2015-07-25 05:03:07 +08:00
|
|
|
include "llvm/Option/OptParser.td"
|
|
|
|
|
2015-10-14 05:02:34 +08:00
|
|
|
def Bsymbolic: Flag<["-"], "Bsymbolic">,
|
|
|
|
HelpText<"Bind defined symbols locally">;
|
|
|
|
|
2016-02-02 17:28:53 +08:00
|
|
|
def Bsymbolic_functions: Flag<["-"], "Bsymbolic-functions">,
|
|
|
|
HelpText<"Bind defined function symbols locally">;
|
|
|
|
|
2015-10-02 00:42:03 +08:00
|
|
|
def Bdynamic: Flag<["-"], "Bdynamic">,
|
|
|
|
HelpText<"Link against shared libraries">;
|
|
|
|
|
|
|
|
def Bstatic: Flag<["-"], "Bstatic">,
|
|
|
|
HelpText<"Do not link against shared libraries">;
|
|
|
|
|
ELF: Implement --build-id.
This patch implements --build-id. After the linker creates an output file
in the memory buffer, it computes the FNV1 hash of the resulting file
and set the hash to the .note section as a build-id.
GNU ld and gold have the same feature, but their default choice of the
hash function is different. Their default is SHA1.
We made a deliberate choice to not use a secure hash function for the
sake of performance. Computing a secure hash is slow -- for example,
MD5 throughput is usually 400 MB/s or so. SHA1 is slower than that.
As a result, if you pass --build-id to gold, then the linker becomes about
10% slower than that without the option. We observed a similar degradation
in an experimental implementation of build-id for LLD. On the other hand,
we observed only 1-2% performance degradation with the FNV hash.
Since build-id is not for digital certificate or anything, we think that
a very small probability of collision is acceptable.
We considered using other signals such as using input file timestamps as
inputs to a secure hash function. But such signals would have an issue
with build reproducibility (if you build a binary from the same source
tree using the same toolchain, the build id should become the same.)
GNU linkers accepts --build-id=<style> option where style is one of
"MD5", "SHA1", or an arbitrary hex string. That option is out of scope
of this patch.
http://reviews.llvm.org/D18091
llvm-svn: 263292
2016-03-12 04:51:53 +08:00
|
|
|
def build_id : Flag<["--", "-"], "build-id">,
|
|
|
|
HelpText<"Generate build ID note">;
|
|
|
|
|
2015-10-27 23:10:53 +08:00
|
|
|
def L : JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Directory to search for libraries">;
|
2015-09-12 06:42:45 +08:00
|
|
|
|
2015-10-24 03:02:19 +08:00
|
|
|
def O : Joined<["-"], "O">, HelpText<"Optimize">;
|
|
|
|
|
2015-10-01 08:33:02 +08:00
|
|
|
def allow_multiple_definition: Flag<["--"], "allow-multiple-definition">,
|
|
|
|
HelpText<"Allow multiple definitions">;
|
2015-09-17 04:45:57 +08:00
|
|
|
|
2015-10-02 22:21:24 +08:00
|
|
|
def allow_shlib_undefined : Flag<["--", "-"], "allow-shlib-undefined">;
|
2015-10-02 01:33:38 +08:00
|
|
|
|
2015-10-12 04:59:12 +08:00
|
|
|
def as_needed : Flag<["--"], "as-needed">;
|
|
|
|
|
2015-10-07 00:20:00 +08:00
|
|
|
def disable_new_dtags : Flag<["--"], "disable-new-dtags">,
|
|
|
|
HelpText<"Disable new dynamic tags">;
|
|
|
|
|
2015-09-17 04:45:57 +08:00
|
|
|
def discard_all : Flag<["-"], "discard-all">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Delete all local symbols">;
|
2015-09-21 07:35:56 +08:00
|
|
|
|
2015-09-21 05:58:12 +08:00
|
|
|
def discard_locals : Flag<["-"], "discard-locals">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Delete temporary local symbols">;
|
2015-09-21 07:35:56 +08:00
|
|
|
|
2015-10-01 08:33:02 +08:00
|
|
|
def discard_none : Flag<["-"], "discard-none">,
|
|
|
|
HelpText<"Keep all symbols in the symbol table">;
|
2015-09-23 07:38:23 +08:00
|
|
|
|
2015-10-03 17:32:48 +08:00
|
|
|
def dynamic_linker : Separate<["--", "-"], "dynamic-linker">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Which dynamic linker to use">;
|
2015-09-26 03:24:57 +08:00
|
|
|
|
2016-01-15 21:34:52 +08:00
|
|
|
def eh_frame_hdr : Flag<["--"], "eh-frame-hdr">,
|
|
|
|
HelpText<"Request creation of .eh_frame_hdr section and PT_GNU_EH_FRAME segment header">;
|
|
|
|
|
2015-10-07 00:20:00 +08:00
|
|
|
def enable_new_dtags : Flag<["--"], "enable-new-dtags">,
|
|
|
|
HelpText<"Enable new dynamic tags">;
|
|
|
|
|
2015-10-01 08:33:02 +08:00
|
|
|
def entry : Separate<["--", "-"], "entry">, MetaVarName<"<entry>">,
|
|
|
|
HelpText<"Name of entry point symbol">;
|
2015-09-24 23:08:23 +08:00
|
|
|
|
2015-10-02 22:21:24 +08:00
|
|
|
def export_dynamic : Flag<["--", "-"], "export-dynamic">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Put symbols in the dynamic symbol table">;
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2015-10-05 18:29:46 +08:00
|
|
|
def fini : Separate<["-"], "fini">, MetaVarName<"<symbol>">,
|
|
|
|
HelpText<"Specify a finalizer function">;
|
|
|
|
|
2015-10-22 16:21:35 +08:00
|
|
|
def hash_style : Separate<["--", "-"], "hash-style">,
|
|
|
|
HelpText<"Specify hash style (sysv, gnu or both)">;
|
|
|
|
|
2016-02-28 11:18:09 +08:00
|
|
|
def help : Flag<["--", "-"], "help">,
|
|
|
|
HelpText<"Print option help">;
|
|
|
|
|
2016-02-26 02:43:51 +08:00
|
|
|
def icf : Flag<["--"], "icf=all">,
|
2016-03-02 06:17:09 +08:00
|
|
|
HelpText<"Enable identical code folding">;
|
2016-02-26 02:43:51 +08:00
|
|
|
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
def gc_sections : Flag<["--"], "gc-sections">,
|
|
|
|
HelpText<"Enable garbage collection of unused sections">;
|
|
|
|
|
2015-10-06 20:08:08 +08:00
|
|
|
def init : Separate<["-"], "init">, MetaVarName<"<symbol>">,
|
2015-10-05 18:29:46 +08:00
|
|
|
HelpText<"Specify an initializer function">;
|
|
|
|
|
2015-10-20 18:03:14 +08:00
|
|
|
def l : JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Root name of library to use">;
|
2015-09-29 04:30:11 +08:00
|
|
|
|
2015-10-28 13:13:12 +08:00
|
|
|
def m : JoinedOrSeparate<["-"], "m">,
|
2015-10-07 17:13:03 +08:00
|
|
|
HelpText<"Set target emulation">;
|
|
|
|
|
2015-10-02 01:33:38 +08:00
|
|
|
def no_allow_shlib_undefined : Flag<["--"], "no-allow-shlib-undefined">;
|
|
|
|
|
2015-10-12 04:59:12 +08:00
|
|
|
def no_as_needed : Flag<["--"], "no-as-needed">;
|
|
|
|
|
2016-01-14 02:55:39 +08:00
|
|
|
def no_demangle: Flag<["--"], "no-demangle">,
|
2016-03-02 06:17:09 +08:00
|
|
|
HelpText<"Do not demangle symbol names">;
|
2016-01-14 02:55:39 +08:00
|
|
|
|
2015-11-19 01:22:02 +08:00
|
|
|
def no_whole_archive : Flag<["--", "-"], "no-whole-archive">,
|
2015-10-02 02:02:21 +08:00
|
|
|
HelpText<"Restores the default behavior of loading archive members">;
|
|
|
|
|
2015-10-01 08:33:02 +08:00
|
|
|
def noinhibit_exec : Flag<["--"], "noinhibit-exec">,
|
|
|
|
HelpText<"Retain the executable output file whenever it is still usable">;
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2015-10-02 04:14:45 +08:00
|
|
|
def no_undefined : Flag<["--"], "no-undefined">,
|
|
|
|
HelpText<"Report unresolved symbols even if the linker is creating a shared library">;
|
|
|
|
|
2016-03-03 08:09:02 +08:00
|
|
|
def o : JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Path to file to write output">;
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2016-03-17 13:57:33 +08:00
|
|
|
def pie : Flag<["-"], "pie">,
|
|
|
|
HelpText<"Create a position independent executable">;
|
|
|
|
|
2015-12-10 17:12:18 +08:00
|
|
|
def print_gc_sections: Flag<["--"], "print-gc-sections">,
|
|
|
|
HelpText<"List removed unused sections">;
|
|
|
|
|
2015-10-01 08:33:02 +08:00
|
|
|
def rpath : Separate<["-"], "rpath">,
|
|
|
|
HelpText<"Add a DT_RUNPATH to the output">;
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2016-02-25 16:23:37 +08:00
|
|
|
def relocatable : Flag<["--"], "relocatable">,
|
|
|
|
HelpText<"Create relocatable object file">;
|
2015-11-13 02:54:15 +08:00
|
|
|
|
2016-03-03 08:09:02 +08:00
|
|
|
def script : Separate<["--"], "script">,
|
|
|
|
HelpText<"Read linker script">;
|
2015-10-11 11:53:36 +08:00
|
|
|
|
2015-10-01 08:33:02 +08:00
|
|
|
def shared : Flag<["-"], "shared">,
|
|
|
|
HelpText<"Build a shared object">;
|
2015-09-28 23:01:59 +08:00
|
|
|
|
2015-10-02 03:36:04 +08:00
|
|
|
def soname : Joined<["-"], "soname=">,
|
|
|
|
HelpText<"Set DT_SONAME">;
|
|
|
|
|
2015-10-24 16:52:46 +08:00
|
|
|
def strip_all : Flag<["--"], "strip-all">,
|
|
|
|
HelpText<"Strip all symbols">;
|
|
|
|
|
2015-09-28 23:01:59 +08:00
|
|
|
def sysroot : Joined<["--"], "sysroot=">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Set the system root">;
|
|
|
|
|
2016-03-11 12:23:12 +08:00
|
|
|
def threads : Joined<["--"], "threads">;
|
|
|
|
|
2015-10-05 17:43:57 +08:00
|
|
|
def undefined : Joined<["--"], "undefined=">,
|
|
|
|
HelpText<"Force undefined symbol during linking">;
|
|
|
|
|
2015-10-11 10:03:03 +08:00
|
|
|
def verbose : Flag<["--"], "verbose">;
|
|
|
|
|
2016-02-28 11:18:07 +08:00
|
|
|
def version : Flag<["--", "-"], "version">,
|
|
|
|
HelpText<"Display the version number">;
|
|
|
|
|
2016-03-14 17:19:30 +08:00
|
|
|
def warn_common : Flag<["--", "-"], "warn-common">,
|
|
|
|
HelpText<"Warn about duplicate common symbols">;
|
|
|
|
|
2015-11-19 01:22:02 +08:00
|
|
|
def whole_archive : Flag<["--", "-"], "whole-archive">,
|
2015-10-02 02:02:21 +08:00
|
|
|
HelpText<"Force load of all members in a static library">;
|
|
|
|
|
2016-01-08 01:20:07 +08:00
|
|
|
def wrap : Separate<["--", "-"], "wrap">, MetaVarName<"<symbol>">,
|
|
|
|
HelpText<"Use wrapper functions for symbol">;
|
|
|
|
|
2015-10-07 23:00:21 +08:00
|
|
|
def z : JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
|
|
|
|
HelpText<"Linker option extensions">;
|
|
|
|
|
2015-10-01 08:33:02 +08:00
|
|
|
// Aliases
|
2015-10-02 00:42:03 +08:00
|
|
|
def alias_Bdynamic_call_shared: Flag<["-"], "call_shared">, Alias<Bdynamic>;
|
|
|
|
def alias_Bdynamic_dy: Flag<["-"], "dy">, Alias<Bdynamic>;
|
|
|
|
def alias_Bstatic_dn: Flag<["-"], "dn">, Alias<Bstatic>;
|
|
|
|
def alias_Bstatic_non_shared: Flag<["-"], "non_shared">, Alias<Bstatic>;
|
|
|
|
def alias_Bstatic_static: Flag<["-"], "static">, Alias<Bstatic>;
|
2015-10-03 05:01:59 +08:00
|
|
|
def alias_L__library_path : Joined<["--"], "library-path=">, Alias<L>;
|
|
|
|
def alias_discard_all_x: Flag<["-"], "x">, Alias<discard_all>;
|
|
|
|
def alias_discard_locals_X: Flag<["-"], "X">, Alias<discard_locals>;
|
2016-03-03 08:09:02 +08:00
|
|
|
def alias_entry_e : JoinedOrSeparate<["-"], "e">, Alias<entry>;
|
2015-11-21 05:22:53 +08:00
|
|
|
def alias_export_dynamic_E: Flag<["-"], "E">, Alias<export_dynamic>;
|
2015-10-05 18:29:46 +08:00
|
|
|
def alias_fini_fini : Joined<["-"], "fini=">, Alias<fini>;
|
2015-10-22 16:21:35 +08:00
|
|
|
def alias_hash_style_hash_style : Joined<["--", "-"], "hash-style=">, Alias<hash_style>;
|
2015-10-05 18:29:46 +08:00
|
|
|
def alias_init_init : Joined<["-"], "init=">, Alias<init>;
|
2015-10-03 05:01:59 +08:00
|
|
|
def alias_l__library : Joined<["--"], "library=">, Alias<l>;
|
2015-10-09 08:33:44 +08:00
|
|
|
def alias_o_output : Joined<["--"], "output=">, Alias<o>;
|
2016-03-17 13:57:33 +08:00
|
|
|
def alias_pie_pic_executable: Flag<["--"], "pic-executable">, Alias<pie>;
|
2015-10-03 14:54:24 +08:00
|
|
|
def alias_rpath_rpath : Joined<["-"], "rpath=">, Alias<rpath>;
|
2015-11-13 02:54:15 +08:00
|
|
|
def alias_relocatable_r : Flag<["-"], "r">, Alias<relocatable>;
|
2015-10-15 21:03:16 +08:00
|
|
|
def alias_shared_Bshareable : Flag<["-"], "Bshareable">, Alias<shared>;
|
2016-03-03 08:09:02 +08:00
|
|
|
def alias_soname_h : JoinedOrSeparate<["-"], "h">, Alias<soname>;
|
2015-10-03 05:01:59 +08:00
|
|
|
def alias_soname_soname : Separate<["-"], "soname">, Alias<soname>;
|
2016-03-03 08:09:02 +08:00
|
|
|
def alias_script_T : JoinedOrSeparate<["-"], "T">, Alias<script>;
|
2015-10-24 16:52:46 +08:00
|
|
|
def alias_strip_all: Flag<["-"], "s">, Alias<strip_all>;
|
2016-03-03 08:09:02 +08:00
|
|
|
def alias_undefined_u : JoinedOrSeparate<["-"], "u">, Alias<undefined>;
|
2016-01-08 01:20:07 +08:00
|
|
|
def alias_wrap_wrap : Joined<["--", "-"], "wrap=">, Alias<wrap>;
|
2015-10-01 08:24:54 +08:00
|
|
|
|
2015-11-14 02:56:07 +08:00
|
|
|
// Our symbol resolution algorithm handles symbols in archive files differently
|
2015-11-13 08:26:12 +08:00
|
|
|
// than traditional linkers, so we don't need --start-group and --end-group.
|
2015-11-14 02:56:07 +08:00
|
|
|
// These options are recongized for compatibility but ignored.
|
2015-10-02 06:54:37 +08:00
|
|
|
def end_group : Flag<["--"], "end-group">;
|
2015-10-27 03:05:44 +08:00
|
|
|
def end_group_paren: Flag<["-"], ")">;
|
2015-11-13 08:26:12 +08:00
|
|
|
def start_group : Flag<["--"], "start-group">;
|
|
|
|
def start_group_paren: Flag<["-"], "(">;
|
|
|
|
|
|
|
|
// Options listed below are silently ignored for now for compatibility.
|
2015-10-20 05:01:32 +08:00
|
|
|
def fatal_warnings : Flag<["--"], "fatal-warnings">;
|
2015-10-02 06:31:38 +08:00
|
|
|
def no_add_needed : Flag<["--"], "no-add-needed">;
|
2015-10-02 23:29:31 +08:00
|
|
|
def no_fatal_warnings : Flag<["--"], "no-fatal-warnings">;
|
2016-03-14 17:19:30 +08:00
|
|
|
def no_warn_common : Flag<["--", "-"], "no-warn-common">;
|
2015-10-20 05:01:32 +08:00
|
|
|
def no_warn_mismatch : Flag<["--"], "no-warn-mismatch">;
|
2015-10-03 00:20:39 +08:00
|
|
|
def version_script : Separate<["--"], "version-script">;
|
2015-10-20 05:01:32 +08:00
|
|
|
def warn_shared_textrel : Flag<["--"], "warn-shared-textrel">;
|
2015-10-28 22:50:58 +08:00
|
|
|
def G : Separate<["-"], "G">;
|
2015-12-10 22:08:45 +08:00
|
|
|
|
|
|
|
// Aliases for ignored options
|
|
|
|
def alias_version_script_version_script : Joined<["--"], "version-script=">, Alias<version_script>;
|
2016-03-10 04:01:08 +08:00
|
|
|
|
|
|
|
// Debugging options
|
|
|
|
def save_temps : Flag<["-"], "save-temps">;
|