1
votes

I'm building a DSO under 32-bit GCC 4.2.5 and 64-bit GCC. The 64-bit DSO has extra entries in the dynamic symbol table (nm -D libname.so) that don't appear in the 32-bit DSO.

I'm almost positive this is because the 32-bit DSO uses a static version of libstdc++: all of the extra entries in the table are related to std::vector. Some examples:

 W _ZNSt6vectorIPN3BVT17FileSonarListenerESaIS2_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS2_S4_EERKS2_
 W _ZNSt6vectorIPN3BVT3Net16UDPMessageSocketESaIS3_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS3_S5_EERKS3_
 W _ZNSt6vectorIPN3BVT3Net21MessageSocketListenerESaIS3_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS3_S5_EERKS3_
 W _ZNSt6vectorIPN3BVT4HeadESaIS2_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS2_S4_EERKS2_
 W _ZSt6__findIN9__gnu_cxx17__normal_iteratorIPN3BVT15ServerDiscovery5EntryESt6vectorIS4_SaIS4_EEEES4_ET_SA_SA_RKT0_St26random_access_iterator_tag

The other symbols in the table are explicitly flagged in the source with default visibility with a traditional DLL_EXPORT macro, and I'm compiling with the -fvisibility=hidden flag.

Is there any way to remove these unexpected symbols without affecting clients of the DSO? The DSO defines a pure C interface, so no STL types are being passed around.

Here is the output of gcc -v for both compilers:

Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4)

Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/x86_64-linux-gnu --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default --with-plugin-ld=ld.gold --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)

1

1 Answers

1
votes

Perhaps you could link -lstdc++ when building your .so files? Something like g++ -shared -o yourlib.so yourobjects*.pic.o -lstdc++

And perhaps using a more recent GCC (e.g. 4.6) could help.