public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Radouch, Zdenek" <zradouch@irobot.com>
To: "Radouch, Zdenek" <zradouch@irobot.com>,
	Alan Modra <amodra@gmail.com>,
	"dvalin@internode.on.net" <dvalin@internode.on.net>
Cc: "Paul_Koning@Dell.com" <Paul_Koning@Dell.com>,
	"binutils@sourceware.org"	<binutils@sourceware.org>
Subject: RE: extract ELF load address with binutils?
Date: Thu, 20 Mar 2014 18:12:00 -0000	[thread overview]
Message-ID: <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC329D@hq-mbx-02.wardrobe.irobot.com> (raw)
In-Reply-To: <7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC30E1@hq-mbx-02.wardrobe.irobot.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.)
> 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



      parent reply	other threads:[~2014-03-20 18:12 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
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 [this message]

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=7ADBB2DB4DC7CF4CB641E9ADA826E5E2E1FC329D@hq-mbx-02.wardrobe.irobot.com \
    --to=zradouch@irobot.com \
    --cc=Paul_Koning@Dell.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=dvalin@internode.on.net \
    /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).