Re: dlsym interposition question
Re: dlsym interposition question
- Subject: Re: dlsym interposition question
- From: Ariel Burton <email@hidden>
- Date: Sun, 06 Oct 2013 16:33:38 -0400
Jonas and Greg,
Thanks for your replies.
A number of comments.
Firstly, I'm not sure I made this clear. What I want to do
is to be able to locate the interposing implementation of
getpid and the underlying system-provided implementation
in the main program.
On ELF-like systems dlopening the dynamic library explicitly
allows the definition in that library to be found. That's
not happening here.
Secondly, dlsym ( RTLD_NEXT, "getpid" ) in the interposer
finds the implementation in the interposer, not that in the
system library.
So in either case (main program or the interposer),
how can one find the interposing and interposed implemetations?
Thanks,
Ariel Burton
==
On Fri 4 Oct 13:55, Greg Parker wrote:
> On Oct 4, 2013, at 2:08 AM, Jonas Maebe <email@hidden> wrote:
> > On 04 Oct 2013, at 01:23, email@hidden wrote:
> >> My question is this. How can I find the address of the
> >> definition of getpid that was interposed (i.e., the one
> >> in libSystem.dylib)?
> >
> > Calling dlsym with RTLD_NEXT should work for that, although the description for that parameter in the man page (at least under Mac OS X 10.5) seems to be wrong:
> >
> > ***
> > If dlsym() is called with the special handle RTLD_NEXT, then the search for the symbol is limited to the images which were loaded after the one issuing the call to dlsym().
> > ***
> >
> > I think that should read "... images which were loaded *before* the one issuing the call ..."
>
> That depends on your point of view. The dynamic loader starts with the main executable and discovers the libraries it needs to load top-down, which means libSystem is "after" the app itself. But bindings and initializers run bottom-up, which means libSystem is "before" the app itself.
>
> Newer versions of the man page describe this more clearly:
> If dlsym() is called with the special handle RTLD_NEXT, then dyld
> searches for the symbol in the dylibs the calling image linked against
> when built. ...
>
>
> --
> Greg Parker email@hidden Runtime Wrangler
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden