Symbol Elimination
An extension to symbol reduction is the
elimination of a symbol entry from an object's symbol table.
Local symbols are only maintained in an object's
.symtab
symbol table. This entire
table can be removed from the object by using the
link-editor's -z strip-class
option, or
after a link-edit by using
strip
(1). On occasion, you might want
to maintain the .symtab
symbol table but
remove selected local symbol definitions.
Symbol elimination can be carried out using the
mapfile
keyword
ELIMINATE
. As with the
local
directive, symbols can be
individually defined, or the symbol name can be defined as
the special auto-elimination directive
"*". The following example shows the elimination
of the symbol bar
for the previous symbol
reduction example.
$ cat mapfile $mapfile_version 2 SYMBOL_VERSION ISV_1.1 { global: foo; local: str; eliminate: *; }; $ cc -o libfoo.so.1 -M mapfile -G foo.c bar.c $ elfdump -sN.symtab libfoo.so.1 | egrep 'foo$|bar$|str$' [26] 0x10690 0x4 OBJT LOCL H 0 .data str [44] 0x4e8 0x2c FUNC GLOB D 0 .text foo
The -B eliminate
option can
be used to assert the auto-elimination
directive "*" from the command line.