Padding between .text and .data

DJ Delorie dj@redhat.com
Wed Feb 15 14:28:00 GMT 2006


> In the linker script, armelf.xc, -- and likely other elf targets --
> this line places 256 bytes of padding between the output .text and
> .data sections.
> 
>   /* Adjust the address for the data segment.  We want to adjust up to
>      the same address within the page on the next page up.  */
>   . = ALIGN(256) + (. & (256 - 1));
> 
> Why is this padding necessary?

It puts *up to* 256 bytes.  It aligns the data to start on the next
"page" so that data and code are always in separate pages and the
memory management unit can deal with them separately (read-only,
shared, page in, etc).  Might also help keep the icache and dcache
sane.

Older linkers padded to 512 byte boundaries to optimize disk access,
since disk sectors are usually 512 bytes.



More information about the Binutils mailing list