1.3.5. Symbol Management Options

1.3.5.1. Define/Undefine Symbols

You can define or undefine a symbol on the tiarmclang command line with the -D and -U options. These can be useful for selecting a particular configuration of your source code from the command line.

-D<symbol>[=<value>]

Define a <symbol> with the specified <value>. If no <value> argument is provided, then the <symbol>’s value will be set to 1. A symbol defined on the command-line via the -D option is equivalent to a pre-defined macro symbol.

-U<symbol>

Undefine an existing pre-defined macro <symbol>.

1.3.5.2. Symbol Visibility

An important part of creating shared objects is managing which symbols defined within a shared object are available to be linked against from outside the shared object.

-fvisibility=<visibility_kind>

Set the default ELF image symbol visibility to the specified <visibility_kind>. All symbols are marked with the specified <visibility_kind> unless explicitly overridden within the C/C++ source code.

Symbols that are declared extern are not affected by the use of the -fvisibility option.

The available <visibility kind> arguments include:

  • default - indicates that symbols have public visibility by default and can be linked against from outside a shared object. Global and weak symbols with public visibility can be preempted by definitions of a symbol with the same name from an object outside of the shared object.

  • hidden - indicates that symbols are not available to be linked against from outside a shared object by default.

  • protected - indicates that symbols defined in a shared object are visible outside of the shared object, but cannot be preempted. A reference to a protected symbol from within the shared object in which it is defined must be resolved by the definition in that shared object.