This is the mail archive of the
mailing list for the binutils project.
RE: extract ELF load address with binutils?
- From: "Radouch, Zdenek" <zradouch at irobot dot com>
- To: "Paul_Koning at Dell dot com" <Paul_Koning at Dell dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 18 Mar 2014 17:44:11 +0000
- Subject: RE: extract ELF load address with binutils?
- Authentication-results: sourceware.org; auth=none
- References: <7ADBB2DB4DC7CF4CB641E9ADA826E5E2AAC571BC at HQ-MBX-01 dot wardrobe dot irobot dot com> <m3a9i3s8s1 dot fsf at pepe dot airs dot com> <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FBDF7F at hq-mbx-02 dot wardrobe dot irobot dot com> <m3siqgw32g dot fsf at pepe dot airs dot com> <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC0FF6 at hq-mbx-02 dot wardrobe dot irobot dot com> <m3k3brwvew dot fsf at pepe dot airs dot com> <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC2052 at hq-mbx-02 dot wardrobe dot irobot dot com> <C75A84166056C94F84D238A44AF9F6AD16C83E5D at AUSX10MPC103 dot AMER dot DELL dot 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.
"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.
From: Paul_Koning@Dell.com [mailto:Paul_Koning@Dell.com]
Sent: Tuesday, March 18, 2014 1:13 PM
To: Radouch, Zdenek
Subject: Re: extract ELF load address with binutils?
On Mar 18, 2014, at 1:02 PM, Radouch, Zdenek <email@example.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.