ALIGN in Linker Scripts

后端 未结 3 1003
梦如初夏
梦如初夏 2021-02-04 05:12

What does the ALIGN keyword do in linker scripts? I read many tutorials about linker scripts but I cant understand what really ALIGN do. Can any one explain it simply. Thanks!

3条回答
  •  感动是毒
    2021-02-04 05:55

    The ALIGN() instructions tell the linker that section(bss, text) should be this much aligned.

    For a typical idea, you can take a look here (4.6.3 "Output Section Description")

    e.g.

        //.data is aligned by word size on the 32-bit architecture and direct it to the data section
    For a 32-bit machine, it typically needs to be word aligned 
    
            .data : ALIGN(4) 
            {
               *(.data*)
            } > data_sdram
    

提交回复
热议问题