This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Loading an elf file
- From: Tristan Gingold <gingold at adacore dot com>
- To: Bahadir Balban <bahadir at l4dev dot org>
- Cc: binutils <binutils at sourceware dot org>
- Date: Fri, 9 Apr 2010 12:35:48 +0200
- Subject: Re: Loading an elf file
- References: <4BBEF849.50703@l4dev.org>
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.