public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tristan Gingold <gingold@adacore.com>
To: Bahadir Balban <bahadir@l4dev.org>
Cc: binutils <binutils@sourceware.org>
Subject: Re: Loading an elf file
Date: Fri, 09 Apr 2010 10:35:00 -0000	[thread overview]
Message-ID: <F78200D5-C12F-4422-91B2-BDB9145FA6D6@adacore.com> (raw)
In-Reply-To: <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.

  reply	other threads:[~2010-04-09 10:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09  9:50 Bahadir Balban
2010-04-09 10:35 ` Tristan Gingold [this message]
2010-04-09 14:48   ` Bahadir Balban
2010-04-09 15:17     ` Alan Modra
2010-04-09 15:54     ` John Reiser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F78200D5-C12F-4422-91B2-BDB9145FA6D6@adacore.com \
    --to=gingold@adacore.com \
    --cc=bahadir@l4dev.org \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).