Re: dlopen() sees some symbols, but not others
- From: Paul Pluzhnikov <ppluzhnikov-nsp@xxxxxxxxxxx>
- Date: Wed, 27 Dec 2006 17:02:54 -0800
"Rob Y" <ryampolsky@xxxxxxxxx> writes:
For example, I wanted a module with some utility functions to be
available to the loaded library, but since the main app doesn't call
any of those functions, I added a stub module to the main app with a
call to one of these functions in order to force the utility module to
be linked to the main app.
Here is your first mistake: you are transporting your knowledge of
how UNIX linkers and object files work to AIX, which doesn't quite
work that way.
On UNIX, calling one routine from .o links in that whole .o
On AIX, compiler (by default) emits one CSect for each individual
function, and linker (by default) garbage-collects unused CSects.
Thus referencing one function from .o gets you that one function (and
whatever that function itself calls); but not the rest of the .o.
That worked for the most part - my dlopen'd code was able to call
functions in that module. But a function called FormatElement(), which
was in that module was unresolvable by dlopen().
Was it linked into the exe, or was it garbage-collected?
("nm a.out" will answer that).
In fact, another
function calaled LogFormattedElement() in the same source module was
resolvable and calls FormatElement() internally. As long as my
dlopen'd library called this second function, it worked.
Hmm, that's inconsistent with my mental model of how AIX linking
works. Are you sure? Can you construct a small test case?
Finally, I added a call to FormatElement() to my stub module to
explicitly 'link it in', and now it's resolvable by dlopen().
That's consistent with FormatElement() having been GC'd,
until you added explicit reference for it ...
Since this code was obviously there in the first place,
I don't think it was there in the first place ...
and I used -bexpall, shouldn't it just have been available?
Yes, *if* it was there, it should have been available (provided
its name doesn't begin with underscore -- '-bexpall' doesn't
export those).
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
.
- Follow-Ups:
- Re: dlopen() sees some symbols, but not others
- From: Rob Y
- Re: dlopen() sees some symbols, but not others
- From: Rob Y
- Re: dlopen() sees some symbols, but not others
- References:
- dlopen() sees some symbols, but not others
- From: Rob Y
- dlopen() sees some symbols, but not others
- Prev by Date: dlopen() sees some symbols, but not others
- Next by Date: Re: get all shared memory segments
- Previous by thread: dlopen() sees some symbols, but not others
- Next by thread: Re: dlopen() sees some symbols, but not others
- Index(es):
Relevant Pages
|