The following code compiled with -fvisibility=hidden produces only typeinfo symbols with hidden visibility: #define GOTT_EXPORT __attribute__ ((visibility("default"))) template<class T> struct GOTT_EXPORT spelled_t {}; template<class T> inline std::type_info const &spell() { return typeid(spelled_t<T>); } ... spell<long>() readelf -sW says: 1441: 0000000000180800 16 OBJECT LOCAL HIDDEN 22 _ZTIN4gott4xany9spelled_tIlEE 2536: 0000000000058cb0 26 OBJECT LOCAL HIDDEN 12 _ZTSN4gott4xany9spelled_tIlEE gcc -v says: Reading specs from /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/specs Configured with: /var/tmp/portage/gcc-3.4.4-r1/work/gcc-3.4.4/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/3.4.4 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.4.4 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.4.4/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.4.4/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/include/g++-v3 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --enable-multilib --disable-libmudflap --disable-libgcj --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)
Simplified testcase: #include <typeinfo> template<typename T> struct __attribute__ ((visibility("default"))) Abc{ ~Abc(){} Abc(){} }; const std::type_info *f(void) { return &typeid(Abc<int>); }
Fixed in 4.1.0.