--keep=section_id
Specifies input sections that must not be removed by unused section elimination.
Syntax
--keep=section_id
Where section_id
is one of the following:
- symbol
Specifies that an input section defining
symbol
is to be retained during unused section elimination. If multiple definitions ofsymbol
exist, armlink generates an error message.For example, you might use
--keep=int_handler
.To keep all sections that define a symbol ending in
_handler
, use--keep=*_handler
.- object(section)
Specifies that
section
fromobject
is to be retained during unused section elimination. If a single instance ofsection
is generated, you can omitsection
, for example,file.o()
. Otherwise, you must specifysection
.For example, to keep the
vect
section from thevectors.o
object use:--keep=vectors.o(vect)
To keep all sections from the
vectors.o
object where the first three characters of the name of the sections arevec
, use:--keep=vectors.o(vec*)
- object
Specifies that the single input section from
object
is to be retained during unused section elimination. If you use this short form and there is more than one input section inobject
, the linker generates an error message.For example, you might use
--keep=dspdata.o
.To keep the single input section from each of the objects that has a name starting with
dsp
, use--keep=dsp*.o
.
Usage
All forms of the section_id
argument can contain the
*
and ?
wild characters. Matching is case-insensitive,
even on hosts with case-sensitive file naming. For example:
-
--keep foo.o(Premier*)
causes the entire match forPremier*
to be case-insensitive. --keep foo.o(Premier)
causes a case-sensitive match for the string Premier.
Use *.o
to match all object files. Use *
to match all
object files and libraries.
You can specify multiple --keep
options on the command line.
Matching a symbol that has the same name as an object
If you name a symbol with the same name as an object, then
--keep=symbol_id
searches for a symbol that matches
symbol_id
:
If a symbol is found, it matches the symbol.
If no symbol is found, it matches the object.
You can force --keep
to match an object with
--keep=symbol_id()
. Therefore, to keep both the
symbol and the object, specify --keep foo.o --keep foo.o()
.