http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50348
Bug #: 50348 Summary: -fvisibility=hidden doesn't hide stl implementation details. Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: pl...@agmk.net $ cat x.hpp #ifndef x_hpp #define x_hpp #include <vector> struct X { void foo(); }; typedef std::vector< X > VX; VX bar() __attribute((visibility( "default" ))); #endif $ cat x.cpp #include "x.hpp" VX bar() { return VX(); } $ g++ -fvisibility=hidden -fvisibility-inlines-hidden -fPIC x.cpp -Wall -shared -o libx.so -s $ readelf -sW libx.so | grep -v UND | c++filt Symbol table '.dynsym' contains 20 entries: Num: Value Size Type Bind Vis Ndx Name 2: 00000000000007b0 0 FUNC GLOBAL DEFAULT 10 _init 3: 00000000000009f8 0 FUNC GLOBAL DEFAULT 13 _fini 6: 000000000000090c 30 FUNC GLOBAL DEFAULT 12 bar() 7: 000000000000092a 26 FUNC WEAK DEFAULT 12 std::vector<X, std::allocator<X> >::vector() 8: 000000000000092a 26 FUNC WEAK DEFAULT 12 std::vector<X, std::allocator<X> >::vector() 9: 0000000000000944 26 FUNC WEAK DEFAULT 12 std::_Vector_base<X, std::allocator<X> >::_Vector_base() 10: 000000000000095e 61 FUNC WEAK DEFAULT 12 std::_Vector_base<X, std::allocator<X> >::_Vector_impl::_Vector_impl() 11: 000000000000095e 61 FUNC WEAK DEFAULT 12 std::_Vector_base<X, std::allocator<X> >::_Vector_impl::_Vector_impl() 12: 000000000000099c 26 FUNC WEAK DEFAULT 12 std::allocator<X>::allocator() 13: 00000000000009b6 10 FUNC WEAK DEFAULT 12 __gnu_cxx::new_allocator<X>::new_allocator() 14: 0000000000000944 26 FUNC WEAK DEFAULT 12 std::_Vector_base<X, std::allocator<X> >::_Vector_base() 15: 000000000000099c 26 FUNC WEAK DEFAULT 12 std::allocator<X>::allocator() 16: 00000000000009b6 10 FUNC WEAK DEFAULT 12 __gnu_cxx::new_allocator<X>::new_allocator() 17: 0000000000001dc0 0 NOTYPE GLOBAL DEFAULT ABS _edata 18: 0000000000001dc0 0 NOTYPE GLOBAL DEFAULT ABS __bss_start 19: 0000000000001dd0 0 NOTYPE GLOBAL DEFAULT ABS _end imho the std::vector details shouldn't have default visiblity in this case.