Re: [DynInst_API:] (no subject)


Date: Thu, 13 Nov 2014 10:06:35 -0800 (PST)
From: Matthew LeGendre <legendre1@xxxxxxxx>
Subject: Re: [DynInst_API:] (no subject)

You can't reliably compute the dynamic address of a function until the associated library is loaded*. Once the library is loaded you can get the library's load address and add it to function's symbol value, which gives you the dynamic address.

In ProcControlAPI you can wait for the library to load with an EventLibrary callback. Once it loads, you can get its load address with Library::getLoadAddress(). Add the load address to the function's symbol value and you'll have the function's address in that process.


* = There are cases where you can compute this statically. Many executables (ones not compiled with -fPIE) and system libraries are built to load only a fixed address. For these libraries you can just get the function's symbol value and use it as the address. These libraries will have a Library::getLoadAddress() that returns 0.

-Matt

On Thu, 13 Nov 2014, Fabian Mager wrote:
Hello everyone,
I'm interested in debugging library functions. This works quite well so far
for static libraries. I inspect the debug information of the completely
linked program in order to get the function start addresses. With the help
of ProcControlAPI I'm able to set breakpoints at those addresses before
runtime and do there whatever I want during runtime.
This approach obviously does not work in case the library is loaded
dynamically because the concrete addresses are not known before runtime
hence I don't know where to set the breakpoints. Does DynInst provide some
mechanism to get the final addresses of functions that come with dynamically
loaded libraries?

Thanks,
Fabian


[← Prev in Thread] Current Thread [Next in Thread→]