| |||
| Home > System V Shared Libraries > Using SVr4 shared libraries > Accessing symbols | |||
The symbol tables provide a way to determine those symbols in shared objects that are referenced by other non-shared objects included in the link stage. Where a reference to a symbol exists, it is defined as having been imported from the shared object.
The linker supports symbol versions. This provides more useful information for the symbol table:
Symbols with local scope in a versioned shared object are not referred to from the outside.
A global versioned symbol has no version, and so the usual symbol matching applies.
A versioned symbol with the HIDDEN visibility
attribute set is a deprecated versioned symbol. The static linker
ignores this.
A versioned symbol where the HIDDEN visibility
attribute is not set is the default symbol.
Symbol versioning information is added to the symbol table when a shared object is loaded that contains symbol versioning tables (and references to versioned symbols are matched). You can use a version script file to specify a list of exported symbols, for example:
armlink file_1.o file_2.o --sysv --shared -o libfoo.so --symver_script ver_script.txt
The linker resolves symbols in shared and non-shared objects in the same way. When an undefined reference matches a definition in a shared object, the linker imports the reference by placing it in the dynamic symbol table.
If you are using a steering file, use EXPORT to
specify exported symbols.
The linker imports undefined symbol references when it finds a matching definition in the dynamic symbol table of a shared object that you specify on the command line. These symbols are then considered to be exported symbols.
When building a shared object, only those symbols affected
by a steering file commands, or exported using __declspec(dllexport) in
the source file, are exported. If you do not specify any steering
file commands, the linker exports all global (non-hidden) symbols
by default.
A non-hidden symbol is one that has the DYNAMIC or PROTECTED visibility
attribute in assembler source, or where the C source code contains __declspec(dllimport) or __declspec(dllexport).
When building an executable file, only the symbols required to execute the image correctly on a Linux platform are exported, that is, the linker imports any symbol found in a shared object. Steering file commands can be used to define additional symbols to be inserted into the dynamic symbol table.
Be aware that armlink generates an error for any undefined references that remain.
See Steering file commands for
more details on using EXPORT.