This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: extract ELF load address with binutils?


> 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.)
> Erik

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.

Thanks!

-Z




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]