| author | |
| committer | |
| log | a33b689f2c3ea568ceaa2bf054020f4c318c9355 |
| tree | e99bc27cfa48f5620bf441c6e6d43bee77abff62 |
| parent | 9cfd7dea19c4c54e2754119c04c06cd57cfb759d |
9 files changed, 133 insertions(+), 40 deletions(-)
deps/lld-prebuilt/ELF/Options.inc+2-2| ... | ... | @@ -230,8 +230,6 @@ OPTION(prefix_2, "no-merge-exidx-entries", no_merge_exidx_entries, Flag, INVALID |
| 230 | 230 | OPTION(prefix_2, "no-mmap-output-file", no_mmap_output_file, Flag, INVALID, INVALID, nullptr, 0, 0, nullptr, nullptr, nullptr) |
| 231 | 231 | OPTION(prefix_3, "no-omagic", no_omagic, Flag, INVALID, INVALID, nullptr, 0, 0, |
| 232 | 232 | "Do not set the text data sections to be writable", "<magic>", nullptr) |
| 233 | OPTION(prefix_2, "no-pie", no_pie, Flag, INVALID, INVALID, nullptr, 0, 0, | |
| 234 | "Do not create a position independent executable", nullptr, nullptr) | |
| 235 | 233 | OPTION(prefix_2, "no-print-gc-sections", no_print_gc_sections, Flag, INVALID, INVALID, nullptr, 0, 0, |
| 236 | 234 | "Do not list removed unused sections", nullptr, nullptr) |
| 237 | 235 | OPTION(prefix_2, "no-rosegment", no_rosegment, Flag, INVALID, INVALID, nullptr, 0, 0, |
| ... | ... | @@ -249,6 +247,8 @@ OPTION(prefix_2, "no-whole-archive", no_whole_archive, Flag, INVALID, INVALID, n |
| 249 | 247 | OPTION(prefix_2, "noinhibit-exec", noinhibit_exec, Flag, INVALID, INVALID, nullptr, 0, 0, |
| 250 | 248 | "Retain the executable output file whenever it is still usable", nullptr, nullptr) |
| 251 | 249 | OPTION(prefix_2, "non_shared", alias_Bstatic_non_shared, Flag, INVALID, Bstatic, nullptr, 0, 0, nullptr, nullptr, nullptr) |
| 250 | OPTION(prefix_2, "nopie", nopie, Flag, INVALID, INVALID, nullptr, 0, 0, | |
| 251 | "Do not create a position independent executable", nullptr, nullptr) | |
| 252 | 252 | OPTION(prefix_2, "nostdlib", nostdlib, Flag, INVALID, INVALID, nullptr, 0, 0, |
| 253 | 253 | "Only search directories specified on the command line", nullptr, nullptr) |
| 254 | 254 | OPTION(prefix_1, "N", alias_omagic, Flag, INVALID, omagic, nullptr, 0, 0, nullptr, nullptr, nullptr) |
deps/lld/COFF/PDB.cpp+40-15| ... | ... | @@ -96,10 +96,11 @@ public: |
| 96 | 96 | /// If the object does not use a type server PDB (compiled with /Z7), we merge |
| 97 | 97 | /// all the type and item records from the .debug$S stream and fill in the |
| 98 | 98 | /// caller-provided ObjectIndexMap. |
| 99 | const CVIndexMap &mergeDebugT(ObjFile *File, CVIndexMap &ObjectIndexMap); | |
| 99 | Expected<const CVIndexMap&> mergeDebugT(ObjFile *File, | |
| 100 | CVIndexMap &ObjectIndexMap); | |
| 100 | 101 | |
| 101 | const CVIndexMap &maybeMergeTypeServerPDB(ObjFile *File, | |
| 102 | TypeServer2Record &TS); | |
| 102 | Expected<const CVIndexMap&> maybeMergeTypeServerPDB(ObjFile *File, | |
| 103 | TypeServer2Record &TS); | |
| 103 | 104 | |
| 104 | 105 | /// Add the section map and section contributions to the PDB. |
| 105 | 106 | void addSections(ArrayRef<OutputSection *> OutputSections, |
| ... | ... | @@ -140,6 +141,10 @@ private: |
| 140 | 141 | |
| 141 | 142 | /// Type index mappings of type server PDBs that we've loaded so far. |
| 142 | 143 | std::map<GUID, CVIndexMap> TypeServerIndexMappings; |
| 144 | ||
| 145 | /// List of TypeServer PDBs which cannot be loaded. | |
| 146 | /// Cached to prevent repeated load attempts. | |
| 147 | std::set<GUID> MissingTypeServerPDBs; | |
| 143 | 148 | }; |
| 144 | 149 | } |
| 145 | 150 | |
| ... | ... | @@ -230,8 +235,8 @@ maybeReadTypeServerRecord(CVTypeArray &Types) { |
| 230 | 235 | return std::move(TS); |
| 231 | 236 | } |
| 232 | 237 | |
| 233 | const CVIndexMap &PDBLinker::mergeDebugT(ObjFile *File, | |
| 234 | CVIndexMap &ObjectIndexMap) { | |
| 238 | Expected<const CVIndexMap&> PDBLinker::mergeDebugT(ObjFile *File, | |
| 239 | CVIndexMap &ObjectIndexMap) { | |
| 235 | 240 | ArrayRef<uint8_t> Data = getDebugSection(File, ".debug$T"); |
| 236 | 241 | if (Data.empty()) |
| 237 | 242 | return ObjectIndexMap; |
| ... | ... | @@ -304,11 +309,19 @@ tryToLoadPDB(const GUID &GuidFromObj, StringRef TSPath) { |
| 304 | 309 | return std::move(NS); |
| 305 | 310 | } |
| 306 | 311 | |
| 307 | const CVIndexMap &PDBLinker::maybeMergeTypeServerPDB(ObjFile *File, | |
| 308 | TypeServer2Record &TS) { | |
| 309 | // First, check if we already loaded a PDB with this GUID. Return the type | |
| 312 | Expected<const CVIndexMap&> PDBLinker::maybeMergeTypeServerPDB(ObjFile *File, | |
| 313 | TypeServer2Record &TS) { | |
| 314 | const GUID& TSId = TS.getGuid(); | |
| 315 | StringRef TSPath = TS.getName(); | |
| 316 | ||
| 317 | // First, check if the PDB has previously failed to load. | |
| 318 | if (MissingTypeServerPDBs.count(TSId)) | |
| 319 | return make_error<pdb::GenericError>( | |
| 320 | pdb::generic_error_code::type_server_not_found, TSPath); | |
| 321 | ||
| 322 | // Second, check if we already loaded a PDB with this GUID. Return the type | |
| 310 | 323 | // index mapping if we have it. |
| 311 | auto Insertion = TypeServerIndexMappings.insert({TS.getGuid(), CVIndexMap()}); | |
| 324 | auto Insertion = TypeServerIndexMappings.insert({TSId, CVIndexMap()}); | |
| 312 | 325 | CVIndexMap &IndexMap = Insertion.first->second; |
| 313 | 326 | if (!Insertion.second) |
| 314 | 327 | return IndexMap; |
| ... | ... | @@ -319,18 +332,21 @@ const CVIndexMap &PDBLinker::maybeMergeTypeServerPDB(ObjFile *File, |
| 319 | 332 | // Check for a PDB at: |
| 320 | 333 | // 1. The given file path |
| 321 | 334 | // 2. Next to the object file or archive file |
| 322 | auto ExpectedSession = tryToLoadPDB(TS.getGuid(), TS.getName()); | |
| 335 | auto ExpectedSession = tryToLoadPDB(TSId, TSPath); | |
| 323 | 336 | if (!ExpectedSession) { |
| 324 | 337 | consumeError(ExpectedSession.takeError()); |
| 325 | 338 | StringRef LocalPath = |
| 326 | 339 | !File->ParentName.empty() ? File->ParentName : File->getName(); |
| 327 | 340 | SmallString<128> Path = sys::path::parent_path(LocalPath); |
| 328 | 341 | sys::path::append( |
| 329 | Path, sys::path::filename(TS.getName(), sys::path::Style::windows)); | |
| 330 | ExpectedSession = tryToLoadPDB(TS.getGuid(), Path); | |
| 342 | Path, sys::path::filename(TSPath, sys::path::Style::windows)); | |
| 343 | ExpectedSession = tryToLoadPDB(TSId, Path); | |
| 344 | } | |
| 345 | if (auto E = ExpectedSession.takeError()) { | |
| 346 | TypeServerIndexMappings.erase(TSId); | |
| 347 | MissingTypeServerPDBs.emplace(TSId); | |
| 348 | return std::move(E); | |
| 331 | 349 | } |
| 332 | if (auto E = ExpectedSession.takeError()) | |
| 333 | fatal("Type server PDB was not found: " + toString(std::move(E))); | |
| 334 | 350 | |
| 335 | 351 | auto ExpectedTpi = (*ExpectedSession)->getPDBFile().getPDBTpiStream(); |
| 336 | 352 | if (auto E = ExpectedTpi.takeError()) |
| ... | ... | @@ -707,7 +723,16 @@ void PDBLinker::addObjFile(ObjFile *File) { |
| 707 | 723 | // the PDB first, so that we can get the map from object file type and item |
| 708 | 724 | // indices to PDB type and item indices. |
| 709 | 725 | CVIndexMap ObjectIndexMap; |
| 710 | const CVIndexMap &IndexMap = mergeDebugT(File, ObjectIndexMap); | |
| 726 | auto IndexMapResult = mergeDebugT(File, ObjectIndexMap); | |
| 727 | ||
| 728 | // If the .debug$T sections fail to merge, assume there is no debug info. | |
| 729 | if (!IndexMapResult) { | |
| 730 | warn("Type server PDB for " + Name + " is invalid, ignoring debug info. " + | |
| 731 | toString(IndexMapResult.takeError())); | |
| 732 | return; | |
| 733 | } | |
| 734 | ||
| 735 | const CVIndexMap &IndexMap = *IndexMapResult; | |
| 711 | 736 | |
| 712 | 737 | // Now do all live .debug$S sections. |
| 713 | 738 | for (SectionChunk *DebugChunk : File->getDebugChunks()) { |
deps/lld/ELF/Driver.cpp+7-2| ... | ... | @@ -638,7 +638,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { |
| 638 | 638 | Config->Optimize = args::getInteger(Args, OPT_O, 1); |
| 639 | 639 | Config->OrphanHandling = getOrphanHandling(Args); |
| 640 | 640 | Config->OutputFile = Args.getLastArgValue(OPT_o); |
| 641 | Config->Pie = Args.hasFlag(OPT_pie, OPT_no_pie, false); | |
| 641 | Config->Pie = Args.hasFlag(OPT_pie, OPT_nopie, false); | |
| 642 | 642 | Config->PrintGcSections = |
| 643 | 643 | Args.hasFlag(OPT_print_gc_sections, OPT_no_print_gc_sections, false); |
| 644 | 644 | Config->Rpath = getRpath(Args); |
| ... | ... | @@ -1061,7 +1061,12 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { |
| 1061 | 1061 | addReservedSymbols(); |
| 1062 | 1062 | |
| 1063 | 1063 | // Apply version scripts. |
| 1064 | Symtab->scanVersionScript(); | |
| 1064 | // | |
| 1065 | // For a relocatable output, version scripts don't make sense, and | |
| 1066 | // parsing a symbol version string (e.g. dropping "@ver1" from a symbol | |
| 1067 | // name "foo@ver1") rather do harm, so we don't call this if -r is given. | |
| 1068 | if (!Config->Relocatable) | |
| 1069 | Symtab->scanVersionScript(); | |
| 1065 | 1070 | |
| 1066 | 1071 | // Create wrapped symbols for -wrap option. |
| 1067 | 1072 | for (auto *Arg : Args.filtered(OPT_wrap)) |
deps/lld/ELF/Options.td+2-2| ... | ... | @@ -202,8 +202,6 @@ def no_gnu_unique: F<"no-gnu-unique">, |
| 202 | 202 | def no_merge_exidx_entries: F<"no-merge-exidx-entries">, |
| 203 | 203 | HelpText<"Disable merging .ARM.exidx entries">; |
| 204 | 204 | |
| 205 | def no_pie: F<"no-pie">, HelpText<"Do not create a position independent executable">; | |
| 206 | ||
| 207 | 205 | def no_threads: F<"no-threads">, |
| 208 | 206 | HelpText<"Do not run the linker multi-threaded">; |
| 209 | 207 | |
| ... | ... | @@ -213,6 +211,8 @@ def no_whole_archive: F<"no-whole-archive">, |
| 213 | 211 | def noinhibit_exec: F<"noinhibit-exec">, |
| 214 | 212 | HelpText<"Retain the executable output file whenever it is still usable">; |
| 215 | 213 | |
| 214 | def nopie: F<"nopie">, HelpText<"Do not create a position independent executable">; | |
| 215 | ||
| 216 | 216 | def no_omagic: Flag<["--"], "no-omagic">, MetaVarName<"<magic>">, |
| 217 | 217 | HelpText<"Do not set the text data sections to be writable">; |
| 218 | 218 |
deps/lld/docs/ReleaseNotes.rst+69-13| ... | ... | @@ -5,17 +5,12 @@ LLD 6.0.0 Release Notes |
| 5 | 5 | .. contents:: |
| 6 | 6 | :local: |
| 7 | 7 | |
| 8 | .. warning:: | |
| 9 | These are in-progress notes for the upcoming LLVM 6.0.0 release. | |
| 10 | Release notes for previous releases can be found on | |
| 11 | `the Download Page <http://releases.llvm.org/download.html>`_. | |
| 12 | ||
| 13 | 8 | Introduction |
| 14 | 9 | ============ |
| 15 | 10 | |
| 16 | This document contains the release notes for the LLD linker, release 6.0.0. | |
| 17 | Here we describe the status of LLD, including major improvements | |
| 18 | from the previous release. All LLD releases may be downloaded | |
| 11 | This document contains the release notes for the lld linker, release 6.0.0. | |
| 12 | Here we describe the status of lld, including major improvements | |
| 13 | from the previous release. All lld releases may be downloaded | |
| 19 | 14 | from the `LLVM releases web site <http://llvm.org/releases/>`_. |
| 20 | 15 | |
| 21 | 16 | Non-comprehensive list of changes in this release |
| ... | ... | @@ -24,20 +19,81 @@ Non-comprehensive list of changes in this release |
| 24 | 19 | ELF Improvements |
| 25 | 20 | ---------------- |
| 26 | 21 | |
| 27 | * Item 1. | |
| 22 | * A lot of bugs and compatibility issues have been identified and fixed as a | |
| 23 | result of people using lld 5.0 as a standard system linker. In particular, | |
| 24 | linker script and version script support has significantly improved that | |
| 25 | it should be able to handle almost all scripts. | |
| 26 | ||
| 27 | * A mitigation for Spectre v2 has been implemented. If you pass ``-z | |
| 28 | retpolineplt``, lld uses RET instruction instead of JMP instruction in PLT. | |
| 29 | The option is available for x86 and x86-64. | |
| 30 | ||
| 31 | * Identical Code Folding (ICF) now de-duplicates .eh_frame entries, so lld now | |
| 32 | generates slightly smaller outputs than before when you pass ``--icf=all``. | |
| 33 | ||
| 34 | * Analysis for ``--as-needed`` is now done after garbage collection. If garbage | |
| 35 | collector eliminates all sections that use some library, that library is | |
| 36 | eliminated from DT_NEEDED tags. Previously, the analysis ran before garbage | |
| 37 | collection. | |
| 38 | ||
| 39 | * Size of code segment is now always rounded up to page size to make sure that | |
| 40 | unused bytes at end of code segment is filled with trap instructions (such | |
| 41 | as INT3) instead of zeros. | |
| 42 | ||
| 43 | * lld is now able to generate Android-style compact dynamic relocation table. | |
| 44 | You can turn on the feature by passing ``--pack-dyn-relocs=android``. | |
| 45 | ||
| 46 | * Debug information is used in more cases when reporting errors. | |
| 47 | ||
| 48 | * ``--gdb-index`` gets faster than before. | |
| 49 | ||
| 50 | * String merging is now multi-threaded, which makes ``-O2`` faster. | |
| 51 | ||
| 52 | * ``--hash-style=both`` is now default instead of ``--hash-style=sysv`` to | |
| 53 | match the behavior of recent versions of GNU linkers. | |
| 54 | ||
| 55 | * ARM PLT entries automatically use short or long variants. | |
| 56 | ||
| 57 | * lld can now identify and patch a code sequence that triggers AArch64 errata 843419. | |
| 58 | Add ``--fix-cortex-a53-843419`` to enable the feature. | |
| 59 | ||
| 60 | * lld can now generate thunks for out of range thunks. | |
| 61 | ||
| 62 | * MIPS port now generates all output dynamic relocations using Elf_Rel format only. | |
| 63 | ||
| 64 | * Added handling of the R_MIPS_26 relocation in case of N32/N64 ABIs and | |
| 65 | generating proper PLT entries. | |
| 66 | ||
| 67 | * The following options have been added: ``--icf=none`` ``-z muldefs`` | |
| 68 | ``--plugin-opt`` ``--no-eh-frame-hdr`` ``--no-gdb-index`` | |
| 69 | ``--orphan-handling={place,discard,warn,error}`` | |
| 70 | ``--pack-dyn-relocs={none,android}`` ``--no-omagic`` | |
| 71 | ``--no-print-gc-sections`` ``--ignore-function-address-equality`` ``-z | |
| 72 | retpolineplt`` ``--print-icf-sections`` ``--no-pie`` | |
| 28 | 73 | |
| 29 | 74 | COFF Improvements |
| 30 | 75 | ----------------- |
| 31 | 76 | |
| 32 | 77 | * A GNU ld style frontend for the COFF linker has been added for MinGW. |
| 33 | 78 | In MinGW environments, the linker is invoked with GNU ld style parameters; |
| 34 | which LLD previously only supported when used as an ELF linker. When | |
| 79 | which lld previously only supported when used as an ELF linker. When | |
| 35 | 80 | a PE/COFF target is chosen, those parameters are rewritten into the |
| 36 | 81 | lld-link style parameters and the COFF linker is invoked instead. |
| 37 | 82 | |
| 38 | 83 | * Initial support for the ARM64 architecture has been added. |
| 39 | 84 | |
| 40 | MachO Improvements | |
| 41 | ------------------ | |
| 85 | * New ``--version`` flag. | |
| 86 | ||
| 87 | * Significantly improved support for writing PDB Files. | |
| 88 | ||
| 89 | * New ``--rsp-quoting`` flag, like ``clang-cl``. | |
| 90 | ||
| 91 | * ``/manifestuac:no`` no longer incorrectly disables ``/manifestdependency:``. | |
| 92 | ||
| 93 | * Only write ``.manifest`` files if ``/manifest`` is passed. | |
| 94 | ||
| 95 | WebAssembly Improvements | |
| 96 | ------------------------ | |
| 42 | 97 | |
| 43 | * Item 1. | |
| 98 | * Initial version of WebAssembly support has landed. You can invoke the | |
| 99 | WebAssembly linker by ``wasm-ld``. |
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp+1| ... | ... | @@ -621,6 +621,7 @@ void ArchHandler_x86_64::applyFixupFinal( |
| 621 | 621 | // Fall into llvm_unreachable(). |
| 622 | 622 | break; |
| 623 | 623 | } |
| 624 | llvm_unreachable("invalid x86_64 Reference Kind"); | |
| 624 | 625 | } |
| 625 | 626 | |
| 626 | 627 | void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref, |
deps/lld/test/COFF/pdb-type-server-missing.yaml+2-5| ... | ... | @@ -1,13 +1,10 @@ |
| 1 | 1 | # This is an object compiled with /Zi (see the LF_TYPESERVER2 record) without an |
| 2 | 2 | # adjacent type server PDB. Test that LLD fails gracefully on it. |
| 3 | 3 | |
| 4 | # FIXME: Ideally we'd do what MSVC does, which is to warn and drop all debug | |
| 5 | # info in the object with the missing PDB. | |
| 6 | ||
| 7 | 4 | # RUN: yaml2obj %s -o %t.obj |
| 8 | # RUN: not lld-link %t.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main 2>&1 | FileCheck %s | |
| 5 | # RUN: lld-link %t.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main 2>&1 | FileCheck %s | |
| 9 | 6 | |
| 10 | # CHECK: error: Type server PDB was not found | |
| 7 | # CHECK: warning: Type server PDB for {{.*}}.obj is invalid, ignoring debug info. | |
| 11 | 8 | |
| 12 | 9 | --- !COFF |
| 13 | 10 | header: |
deps/lld/test/ELF/pie.s+1-1| ... | ... | @@ -48,7 +48,7 @@ |
| 48 | 48 | # CHECK: Type: PT_DYNAMIC |
| 49 | 49 | |
| 50 | 50 | ## Check -nopie |
| 51 | # RUN: ld.lld -no-pie %t1.o -o %t2 | |
| 51 | # RUN: ld.lld -nopie %t1.o -o %t2 | |
| 52 | 52 | # RUN: llvm-readobj -file-headers -r %t2 | FileCheck %s --check-prefix=NOPIE |
| 53 | 53 | # NOPIE-NOT: Type: SharedObject |
| 54 | 54 |
deps/lld/test/ELF/relocatable-versioned.s created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | # REQUIRES: x86 | |
| 2 | # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o | |
| 3 | # RUN: ld.lld -o %t2.o -r %t1.o | |
| 4 | # RUN: llvm-nm %t2.o | FileCheck %s | |
| 5 | # CHECK: foo@VERSION | |
| 6 | ||
| 7 | .global "foo@VERSION" | |
| 8 | "foo@VERSION": | |
| 9 | ret |