This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -fPIC and static libstdc++


Hi Ian,

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?

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?

Thanks once again for your help!

Kind regards,

Philip Bennefall
----- Original Message ----- From: "Ian Lance Taylor" <iant@google.com>
To: <philip@blastbay.com>
Cc: <gcc-help@gcc.gnu.org>
Sent: Friday, October 18, 2013 8:01 PM
Subject: Re: -fPIC and static libstdc++


On Fri, Oct 18, 2013 at 8:57 AM, Philip Bennefall <philip@blastbay.com> wrote:

I am building a shared library which will be distributed to clients in
binary form only. I am attempting to make the same binary run on as many
Linux variants as possible, and so when I build it I specify the options
-shared and -fPIC. As part of the effort of making the library as
independent as possible, I also link both the C and C++ standard libraries
statically into the final shared library. I want to do this because I use
C++11 features internally, and I don't want to force the users of my library
to have a C++11 compiler handy.

When doing this, do I need to build libstdc++ and libgcc from source with
-fPIC as well? Or is it okay to link with the static versions of these
libraries that are provided in my Ubuntu 13.04 gcc package?

On GNU/Linux the static versions of libstdc++ and libgcc are normally
compiled with -fPIC, precisely to support the kind of thing you are
doing.  So it should work fine.

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