public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Radouch, Zdenek" <zradouch@irobot.com>
To: "Paul_Koning@Dell.com" <Paul_Koning@Dell.com>
Cc: "binutils@sourceware.org" <binutils@sourceware.org>
Subject: RE: extract ELF load address with binutils?
Date: Tue, 18 Mar 2014 17:44:00 -0000	[thread overview]
Message-ID: <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC207A@hq-mbx-02.wardrobe.irobot.com> (raw)
In-Reply-To: <C75A84166056C94F84D238A44AF9F6AD16C83E5D@AUSX10MPC103.AMER.DELL.COM>

But as I (and objcopy) have illustrated:
1. Not all LOAD types get loaded
2. The address where the segment is loaded can be "wrong", when the loaded segment
   has been padded.

I agree about the multiple segments, but I can't make it work even for one.
The padding clearly comes from the non-embedded world where throwing away 32k of memory
may be OK; I don't have that luxury.

Objcopy says:
"When objcopy generates a raw binary file, it will essentially produce a memory dump
of the contents of the input object file." Memory dump is what I want, to me "undumping"
the dump is synonymous with loading the right data in the right place in memory. 
It is my understanding that the LOAD segment itself can contain an ELF header so it
can be loaded without additional metadata. I have no idea how (or whether) I can make
readelf give me the actual data to be loaded. 
That's where I see a big difference between objcopy and readelf.

-Z
 

-----Original Message-----
From: Paul_Koning@Dell.com [mailto:Paul_Koning@Dell.com] 
Sent: Tuesday, March 18, 2014 1:13 PM
To: Radouch, Zdenek
Cc: binutils@sourceware.org
Subject: Re: extract ELF load address with binutils?


On Mar 18, 2014, at 1:02 PM, Radouch, Zdenek <zradouch@irobot.com> wrote:

> I am writing a firmware updater that takes an ELF executable and needs 
> to extract the RAM data and the address to where the data should be loaded. ...
> The question is can I somehow convince one of the binutils to give me 
> the load address alone, so that I don't have to invent an algorithm extracting the address from the section dump?

I'm not sure the notion of "THE load address" makes sense.  It may be valid for your specific case, but not in general.  ELF files can have multiple load sections, each of which has a load address.

Normally I would say: look in the program headers.  Each header of type LOAD describes something that's loaded, and it shows the addresses.

	paul


  reply	other threads:[~2014-03-18 17:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7ADBB2DB4DC7CF4CB641E9ADA826E5E2AAC571BC@HQ-MBX-01.wardrobe.irobot.com>
     [not found] ` <m3a9i3s8s1.fsf@pepe.airs.com>
     [not found]   ` <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FBDF7F@hq-mbx-02.wardrobe.irobot.com>
     [not found]     ` <m3siqgw32g.fsf@pepe.airs.com>
     [not found]       ` <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC0FF6@hq-mbx-02.wardrobe.irobot.com>
     [not found]         ` <m3k3brwvew.fsf@pepe.airs.com>
2014-03-18 17:02           ` Radouch, Zdenek
2014-03-18 17:13             ` Paul_Koning
2014-03-18 17:44               ` Radouch, Zdenek [this message]
2014-03-18 23:44                 ` Alan Modra
2014-03-19 12:05                   ` Radouch, Zdenek
2014-03-19 13:24                     ` Erik Christiansen
2014-03-20 18:12                     ` Radouch, Zdenek

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=7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC207A@hq-mbx-02.wardrobe.irobot.com \
    --to=zradouch@irobot.com \
    --cc=Paul_Koning@Dell.com \
    --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).