2
votes

I'm trying to write an executable where the .text section is located in a specific location. I wrote the following linker script:

base_address = 0x123456789AB;
SECTIONS
{
    ENTRY(_start)
    . = base_address;
    .text : { *(.text); }
}

However when I look at the memory mapping of the resulting executable, I see:

12345600000-12345679000 r-xp 00000000 08:01 1 /path/to/executable

It is obvious why the section would be aligned to 0x1000, that's page size, but where does 0x100000 come from?

Now the interesting part is that this only happens when I disable build ids with -Wl,--build-id=none, or when I enable them and try to stuff the .note.gnu.build-id section right after .text.

1
I'm having a similar issue - it seems .text sections will be aligned at megabyte boundaries, no idea why or how to suppress it.Ant6n

1 Answers

0
votes

Have a look at the generated map file. It's possible that some of your input .text sections also have their own alignment requirements.