9. Command-line options
Here’s the list of command-line options accepted by the ELD:
9.1. Common options for all the backends
9.1.1. Compatibility Or Ignored Options
- -EL
Link little endian objects.
- -Qy
This option is ignored for SVR4 compatibility
- --add-needed
Deprecated
- --copy-dt-needed-entries
Add the dynamic libraries mentioned to DT_NEEDED
- --ignore-unknown-opts
Disable warnings of unimplemented options
- --nmagic
Turn off page alignment of sections, and disable linking against shared libraries
- --no-add-needed
Deprecated
- --no-allow-shlib-undefined
Do not allow undefined symbols from dynamic library when creating executables
- --no-copy-dt-needed-entries
Turn off the effect of the –copy-dt-needed-entries
- --no-omagic
This option negates most of the effects of the -N option.Disable linking with shared libraries
- --omagic
Set the text and data sections to be readable and writable. Also, do not page-align the data segment, and disable linking against shared libraries.
- -plugin <pluginfile>
Specify a plugin file
- -plugin-opt <plugin-opt>
Specify plugin options
- -thin-archive-rule-matching-compatibility, --thin-archive-rule-matching-compatibility
Provides rule-matching compatibility when fat archives are converted to thin archives
9.1.2. DIAGNOSITC OPTIONS
- -W<warn-type>
Print warnings which are OFF by default
-Wall : print all warnings
-W[no]linker-script : display warnings detected while parsing linker scripts
-W[no]attribute-mix : display a warning if object files of RISC-V with different attributes are being linked
-W[no-]archive-file : display warnings detected while reading archive files
-W[no-]linker-script-memory : display warnings detected while processing linker script memory command
-W[no-]bad-dot-assignments : display warnings for bad dot assignments
-Wwhole-archive : display a warning when whole-archive is enabled for any archive file
- -color <on/off>
Enable color output for diagnostics
- -cref, --cref
Print the references for a symbol or section
- -t
Print all files processed by the linker
- -display_hotness <value>
Display hotness information for optimization remarks
- --emit-timing-stats <filename>
Emit time statistics of various linker operatons to the specified file
- -emit-timing-stats-in-output, --emit-timing-stats-in-output
Insert link-time stats in section .note.qc.timing
- --error-limit <max-error-number>
Maximum number of errors to emit before stopping (0 = no limit)
- --error-style <style>
Specify an error style, LLVM/GNU
- --fatal-internal-errors
Enable fatal internal errors
- --fatal-warnings
Enable fatal warnings
- --gc-cref <symbol/section>
Print the references for a symbol or section when garbage collection is enabled
- --no-fatal-internal-errors
Disable fatal internal errors
- --no-fatal-warnings
Disable fatal warnings
- --no-warn-mismatch
Do not Warn on incompatible files passed to the linker.
- -opt-record-file, --opt-record-file
Create diagnostic yaml file
- -print-timing-stats, --print-timing-stats
Print time statistics of various linker operatons to console
- --progress-bar
Show Progress Bar
- --summary
Display linker run summary at the end
- --time-region <region>
Emit time statistics for specified region of linker operation
- -trace <trace-type>
Allow tracing of
–trace=linker-script : trace linker script
–trace=files : trace input files
–trace=reloc=<pattern> : trace relocations
–trace=symbol=<symbol-name> : trace symbol
–trace=all-symbols : trace all symbols
–trace=LTO : trace LTO
–trace=garbage-collection : trace linker garbage collection
–trace=plugin : trace plugin
–trace=threads : trace threads
–trace=assignments : trace symbol assignments
–trace=command-line : trace header info
–trace=live-edges : trace reachable sections when garbage collection is enabled
–trace=merge-strings : trace linker string optimization
–trace=trampolines : trace trampolines
–trace=wrap-symbols : trace symbol wrap options
–trace=symdef : trace symbol resolution from symdef files
–trace=dynamic-linking : trace dynamic linking
- --trace-linker-script
Trace stages of linker script processing
- --trace-lto
Trace stages of lto
- -trace-merge-strings <option>
Emit diagnostics describing how strings were merged. Options: all(default), allocatable_sections, <output section (regex)>
- -trace-reloc <relocation>
trace a particular relocation
- -trace-section <section_name>
Show metadata about a particular section
- -y <symbol>
Trace a particular symbol
- --verbose
Enable verbose output
- -verbose=<verbose-level>
Enable verbose output
- -verify-options <option>
Verify certain internal linker computations - currently supports reloc
- --warn-common
Warn on common symbols
- --warn-limit <maxwarnings>
Maximum number of warnings to emit (0 = no limit)
- --warn-mismatch
Warn on incompatible files passed to the linker.
9.1.3. DYNAMIC LIBRARY OPTIONS
- -Bgroup
Enable runtime linker to handle lookups in this object and its dependencies to be performed only inside this group
- -Bsymbolic
Bind references to global symbols to the definition within the shared library
- -Bsymbolic-functions
Bind references to global functions to the definition within the shared library
- -g
Enable debug output when building shared libraries or executables
- -fPIC
Enable PIC mode
- --hash-size <size>
Specify a hash size when creating the hash sections for the dynamic loader
- -hash-style <hashstyle>
Specify a hash style when creating the hash sections for the dynamic loader
Don’t Warn if the linker adds a DT_TEXTREL
- -soname=<name>, --soname=<name>
Set the internal DT_SONAME field to the specified name
Warn if the linker adds a DT_TEXTREL
9.1.4. DYNAMIC LIBRARY/EXECUTABLE OPTIONS
- -dynamic-linker <path>
Set the path to the dynamic linker
- -export-dynamic, --export-dynamic
Add all symbols to the dynamic symbol table when creating executables
- -export-dynamic-symbol <symbol>
Export specified symbol to dynamic symbol table
- -force-dynamic, --force-dynamic
Build executable as a force dynamic executable
- -no-dynamic-linker, --no-dynamic-linker
The program does not need a dynamic linker when creating static PIE executables
- --no-export-dynamic
- -rpath <path>
Add a path to the runtime library search path
- -rpath-link <path>
Specifies the path to search
9.1.5. Extended Options
- --align-segments
Align segments to page boundaries
- --allow-bss-conversion
Dont produce an error when mixing NOBITS, and PROGBITS sections in the same segment
- -copy-farcalls-from-file <filename>
Copy far calls instead of using trampolines
- -z <extended-opts>
Extended Options or Non standard options.
Available options are:
-z=combreloc : Combines multiple reloc sections and sorts them to make dynamicsymbol lookup caching
-z=now : Enables immediate binding
-z=nocopyreloc : Disables Copy Relocation
- --disable-new-dtags
Disable new dynamic tags
- -dump-mapping-file <outputfilename>
Dump mapping file to output file
- -dump-response-file <outputfilename>
Dump response file to output file
- -emit-relocs-llvm, --emit-relocs-llvm
Emit relocations sections
- --enable-new-dtags
Enable new dynamic tags
- -mapping-file <INI-file>
Reproduce link using a mapping file
- --no-align-segments
Dont align segments to page boundaries
- -no-emit-relocs, --no-emit-relocs
Dont emit relocations in the output file, applicable to –emit-relocs-llvm option too
- -no-reuse-trampolines-file <filename>
Dont reuse trampolines for symbols specified in file
- --no-verify
Dont verify link output
- -reproduce <tarfilename>
Write a tar file containing input files and command line options to inspect and re-link
- -reproduce-compressed <tarfilename>
Write compressed tar file in zlib format containing input files and command line options to inspect and re-link.
- -reproduce-on-fail <tarfilename>
Write reproduce tar file when link failscontaining input files and command line options to inspect and re-link.
- -rosegment, --rosegment
Put read-only non-executable sections in their own segment
- --script-options <matchtype>
Specify a match type, match-gnu/match-llvm
- --use-old-style-trampoline-name
Use old style of naming trampolines
9.1.6. GENERAL OPTIONS
- --build-id
Request creation of “.note.gnu.build-id” ELF note section
- -build-id=fast/md5/sha1/tree/uuid/0x<hexstring>/none
Request creation of “.note.gnu.build-id” ELF note section
- -o <outputfile>
Path to file to write output
- --repository-version
Print the Linker Repository version
- -sysroot <sysroot-path>
Set the system root
- --version
Print the Linker version
9.1.8. Input Format
- -b <input-format>
Specify input format for inputs following this option. Supported values: binary,default
9.1.9. OUTPUT KIND
- -Bdynamic
Link against dynamic library
- -dynamic
Create dynamic executable (default)
- -no-pie
Do not create a PIE executable
- -pie
Create PIE executable
- -r
Create relocatable object file
Create dynamic library
- -static
Create static executable
9.1.10. Link Time Speedup
- -enable-threads=<option>
make linker fully threaded, available options: all
- -no-threads, --no-threads
Disable Threads at Link time
- --thread-count <threadcount>
Specify the number of threads for all linker operations
- -threads, --threads
Enable Threads at Link time
9.1.11. LLVM and Target Options
- -m
Select target emulation
- -mabi <mabi>
Target ABI
- -march <march>
Target architecture
- -mcpu <mcpu>
Target CPU
- -mllvm <option>
Options to pass to LLVM
- -mtriple <triple>
Target triple to link for
9.1.12. LTO Options
- -exclude-lto-filelist <list_of_files>
Specify a list of files that are to be disregarded while using embedded bitcode section for LTO. This has no effect if -flto switch is not used.
- -flto, --flto
Enable LTO if a Bitcode file is present.
- -flto-options <option>
Specify various options with LTO
- -flto-use-as, --flto-use-as
Use the standalone assembler instead of the integrated assembler for LTO
- -include-lto-filelist <list_of_files>
Specify a list of files with embedded bitcode sections that are to be used for LTO. This has no effect if -flto switch is used
- -save-temps, --save-temps
Save the temporary files produced by LTO
- -save-temps=<filename>
Save the temporary files produced by LTO
9.1.13. EXECUTABLE OPTIONS
- -L
Path to search for libraries or linker scripts
- -Y <path>
Add path to the default library search path
- -emit-relocs, --emit-relocs
Make Emit relocs behave just like GNU.
- -e <symbolname>
Name of entry point symbol
- -fini <symbol>
Specify a finalizer function
- --image-base <address>
- -init <symbol>
Specify an initializer function
- -l
Root name of library to use
- --library-path <path>
Path to search for libraries or linker scripts
- --library=<namespec>
library to use
- -no-whole-archive, --no-whole-archive
Restores the default behavior of loading archive members
- --noinhibit-exec
Retain the executable output file whenever it is still usable
- -nostdlib
Disable default search path for libraries
- -whole-archive, --whole-archive
Force load of all members in a static library
9.1.14. Map Options
- -Map <filename>
Dump the output layout to the map file
- -MapDetail <option>
Detail information in the map file
- -MapStyle <fileformat>
Dump the output layout to the map file in YAML/Text/Binary Form
- -M
Emit the map file
- -trampoline-map <filename>
Dump Trampoline Information in YAML format
- --color-map
Color the map file
9.1.15. Misc Features
- -allow-incompatible-section-mix, --allow-incompatible-section-mix
Allow incompatible section mix
9.1.16. OPTIMIZATION OPTIONS
- --eh-frame-hdr
Create EH Frame Header section for faster exception handling
- -gc-sections, --gc-sections
Enable garbage collection
- -no-gc-sections, --no-gc-sections
Disable garbage collection
- --no-merge-strings
Disable String Merging
- --no-trampolines
Disable Trampolines
- -print-gc-sections, --print-gc-sections
Print sections that are garbage collected
9.1.17. Features From other Linkers
- -R <filename>
Read symbol names and addresses from filename
- -symdef, --symdef
Output SymDef file to console
- --symdef-file <filename>
Emit SymDef file
- --symdef-style <style>
Determine how to handle symbol resolution for symbols from symdef file, Options available are provide
9.1.18. Plugin Options
- --no-default-plugins
Allow no plugins to be implicitly loaded
- --plugin-config <config-file>
Specify a plugin configuration
9.1.19. SYMBOL RESOLUTION OPTIONS
- --allow-multiple-definition
Allow multiple definitions
- -allow-shlib-undefined, --allow-shlib-undefined
Allow undefined symbols from dynamic library when creating executables
- --as-needed
This option affects ELF DT_NEEDED tags for dynamic libraries mentioned on the command line
- -defsym symbol=<expression>
Create a global symbol in the output file containing the absolute address given by expression
- -end-group, --end-group
End a group
- --no-as-needed
This option restores the default behavior of adding DT_NEEDED entries
- -no-undefined, --no-undefined
Report unresolved symbol references from regular object files
- -start-group, --start-group
Start a group
- -u
Force symbol to be entered in the output file as an undefined symbol
- --use-shlib-undefines
Resolve undefined symbols from dynamic libraries
- --warn-once
Warn only once for every undefined reference
9.1.20. SCRIPT OPTIONS
- -T <linkerscriptfile>
Use the given linker script in place of the default script.
- -Tbss <address>
Specify an address for the .bss section
- -Tdata <address>
Specify an address for the .data section
- -Ttext <address>
Specify an address for the .text section
- -Ttext-segment <address>
Specify an address for the .text-segment segment
- -default-script <pluginfile>
Use the linker script as the default linker script.
- --no-check-sections
Do not check section addresses for overlaps
- -dynamic-list <list-of-symbols>
Specify a list of symbols if present will be exported
- --check-sections
Check section addresses for overlaps(default)
- --exclude-libs <libs>
Specifies a list of archive libraries from which symbols should not be automatically exported
- -extern-list <list-of-symbols>
Specify a list of symbols that exists as external dependencies
- --global-merge-non-alloc-strings
merge non-alloc strings across output sections
- --map-section <section>
Specify a input section that maps to a output section
- -orphan-handling <mode>
Specify how to handle orphan sections. Options available are place,error, warn
- --print-memory-usage
Print memory usage when MEMORY linker script directive is used
- -section-start <address>
Specify a virtual output section address for a specified section
- -sort-section=<option>
Sort sections. Options availabe are name , alignment
- -unique-output-sections, --unique-output-sections
Place each input section in a unique output section
- --unresolved-symbols <option>
Determine how to handle unresolved symbols, Options available are ignore-all,report-all(Default), ignore-in-object-files, ignore-in-shared-libs
- -version-script <linkersciptfile>
Use the linker script as a version script.
9.1.21. SYMBOL OPTIONS
- -d
Assign space to common symbols
- --demangle
Demangle C++ symbols
- --demangle-style <value>
Specify whether the linker should demangle symbols when emitting errors or emitting Map files
- --discard-all
Discard all symbols
- --discard-locals
Discard all local symbols
- --no-demangle
Dont demangle C++ symbols
- -portable <symbol>
Specify symbol to be portable wrapped to
- --sort-common
sort common symbols by alignment
- -sort-common=<option>
Sort common symbols by ascdending/descending order of alignment
- --strip-all
Omit all symbol informations from output
- --strip-debug
Omit all debug information from output
- -wrap <symbol>
Specify symbol to be wrapped to
9.2. ARM and AArch64 specific options
9.2.1. ARM/AArch64 Linker Options
- -compact, --compact
Create a smaller output file. The Loader need to support such files
- --disable-bss-conversion
Don’t convert BSS to NonBSS when BSS/NonBSS Sections are mixed
- --enable-bss-mixing
Enable mixing BSS/NonBSS sections
- --use-mov-veneer
Use movt/movw to load address in veneers with absolute relocation
9.2.2. ARM Linker Option ONLY
- -execute-only, --execute-only
Mark executable sections execute-only on AArch64
- -fix-cortex-a53-843419, --fix-cortex-a53-843419
Fix the cortex a53 errata 843419
- --fix-cortex-a8
Fix the Cortex A8 bug
- -fropi, --fropi
Enable Read write data access relative to a static base registers.
- -frwpi, --frwpi
Enable Read write data access relative to a static base registers.
- --no-fix-cortex-a8
Dont Fix the Cortex A8 bug
9.3. Hexagon specific options
9.4. RISCV specific options
9.4.1. Symbol Patching
- --patch-base <value>
Specify base image to generate patch for
- --patch-enable
Enable symbol patching using indirection
9.4.2. RISCV Linker Options
- --disable-bss-conversion
Don’t convert BSS to NonBSS when BSS/NonBSS Sections are mixed
- --enable-bss-mixing
Enable mixing BSS/NonBSS sections
- --keep-labels
Keep all local labels for debugging purposes
- --no-relax-gp
Disable GP relaxation
- --no-relax
Disable relaxation
- --no-relax-c
Disable relaxation to compressed instructions
- --relax
Enable relaxation (default behavior)