diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /lld/docs | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'lld/docs')
-rw-r--r-- | lld/docs/AtomLLD.rst | 2 | ||||
-rw-r--r-- | lld/docs/ELF/linker_script.rst | 77 | ||||
-rw-r--r-- | lld/docs/NewLLD.rst | 2 | ||||
-rw-r--r-- | lld/docs/ReleaseNotes.rst | 27 | ||||
-rw-r--r-- | lld/docs/WebAssembly.rst | 15 | ||||
-rw-r--r-- | lld/docs/conf.py | 4 | ||||
-rw-r--r-- | lld/docs/design.rst | 2 | ||||
-rw-r--r-- | lld/docs/development.rst | 2 | ||||
-rw-r--r-- | lld/docs/getting_started.rst | 4 | ||||
-rw-r--r-- | lld/docs/index.rst | 11 | ||||
-rw-r--r-- | lld/docs/ld.lld.1 | 60 |
11 files changed, 170 insertions, 36 deletions
diff --git a/lld/docs/AtomLLD.rst b/lld/docs/AtomLLD.rst index 614e568d1997..2766094696e0 100644 --- a/lld/docs/AtomLLD.rst +++ b/lld/docs/AtomLLD.rst @@ -59,4 +59,4 @@ Indices and tables * :ref:`genindex` * :ref:`search` -__ http://llvm.org/docs/DeveloperPolicy.html#license +__ https://llvm.org/docs/DeveloperPolicy.html#license diff --git a/lld/docs/ELF/linker_script.rst b/lld/docs/ELF/linker_script.rst new file mode 100644 index 000000000000..0f409b2020ac --- /dev/null +++ b/lld/docs/ELF/linker_script.rst @@ -0,0 +1,77 @@ +Linker Script implementation notes and policy +============================================= + +LLD implements a large subset of the GNU ld linker script notation. The LLD +implementation policy is to implement linker script features as they are +documented in the ld `manual <https://sourceware.org/binutils/docs/ld/Scripts.html>`_ +We consider it a bug if the lld implementation does not agree with the manual +and it is not mentioned in the exceptions below. + +The ld manual is not a complete specification, and is not sufficient to build +an implementation. In particular some features are only defined by the +implementation and have changed over time. + +The lld implementation policy for properties of linker scripts that are not +defined by the documentation is to follow the GNU ld implementation wherever +possible. We reserve the right to make different implementation choices where +it is appropriate for LLD. Intentional deviations will be documented in this +file. + +Output section description +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The description of an output section looks like: + +:: + + section [address] [(type)] : [AT(lma)] [ALIGN(section_align)] [SUBALIGN](subsection_align)] { + output-section-command + ... + } [>region] [AT>lma_region] [:phdr ...] [=fillexp] [,] + +Output section address +---------------------- + +When an *OutputSection* *S* has ``address``, LLD will set sh_addr to ``address``. + +The ELF specification says: + +> The value of sh_addr must be congruent to 0, modulo the value of sh_addralign. + +The presence of ``address`` can cause the condition unsatisfied. LLD will warn. +GNU ld from Binutils 2.35 onwards will reduce sh_addralign so that +sh_addr=0 (modulo sh_addralign). + +Output section alignment +------------------------ + +sh_addralign of an *OutputSection* *S* is the maximum of +``ALIGN(section_align)`` and the maximum alignment of the input sections in +*S*. + +When an *OutputSection* *S* has both ``address`` and ``ALIGN(section_align)``, +GNU ld will set sh_addralign to ``ALIGN(section_align)``. + +Output section LMA +------------------ + +A load address (LMA) can be specified by ``AT(lma)`` or ``AT>lma_region``. + +- ``AT(lma)`` specifies the exact load address. If the linker script does not + have a PHDRS command, then a new loadable segment will be generated. +- ``AT>lma_region`` specifies the LMA region. The lack of ``AT>lma_region`` + means the default region is used. Note, GNU ld propagates the previous LMA + memory region when ``address`` is not specified. The LMA is set to the + current location of the memory region aligned to the section alignment. + If the linker script does not have a PHDRS command, then if + ``lma_region`` is different from the ``lma_region`` for + the previous OutputSection a new loadable segment will be generated. + +The two keywords cannot be specified at the same time. + +If neither ``AT(lma)`` nor ``AT>lma_region`` is specified: + +- If the previous section is also in the default LMA region, and the two + section have the same memory regions, the difference between the LMA and the + VMA is computed to be the same as the previous difference. +- Otherwise, the LMA is set to the VMA. diff --git a/lld/docs/NewLLD.rst b/lld/docs/NewLLD.rst index 59a8f87ea86a..1b1c87067f51 100644 --- a/lld/docs/NewLLD.rst +++ b/lld/docs/NewLLD.rst @@ -248,7 +248,7 @@ Finally, the linker replaces bitcode symbols with ELF/COFF symbols, so that they are linked as if they were in the native format from the beginning. The details are described in this document. -http://llvm.org/docs/LinkTimeOptimization.html +https://llvm.org/docs/LinkTimeOptimization.html Glossary -------- diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst index bc16417646c3..fe3de8306cd8 100644 --- a/lld/docs/ReleaseNotes.rst +++ b/lld/docs/ReleaseNotes.rst @@ -1,19 +1,19 @@ ======================== -lld 10.0.0 Release Notes +lld 11.0.0 Release Notes ======================== .. contents:: :local: .. warning:: - These are in-progress notes for the upcoming LLVM 10.0.0 release. + These are in-progress notes for the upcoming LLVM 11.0.0 release. Release notes for previous releases can be found on `the Download Page <https://releases.llvm.org/download.html>`_. Introduction ============ -This document contains the release notes for the lld linker, release 10.0.0. +This document contains the release notes for the lld linker, release 11.0.0. Here we describe the status of lld, including major improvements from the previous release. All lld releases may be downloaded from the `LLVM releases web site <https://llvm.org/releases/>`_. @@ -24,11 +24,18 @@ Non-comprehensive list of changes in this release ELF Improvements ---------------- -* Glob pattern, which you can use in linker scripts or version scripts, - now supports `\` and `[!...]`. Except character classes - (e.g. `[[:digit:]]`), lld's glob pattern should be fully compatible - with GNU now. (`r375051 - <https://github.com/llvm/llvm-project/commit/48993d5ab9413f0e5b94dfa292a233ce55b09e3e>`_) +* New ``--time-trace`` option records a time trace file that can be viewed in + chrome://tracing. The file can be specified with ``--time-trace-file``. + Trace granularity can be specified with ``--time-trace-granularity``. + (`D71060 <https://reviews.llvm.org/D71060>`_) +* ... + +Breaking changes +---------------- + +* One-dash form of some long option (``--thinlto-*``, ``--lto-*``, ``--shuffle-sections=``) + are no longer supported. +* ``--export-dynamic-symbol`` no longer implies ``-u``. COFF Improvements ----------------- @@ -48,7 +55,3 @@ MachO Improvements WebAssembly Improvements ------------------------ -* `__data_end` and `__heap_base` are no longer exported by default, - as it's best to keep them internal when possible. They can be - explicitly exported with `--export=__data_end` and - `--export=__heap_base`, respectively. diff --git a/lld/docs/WebAssembly.rst b/lld/docs/WebAssembly.rst index 1b01cab5c253..b23f2cd462b4 100644 --- a/lld/docs/WebAssembly.rst +++ b/lld/docs/WebAssembly.rst @@ -112,8 +112,8 @@ The default behaviour is to generate these stub function and to produce a warning. The ``--fatal-warnings`` flag can be used to disable this behaviour and error out if mismatched are found. -Imports and Exports -~~~~~~~~~~~~~~~~~~~ +Exports +~~~~~~~ When building a shared library any symbols marked as ``visibility=default`` will be exported. @@ -130,6 +130,17 @@ Finally, just like with native ELF linker the ``--export-dynamic`` flag can be used to export symbols in the executable which are marked as ``visibility=default``. +Imports +~~~~~~~ + +By default no undefined symbols are allowed in the final binary. The flag +``--allow-undefined`` results in a WebAssembly import being defined for each +undefined symbol. It is then up to the runtime to provide such symbols. + +Alternatively symbols can be marked in the source code as with the +``import_name`` and/or ``import_module`` clang attributes which signals that +they are expected to be undefined at static link time. + Garbage Collection ~~~~~~~~~~~~~~~~~~ diff --git a/lld/docs/conf.py b/lld/docs/conf.py index 0f03b1275a7c..7d4fc0c5ad75 100644 --- a/lld/docs/conf.py +++ b/lld/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'2011-%d, LLVM Project' % date.today().year # built documents. # # The short version. -version = '10' +version = '11' # The full version, including alpha/beta/rc tags. -release = '10' +release = '11' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/lld/docs/design.rst b/lld/docs/design.rst index 1e111f979bb5..20d8fe78a641 100644 --- a/lld/docs/design.rst +++ b/lld/docs/design.rst @@ -326,7 +326,7 @@ Testing The lld project contains a test suite which is being built up as new code is added to lld. All new lld functionality should have a tests added to the test -suite. The test suite is `lit <http://llvm.org/cmds/lit.html/>`_ driven. Each +suite. The test suite is `lit <https://llvm.org/cmds/lit.html/>`_ driven. Each test is a text file with comments telling lit how to run the test and check the result To facilitate testing, the lld project builds a tool called lld-core. This tool reads a YAML file (default from stdin), parses it into one or more diff --git a/lld/docs/development.rst b/lld/docs/development.rst index ce91341d665f..81b826f64835 100644 --- a/lld/docs/development.rst +++ b/lld/docs/development.rst @@ -6,7 +6,7 @@ Development Note: this document discuss Mach-O port of LLD. For ELF and COFF, see :doc:`index`. -lld is developed as part of the `LLVM <http://llvm.org>`_ project. +lld is developed as part of the `LLVM <https://llvm.org>`_ project. Creating a Reader ----------------- diff --git a/lld/docs/getting_started.rst b/lld/docs/getting_started.rst index a174f652e736..506cb24dde84 100644 --- a/lld/docs/getting_started.rst +++ b/lld/docs/getting_started.rst @@ -6,7 +6,7 @@ Getting Started: Building and Running lld This page gives you the shortest path to checking out and building lld. If you run into problems, please file bugs in the `LLVM Bugzilla`__ -__ http://llvm.org/bugs/ +__ https://bugs.llvm.org/ Building lld ------------ @@ -84,4 +84,4 @@ More Information For more information on using CMake see the `LLVM CMake guide`_. -.. _LLVM CMake guide: http://llvm.org/docs/CMake.html +.. _LLVM CMake guide: https://llvm.org/docs/CMake.html diff --git a/lld/docs/index.rst b/lld/docs/index.rst index 68604c27f95a..b820d57e3d35 100644 --- a/lld/docs/index.rst +++ b/lld/docs/index.rst @@ -33,10 +33,10 @@ Features machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your mileage may vary, though. -- It supports various CPUs/ABIs including x86-64, x86, x32, AArch64, - ARM, MIPS 32/64 big/little-endian, PowerPC, PowerPC 64 and AMDGPU. - Among these, x86-64, AArch64, and ARM (>= v6) are production quality. - MIPS seems decent too. x86 should be OK but is not well tested yet. +- It supports various CPUs/ABIs including AArch64, AMDGPU, ARM, Hexagon, MIPS + 32/64 big/little-endian, PowerPC, PowerPC64, RISC-V, SPARC V9, x86-32 and + x86-64. Among these, AArch64, ARM (>= v6), PowerPC, PowerPC64, x86-32 and + x86-64 have production quality. MIPS seems decent too. - It is always a cross-linker, meaning that it always supports all the above targets however it was built. In fact, we don't provide a @@ -98,7 +98,7 @@ Build If you have already checked out LLVM using SVN, you can check out LLD under ``tools`` directory just like you probably did for clang. For the details, see `Getting Started with the LLVM System -<http://llvm.org/docs/GettingStarted.html>`_. +<https://llvm.org/docs/GettingStarted.html>`_. If you haven't checked out LLVM, the easiest way to build LLD is to check out the entire LLVM projects/sub-projects from a git mirror and @@ -176,3 +176,4 @@ document soon. missingkeyfunction Partitions ReleaseNotes + ELF/linker_script diff --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1 index 92d67b17e24e..5edeaf85f93f 100644 --- a/lld/docs/ld.lld.1 +++ b/lld/docs/ld.lld.1 @@ -157,6 +157,10 @@ This is recorded in an ELF segment of type .It Fl -dynamic-list Ns = Ns Ar file Read a list of dynamic symbols from .Ar file . +(executable) Put matched non-local defined symbols to the dynamic symbol table. +(shared object) References to matched non-local STV_DEFAULT symbols shouldn't be bound to definitions within the shared object. Implies +.Cm -Bsymbolic +but does not set DF_SYMBOLIC .It Fl -eh-frame-hdr Request creation of .Li .eh_frame_hdr @@ -184,10 +188,14 @@ This option is currently only supported on AArch64. Exclude static libraries from automatic export. .It Fl -export-dynamic , Fl E Put symbols in the dynamic symbol table. -.It Fl -export-dynamic-symbol Ns = Ns Ar symbol -Include -.Ar symbol -in the dynamic symbol table. +.It Fl -export-dynamic-symbol Ns = Ns Ar glob +(executable) Put matched non-local defined symbols to the dynamic symbol table. +(shared object) References to matched non-local STV_DEFAULT symbols shouldn't be bound to definitions within the shared object even if they would otherwise be due to +.Cm -Bsymbolic +, +.Cm -Bsymbolic-functions +or +.Cm --dynamic-list .It Fl -fatal-warnings Treat warnings as errors. .It Fl -filter Ns = Ns Ar value , Fl F Ar value @@ -300,10 +308,10 @@ Disable merging .ARM.exidx entries. Page align sections. .It Fl -no-omagic Do not set the text data sections to be writable, page align sections. +.It Fl -no-relax +Disable target-specific relaxations. This is currently a no-op. .It Fl -no-rosegment Do not put read-only non-executable sections in their own segment. -.It Fl -no-threads -Do not run the linker multi-threaded. .It Fl -no-undefined-version Report version scripts that refer undefined symbols. .It Fl -no-undefined @@ -416,6 +424,9 @@ List removed unused sections. List identical folded sections. .It Fl -print-map Print a link map to the standard output. +.It Fl -print-archive-stats Ns = Ns Ar file +Write archive usage statistics to the specified file. +Print the numbers of members and fetched members for each archive. .It Fl -push-state Save the current state of .Fl -as-needed , @@ -456,6 +467,8 @@ were concatenated in the order they appeared on the command line. Set address of section. .It Fl -shared , Fl -Bsharable Build a shared object. +.It Fl -shuffle-sections Ns = Ns Ar seed +Shuffle input sections using the given seed. If 0, use a random seed. .It Fl -soname Ns = Ns Ar value , Fl h Ar value Set .Dv DT_SONAME @@ -523,9 +536,19 @@ Path to ThinLTO cached object file directory. Pruning policy for the ThinLTO cache. .It Fl -thinlto-jobs Ns = Ns Ar value Number of ThinLTO jobs. -.It Fl -threads -Run the linker multi-threaded. -This option is enabled by default. +.It Fl -threads Ns = Ns Ar N +Number of threads. +.Cm all +(default) means all of concurrent threads supported. +.Cm 1 +disables multi-threading. +.It Fl -time-trace +Record time trace. +.It Fl -time-trace-file Ns = Ns Ar file +Write time trace output to +.Ar file . +.It Fl -time-trace-granularity Ns = Ns Ar value +Minimum time granularity (in microseconds) traced by time profiler. .It Fl -trace Print the names of the input files. .It Fl -trace-symbol Ns = Ns Ar symbol , Fl y Ar symbol @@ -551,6 +574,8 @@ matches the characters within brackets. All symbols that match a given pattern are handled as if they were given as arguments of .Fl -undefined . +.It Fl -unique +Creates a separate output section for every orphan input section. .It Fl -unresolved-symbols Ns = Ns Ar value Determine how to handle unresolved symbols. .It Fl -use-android-relr-tags @@ -569,6 +594,10 @@ Read version script from Warn about reverse or cyclic dependencies to or between static archives. This can be used to ensure linker invocation remains compatible with traditional Unix-like linkers. +.It Fl -warn-backrefs-exclude Ns = Ns Ar glob +Glob describing an archive (or an object file within --start-lib) +which should be ignored for +.Fl -warn-backrefs .It Fl -warn-common Warn about duplicate common symbols. .It Fl -warn-ifunc-textrel @@ -596,6 +625,13 @@ Use wrapper functions for symbol. Linker option extensions. .Bl -tag -width indent -compact .Pp +.It Cm dead-reloc-in-nonalloc Ns = Ns Ar section_glob=value +Resolve a relocation in a matched non-SHF_ALLOC section referencing a discarded symbol to +.Ar value +Accepts globs, in the event of a section matching more than one option, the last +option takes precedence. An order of least specific to most specific match is +recommended. +.Pp .It Cm execstack Make the main stack executable. Stack permissions are recorded in the @@ -701,6 +737,12 @@ processing. .It Cm pac-plt AArch64 only, use pointer authentication in PLT. .Pp +.It Cm rel +Use REL format for dynamic relocations. +.Pp +.It Cm rela +Use RELA format for dynamic relocations. +.Pp .It Cm retpolineplt Emit retpoline format PLT entries as a mitigation for CVE-2017-5715. .Pp |