public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* runtime addresses of functions in shared objects
@ 2001-07-03 18:34 Collins, Tom
  2001-07-04  2:29 ` Ingo Krabbe
  0 siblings, 1 reply; 2+ messages in thread
From: Collins, Tom @ 2001-07-03 18:34 UTC (permalink / raw)
  To: gcc-help

Hello...

Is there a way to determine the runtime addresses of functions that
reside in shared object files?

I am writing a profiler for an application in which I supply the mcount,
mstartup, and moncontrol functions.  The mcount function obtains the
callers return address from the stack.  I have a small multi-threaded
(cloned) application that I have tested this on, and it works fine.

What I am wondering is what to do with shared objects.  Do they not 
undergo relocation when they are loaded?  If so, how do I find out
what those relocated addresses are for those functions in the shared
object?

Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: runtime addresses of functions in shared objects
  2001-07-03 18:34 runtime addresses of functions in shared objects Collins, Tom
@ 2001-07-04  2:29 ` Ingo Krabbe
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Krabbe @ 2001-07-04  2:29 UTC (permalink / raw)
  To: Collins, Tom; +Cc: gcc-help

On Tue, 3 Jul 2001, Collins, Tom wrote:

> Hello...
>
> Is there a way to determine the runtime addresses of functions that
> reside in shared object files?
>
> I am writing a profiler for an application in which I supply the mcount,
> mstartup, and moncontrol functions.  The mcount function obtains the
> callers return address from the stack.  I have a small multi-threaded
> (cloned) application that I have tested this on, and it works fine.
>
> What I am wondering is what to do with shared objects.  Do they not
> undergo relocation when they are loaded?  If so, how do I find out
> what those relocated addresses are for those functions in the shared
> object?
>
> Thanks
>
You should look at dlopen of libdl.so (found in header dlfcn.h). The
dlopen functions can open these shared object files and with dlsym you can
finally get the runtime address of a symbol which you can use in your
program then. There is a Manual Page 'man dlopen' which is enough to
create a small example. It's easy, really !

CU INGO


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-04  2:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-03 18:34 runtime addresses of functions in shared objects Collins, Tom
2001-07-04  2:29 ` Ingo Krabbe

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).