--keep=section_id linker option
Specifies input sections that must not be removed by unused section elimination.
Where section_id is one of the following:
Specifies that an input section defining symbol is to be retained during unused section elimination. If multiple definitions of symbol 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.
Specifies that section from object is to be retained during unused section elimination. If a single instance of section is generated, you can omit section , for example, file.o(). Otherwise, you must specify section .
For example, to keep the vect section from the vectors.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 are vec, use: --keep=vectors.o(vec*)
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 in object , 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.
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 for Premier* 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().