This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: -fPIC and static libstdc++
- From: Ian Lance Taylor <iant at google dot com>
- To: Philip Bennefall <philip at blastbay dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Sun, 20 Oct 2013 19:34:48 -0700
- Subject: Re: -fPIC and static libstdc++
- Authentication-results: sourceware.org; auth=none
- References: <839BCFEEFECB4BF786328EEBFB05CF16 at chicken> <CAKOQZ8wyW8iinbVQZc_zN4m+JOtUMG1QNYj+ifKjj1ZEafydiw at mail dot gmail dot com> <6D81A6BC22404EA994707DB72C8931C7 at chicken>
On Sat, Oct 19, 2013 at 4:22 AM, Philip Bennefall <philip@blastbay.com> wrote:
>
> My last response mistakenly went to you alone, rather than to the list. This
> should be seen by everyone.
>
> As per your suggestion, I inspected the output of readelf -r with libgcc and
> libstdc++. I get an enormous amount of output, but among all the entries I
> see things like the following for libgcc:
>
> 000015a2 00000b04 R_386_PLT32 00000000 __addtf3
> 00000113 00001304 R_386_PLT32 00000000 __fabstf2
> 0000001d 00000c04 R_386_PLT32 00000000 __fixunssfdi
> ... And lots of others.
>
> For libstdc++, I see things like:
> 0000003e 00001904 R_386_PLT32 00000000 _ZNSi6sentryC1ERSib
> 00000017 00001304 R_386_PLT32 00000000 _Znwj
> 0000001e 00001604 R_386_PLT32 00000000 _ZN10__cxxabiv116__enu
> 0000011e 00005904 R_386_PLT32 00000000 _Unwind_Resume
>
> I just chose some of these entirely at random, but I am having a hard time
> interpreting this output. Does it seem as though these libraries have
> relocation information in them? I assume yes?
Yes, they have relocation information. More importantly, the presence
of the R_386_PLT32 relocation means that the code was compiled with
-fPIC.
> Once I have compiled my shared library, is there any trivial way of
> verifying whether or not everything was compiled correctly for maximum
> independence so to speak?
You can use readelf -rd on the shared library to see what other shared
libraries and symbols your library depends on.
Ian