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: "Radouch, Zdenek" <zradouch at irobot dot com>, Alan Modra <amodra at gmail dot com>, "dvalin at internode dot on dot net" <dvalin at internode dot on dot net>
- Cc: "Paul_Koning at Dell dot com" <Paul_Koning at Dell dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 20 Mar 2014 18:11:28 +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> <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC207A at hq-mbx-02 dot wardrobe dot irobot dot com>,<20140318234418 dot GC9145 at bubble dot grove dot modra dot org> <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC30E1 at hq-mbx-02 dot wardrobe dot irobot dot com>
> Erik writes:
> Since you can run a script at the programming site, is there any reason
> not to just send the elf file, so the script can extract address(es),
That *is* the idea, i.e., sending a single file.
> (E.g. from "objdump -h xxx.elf" and a line or two of awk,
Well if you re-read my original post, I said that I simply do not
know how to do it. I am an end user; I don't speak binultils internals.
That is, I don't know how much variation I may face in the sections.
I have no idea why "objdump -h" gives me .text as the first section, and
"readelf -S" on the same file gives it to me as the second one.
I do not know if .text will always be the first chunk in the segment.
That's why my preferred solution would be to rely on one of the binutils
to figure it out for me.
My second solution is to extract the info from a binutil output,
as you suggested. For that, I need an algorithm for finding the section
that will be placed at the beginning of the first segment.
I was willing to throw ten or twenty lines of python at it, if you can
do it with awk, then could I please have the one English sentence that
describes what needs to be done to get the load address?
> or nm xxx.elf | grep <Your_start_address_symbol>),
Can't use nm as there may not be a symbol for the load address
> For myself, I've always just sent intel or motorola hex files for
> loading to the platform - then the load address is also included,
> though not so easily human-readable. (But the programming tools handle
> it without human intervention, since that's what these formats are for.)
You just gave me a great idea for an alternate solution (i.e., if there is
no straight way to parse the section headers):
objcopy -O binary foo.elf foo.data
objcopy -O srec foo.elf | s19toladdr >foo.addr
All I have to do in s19toladdr is to parse the first line to extract
the load address.