From: Andreas Jaeger <aj@suse.de>
To: Guido Guenther <guido.guenther@gmx.net>
Cc: linux-mips@oss.sgi.com
Subject: Re: understanding elf_machine_load_address
Date: Sat, 08 Dec 2001 16:18:53 +0100 [thread overview]
Message-ID: <u8n10tg2oy.fsf@gromit.moeb> (raw)
In-Reply-To: <20011208141141.GA11437@bogon.ms20.nix> (Guido Guenther's message of "Sat, 8 Dec 2001 15:11:42 +0100")
Guido Guenther <guido.guenther@gmx.net> writes:
> Hi,
> I'm trying to understand to following snippet from glibc's
> sysdeps/mips/dl-machine.h:
That one is really a bit tricky but it should be correct.
You should add the comment in front:
/* Return the run-time load address of the shared object. */
> elf_machine_load_address (void)
> {
> ElfW(Addr) addr;
> asm (" .set noreorder\n"
> " la %0, here\n"
load address this object has at build time (that's the address objdump
prints) and which is different than the current address (a shared
library can be loaded to any address and elf_machine_load_address is
called before relocation).
> " bltzal $0, here\n"
> " nop\n"
> "here: subu %0, $31, %0\n"
Subtract shared address of "here" from address of "here" at build time
- and you know at which address byte 0 of the shared library is
loaded.
> " .set reorder\n"
> : "=r" (addr)
> : /* No inputs */
> : "$31");
> return addr;
> }
>
> As of my understanding addr is zero since $31-%0 is always
> zero(%0 stored (before the subu) the address of 'here', as does $31
> after the bltzal). Please beat me with a cluebat.
Enough cluebat?
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
next prev parent reply other threads:[~2001-12-08 17:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-08 14:11 understanding elf_machine_load_address Guido Guenther
2001-12-08 15:18 ` Andreas Jaeger [this message]
2001-12-08 16:37 ` Guido Guenther
2001-12-08 16:47 ` Daniel Jacobowitz
2001-12-08 19:42 ` Andreas Jaeger
2001-12-08 20:23 ` Guido Guenther
2001-12-08 20:52 ` Andreas Jaeger
2001-12-08 21:03 ` Daniel Jacobowitz
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=u8n10tg2oy.fsf@gromit.moeb \
--to=aj@suse.de \
--cc=guido.guenther@gmx.net \
--cc=linux-mips@oss.sgi.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.