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: Tracing shared libraries (how to find link map)


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


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