--keep=section_id
Specifies input sections that must not be removed by unused section elimination.
Syntax
--keep=section_id
Where
is one of the following: section_id
symbol
Specifies that an input section defining
is to be retained during unused section elimination. If multiple definitions ofsymbol
exist, armlink generates an error message.symbol
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
fromsection
is to be retained during unused section elimination. If a single instance ofobject
is generated, you can omitsection
, for example,section
file.o()
. Otherwise, you must specify
.section
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
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.object
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
argument can contain the section_id
*
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-insensitive match for the string Premier.
Note
The only case where a case-sensitive match is made is for--keep=symbol
when symbol
does not contain any
wildcard characters.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=
searches for a symbol that matches
symbol_id
: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=
. Therefore, to keep both the
symbol and the object, specify symbol_id
()--keep foo.o --keep foo.o()
.