GLOBAL hidden symbols handling in LLD

Question about GLOBAL hidden symbols and how it’s treated during static linking.
I have object A that has NOTYPE GLOBAL HIDDEN UND symbol
I have object B that has FUNC GLOBAL HIDDEN 5 symbol
During static linking the undefined symbol in object A gets resolved to definition in object B.

I thought GLOBAL hidden for the purposes of static linking is LOCAL DEFAULT?

A symbol defined in the current component is hidden if its name is not visible to other components. Such a symbol is necessarily protected. This attribute is used to control the external interface of a component. An object named by such a symbol may still be referenced from another component if its address is passed outside.

A hidden symbol contained in a relocatable object is either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object."

What am I missing?

I believe “component” here is referring to an executable or shared library, e.g. a hidden symbol in a shared library can’t be used by other shared libraries. They’re visible to other object files in the shared library while it’s being linked though. The conversion to STB_LOCAL binding is referring to the symbol table of the final executable/shared library, not how the linker treats the symbols in the input relocatable objects.

Ah, I see.

1 Like