Keil Logo

Technical Support

On-Line Manuals

Linker User Guide

Preface Overview of the Linker Linking Models Supported by armlink Image Structure and Generation Linker Optimization Features Getting Image Details Accessing and Managing Symbols with armlink Scatter-loading Features Scatter File Syntax Linker Command-line Options --any_contingency --any_placement=algorithm --any_sort_order=order --api, --no_api --arm_only --autoat, --no_autoat --be8 --be32 --bestdebug, --no_bestdebug --blx_arm_thumb, --no_blx_arm_thumb --blx_thumb_arm, --no_blx_thumb_arm --branchnop, --no_branchnop --callgraph, --no_callgraph --callgraph_file=filename --callgraph_output=fmt --callgraph_subset=symbol[,symbol,...] --cgfile=type --cgsymbol=type --cgundefined=type --comment_section, --no_comment_section --compress_debug, --no_compress_debug --cpp_compat linker option --cppinit, --no_cppinit --cpu=list --cpu=name --crosser_veneershare, --no_crosser_veneershare --datacompressor=opt --debug, --no_debug --diag_error=tag[,tag,…] --diag_remark=tag[,tag,…] --diag_style=arm|ide|gnu --diag_suppress=tag[,tag,…] --diag_warning=tag[,tag,…] --eager_load_debug, --no_eager_load_debug --edit=file_list --emit_debug_overlay_relocs --emit_debug_overlay_section --emit_non_debug_relocs --emit_relocs --entry=location --errors=filename --exceptions, --no_exceptions --feedback=filename --feedback_image=option --feedback_type=type --filtercomment, --no_filtercomment --fini=symbol --first=section_id --force_explicit_attr --fpu=list --fpu=name --help --info=topic[,topic,…] --info_lib_prefix=opt --init=symbol --inline, --no_inline --inline_type=type --inlineveneer, --no_inlineveneer input-file-list --keep=section_id --largeregions, --no_largeregions --last=section_id --ldpartial --legacyalign, --no_legacyalign --libpath=pathlist --library_type=lib --liclinger=seconds --list=filename --list_mapping_symbols, --no_list_mapping_symbols --load_addr_map_info, --no_load_addr_map_info --locals, --no_locals --mangled, --unmangled --map, --no_map --match=crossmangled --max_er_extension=size --max_veneer_passes=value --max_visibility=type --merge, --no_merge --muldefweak, --no_muldefweak -o filename, --output=filename --output_float_abi=option --override_visibility --pad=num --paged --pagesize=pagesize --partial --piveneer, --no_piveneer --predefine="string" --reduce_paths, --no_reduce_paths --ref_cpp_init, --no_ref_cpp_init --reloc --remarks --remove, --no_remove --ro_base=address --ropi --rosplit --rw_base=address --rwpi --scanlib, --no_scanlib --scatter=filename --section_index_display=type --show_cmdline --show_full_path --show_parent_lib --show_sec_idx --sort=algorithm --split --startup=symbol, --no_startup --strict --strict_enum_size, --no_strict_enum_size --strict_flags, --no_strict_flags --strict_ph, --no_strict_ph --strict_relocations, --no_strict_relocations --strict_symbols, --no_strict_symbols --strict_visibility, --no_strict_visibility --strict_wchar_size, --no_strict_wchar_size --symbols, --no_symbols --symdefs=filename --tailreorder, --no_tailreorder --thumb2_library, --no_thumb2_library --tiebreaker=option --unaligned_access, --no_unaligned_access --undefined=symbol --undefined_and_export=symbol --unresolved=symbol --use_definition_visibility --userlibpath=pathlist --veneerinject, --no_veneerinject --veneer_inject_type=type --veneer_pool_size=size --veneershare, --no_veneershare --verbose --version_number --vfemode=mode --via=filename --vsn --xo_base=address --xref, --no_xref --xrefdbg, --no_xrefdbg --xref{from|to}=object(section) --zi_base=address Linker Steering File Command Reference Via File Syntax

--keep=section_id

9.60 --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 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.
object(section)
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*)
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 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.

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 for Premier* 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=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().
Non-ConfidentialPDF file icon PDF versionARM DUI0377H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.