This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Tracing shared libraries (how to find link map)
- From: Daniel Jacobowitz <drow at false dot org>
- To: Steve Fink <sphink at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 5 Sep 2006 09:36:03 -0400
- Subject: Re: Tracing shared libraries (how to find link map)
- References: <7d7f2e8c0609011741k4b5a75e6of32386c12fffe9b1@mail.gmail.com>
This doesn't really have much to do with binutils, but I happen to know
the answers...
On Fri, Sep 01, 2006 at 05:41:43PM -0700, Steve Fink wrote:
> If I somehow knew that libA.so were getting loaded and got a trap
> after that, then I still wouldn't know how to find b() to set a
> breakpoint in it because the PLT of libA.so looks like it is stored as
> a relative address in the ELF header.
Take a look at the DT_DEBUG dynamic tag, which points (after the
dynamic linker has first run) to a struct r_debug. You can find a list
of link maps there for all loaded shared libraries. These include
base addresses.
Figuring out where to set the breakpoint is a bit tricky though.
GDB does it by name, e.g. glibc uses _dl_debug_state. It's described
in struct r_debug (r_brk), but that's not initialized until after the
program has run...
--
Daniel Jacobowitz
CodeSourcery