This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu mailing list for the glibc project.


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

Shared library -shared vs. -fpic


Hi all,

I thought I'd report my findings. 

Indeed -fpic and -fPIC are not necessary for shared libraries to be used
either by ld.so or libdl.so. Why? I have no idea... As long as you do
-shared with gcc, you're golden.

However, interesting enough, when I dlopen() to load a shared library
that I built and that library references _start,
dlopen() reports that _start is undefined. _init is defined so I used
that instead. But, as it turns out, these symbols get changed when the
library is dlopen(). For some reason, I cannot get to _init or _start of
the original code.
Anyone know how to do this? It works ok for now, I'd just like to
understand a bit more of what's going on.

Why would I be using these symbols? Well, I'm doing statistical
profiling of the address space and the loaded shared library needs to
get the start and end of the texts address space. Any ideas how to do
this?

I'll send the tool to this list, as soon as I do the demo on Wednesday.
You may find it interesting. What does it do? Dynamic insertion of
profiling probes into running executables. I can profile subroutines
using wallclock, or the hardware counters, I can also generate
statistical profiles. This works for serial, threaded, MPI'd and mixed
executables. Pretty cool eh?

Regards,

-Phil

P.S. Attached is the test case for those who are curious.

Wolfgang Sourdeau wrote:
> 
> >>>>> "Philip" == Philip J Mucci <mucci@cs.utk.edu> writes:
> 
>     Philip> Wolfgang, thanks for the information. So the shared
>     Philip> library still works?
> 
> It does. Just give it a try and see by yourself.
> 
>     Philip> I can't imagine how that works.... Is that true of using the shared
>     Philip> library through dlopen? I'll try it.
> 
> I don't know if it is working that way. But try the different ways and
> tell us how it worked.
> 
> W

shlib-wierd.shar


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