Loading an elf file
Tristan Gingold
gingold@adacore.com
Fri Apr 9 10:35:00 GMT 2010
On Apr 9, 2010, at 11:50 AM, Bahadir Balban wrote:
> Hi,
>
> I am trying to load an elf file. Often read-only, writeable and exec
> sections are packed into one loadable segment as below:
>
>> Program Headers:
>> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
>> LOAD 0x008000 0xf0008000 0x00008000 0x29000 0x2f21c RWE 0x8000
>> LOAD 0x038000 0xf0038000 0x00038000 0x044e8 0x044e8 RW 0x8000
>>
>> Section to Segment mapping:
>> Segment Sections...
>> 00 .text .rodata .data .bss
>> 01 .init
>
> This forces me to inspect sections rather than program segments to
> distinguish RX, RO, RW parts of the executable.
>
> Firstly is the above elf file correctly assembled? Secondly I thought
> the standard practice to load an elf file is to use program headers
> only, but I am obliged to inspect sections. Can you comment?
No, you don't need to inspect sections. Looks like the executable was not generated as you expected it.
The way sections are packed into segments is controlled by the linker script. You need to check it.
You'd also be better to check the attributes of the sections.
Tristan.
More information about the Binutils
mailing list