Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ".hidden" mean in the output of output objdump -t?

Tags:

c++

c

objdump

Example:

$ objdump Logger.cpp.o  -t

00000000 g     F .text  00000000 .hidden __sti___10_Logger_cpp_0b2ae32b
like image 999
MBober Avatar asked Jul 04 '12 13:07

MBober


2 Answers

It means that the visibility of the symbol is hidden: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html

Reasons for changing the visibility of symbols include:

  • Less risk of symbol collision.
  • Smaller binaries.
  • Reduced start-up time because the dynamic linker does not need to process as many symbols.
  • Opportunities for more efficient code because the compiler knows that a symbol cannot be overridden via an LD_PRELOAD-type system.
  • Prevention of third-party software calling into undocumented APIs.

See http://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html for more information.

like image 93
Daniel Trebbien Avatar answered Nov 12 '22 18:11

Daniel Trebbien


A link that explains visibility support (for gcc)

From the link:

  • It very substantially improves load times of your DSO (Dynamic Shared Object). For example, a huge C++ template-based library which was tested (the TnFOX Boost.Python bindings library) now loads in eight seconds rather than over six minutes!

  • It lets the optimiser produce better code. PLT indirections (when a function call or variable access must be looked up via the Global Offset Table such as in PIC code) can be completely avoided, thus substantially avoiding pipeline stalls on modern processors and thus much faster code. Furthermore when most of the symbols are bound locally, they can be safely elided (removed) completely through the entire DSO. This gives greater latitude especially to the inliner which no longer needs to keep an entry point around "just in case".

  • It reduces the size of your DSO by 5-20%. ELF's exported symbol table format is quite a space hog, giving the complete mangled symbol name which with heavy template usage can average around 1000 bytes. C++ templates spew out a huge amount of symbols and a typical C++ library can easily surpass 30,000 symbols which is around 5-6Mb! Therefore if you cut out the 60-80% of unnecessary symbols, your DSO can be megabytes smaller!

  • Much lower chance of symbol collision. The old woe of two libraries internally using the same symbol for different things is finally behind us with this patch. Hallelujah!

Although the library quoted above is an extreme case, the new visibility support reduced the exported symbol table from > 200,000 symbols to less than 18,000. Some 21Mb was knocked off the binary size as well!

A usage sample and also potential pitfall when using visibilty attribute

like image 38
slashmais Avatar answered Nov 12 '22 18:11

slashmais