authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-23 13:04:47-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-23 13:04:47-05:00
loga33b689f2c3ea568ceaa2bf054020f4c318c9355
treee99bc27cfa48f5620bf441c6e6d43bee77abff62
parent9cfd7dea19c4c54e2754119c04c06cd57cfb759d

update embedded LLD to 6.0.0rc3


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
230230OPTION(prefix_2, "no-mmap-output-file", no_mmap_output_file, Flag, INVALID, INVALID, nullptr, 0, 0, nullptr, nullptr, nullptr)
231231OPTION(prefix_3, "no-omagic", no_omagic, Flag, INVALID, INVALID, nullptr, 0, 0,
232232 "Do not set the text data sections to be writable", "<magic>", nullptr)
233OPTION(prefix_2, "no-pie", no_pie, Flag, INVALID, INVALID, nullptr, 0, 0,
234 "Do not create a position independent executable", nullptr, nullptr)
235233OPTION(prefix_2, "no-print-gc-sections", no_print_gc_sections, Flag, INVALID, INVALID, nullptr, 0, 0,
236234 "Do not list removed unused sections", nullptr, nullptr)
237235OPTION(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
249247OPTION(prefix_2, "noinhibit-exec", noinhibit_exec, Flag, INVALID, INVALID, nullptr, 0, 0,
250248 "Retain the executable output file whenever it is still usable", nullptr, nullptr)
251249OPTION(prefix_2, "non_shared", alias_Bstatic_non_shared, Flag, INVALID, Bstatic, nullptr, 0, 0, nullptr, nullptr, nullptr)
250OPTION(prefix_2, "nopie", nopie, Flag, INVALID, INVALID, nullptr, 0, 0,
251 "Do not create a position independent executable", nullptr, nullptr)
252252OPTION(prefix_2, "nostdlib", nostdlib, Flag, INVALID, INVALID, nullptr, 0, 0,
253253 "Only search directories specified on the command line", nullptr, nullptr)
254254OPTION(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:
9696 /// If the object does not use a type server PDB (compiled with /Z7), we merge
9797 /// all the type and item records from the .debug$S stream and fill in the
9898 /// caller-provided ObjectIndexMap.
99 const CVIndexMap &mergeDebugT(ObjFile *File, CVIndexMap &ObjectIndexMap);
99 Expected<const CVIndexMap&> mergeDebugT(ObjFile *File,
100 CVIndexMap &ObjectIndexMap);
100101
101 const CVIndexMap &maybeMergeTypeServerPDB(ObjFile *File,
102 TypeServer2Record &TS);
102 Expected<const CVIndexMap&> maybeMergeTypeServerPDB(ObjFile *File,
103 TypeServer2Record &TS);
103104
104105 /// Add the section map and section contributions to the PDB.
105106 void addSections(ArrayRef<OutputSection *> OutputSections,
......@@ -140,6 +141,10 @@ private:
140141
141142 /// Type index mappings of type server PDBs that we've loaded so far.
142143 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;
143148};
144149}
145150
......@@ -230,8 +235,8 @@ maybeReadTypeServerRecord(CVTypeArray &Types) {
230235 return std::move(TS);
231236}
232237
233const CVIndexMap &PDBLinker::mergeDebugT(ObjFile *File,
234 CVIndexMap &ObjectIndexMap) {
238Expected<const CVIndexMap&> PDBLinker::mergeDebugT(ObjFile *File,
239 CVIndexMap &ObjectIndexMap) {
235240 ArrayRef<uint8_t> Data = getDebugSection(File, ".debug$T");
236241 if (Data.empty())
237242 return ObjectIndexMap;
......@@ -304,11 +309,19 @@ tryToLoadPDB(const GUID &GuidFromObj, StringRef TSPath) {
304309 return std::move(NS);
305310}
306311
307const CVIndexMap &PDBLinker::maybeMergeTypeServerPDB(ObjFile *File,
308 TypeServer2Record &TS) {
309 // First, check if we already loaded a PDB with this GUID. Return the type
312Expected<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
310323 // index mapping if we have it.
311 auto Insertion = TypeServerIndexMappings.insert({TS.getGuid(), CVIndexMap()});
324 auto Insertion = TypeServerIndexMappings.insert({TSId, CVIndexMap()});
312325 CVIndexMap &IndexMap = Insertion.first->second;
313326 if (!Insertion.second)
314327 return IndexMap;
......@@ -319,18 +332,21 @@ const CVIndexMap &PDBLinker::maybeMergeTypeServerPDB(ObjFile *File,
319332 // Check for a PDB at:
320333 // 1. The given file path
321334 // 2. Next to the object file or archive file
322 auto ExpectedSession = tryToLoadPDB(TS.getGuid(), TS.getName());
335 auto ExpectedSession = tryToLoadPDB(TSId, TSPath);
323336 if (!ExpectedSession) {
324337 consumeError(ExpectedSession.takeError());
325338 StringRef LocalPath =
326339 !File->ParentName.empty() ? File->ParentName : File->getName();
327340 SmallString<128> Path = sys::path::parent_path(LocalPath);
328341 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);
331349 }
332 if (auto E = ExpectedSession.takeError())
333 fatal("Type server PDB was not found: " + toString(std::move(E)));
334350
335351 auto ExpectedTpi = (*ExpectedSession)->getPDBFile().getPDBTpiStream();
336352 if (auto E = ExpectedTpi.takeError())
......@@ -707,7 +723,16 @@ void PDBLinker::addObjFile(ObjFile *File) {
707723 // the PDB first, so that we can get the map from object file type and item
708724 // indices to PDB type and item indices.
709725 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;
711736
712737 // Now do all live .debug$S sections.
713738 for (SectionChunk *DebugChunk : File->getDebugChunks()) {
deps/lld/ELF/Driver.cpp+7-2
......@@ -638,7 +638,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
638638 Config->Optimize = args::getInteger(Args, OPT_O, 1);
639639 Config->OrphanHandling = getOrphanHandling(Args);
640640 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);
642642 Config->PrintGcSections =
643643 Args.hasFlag(OPT_print_gc_sections, OPT_no_print_gc_sections, false);
644644 Config->Rpath = getRpath(Args);
......@@ -1061,7 +1061,12 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
10611061 addReservedSymbols();
10621062
10631063 // 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();
10651070
10661071 // Create wrapped symbols for -wrap option.
10671072 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">,
202202def no_merge_exidx_entries: F<"no-merge-exidx-entries">,
203203 HelpText<"Disable merging .ARM.exidx entries">;
204204
205def no_pie: F<"no-pie">, HelpText<"Do not create a position independent executable">;
206
207205def no_threads: F<"no-threads">,
208206 HelpText<"Do not run the linker multi-threaded">;
209207
......@@ -213,6 +211,8 @@ def no_whole_archive: F<"no-whole-archive">,
213211def noinhibit_exec: F<"noinhibit-exec">,
214212 HelpText<"Retain the executable output file whenever it is still usable">;
215213
214def nopie: F<"nopie">, HelpText<"Do not create a position independent executable">;
215
216216def no_omagic: Flag<["--"], "no-omagic">, MetaVarName<"<magic>">,
217217 HelpText<"Do not set the text data sections to be writable">;
218218
deps/lld/docs/ReleaseNotes.rst+69-13
......@@ -5,17 +5,12 @@ LLD 6.0.0 Release Notes
55.. contents::
66 :local:
77
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
138Introduction
149============
1510
16This document contains the release notes for the LLD linker, release 6.0.0.
17Here we describe the status of LLD, including major improvements
18from the previous release. All LLD releases may be downloaded
11This document contains the release notes for the lld linker, release 6.0.0.
12Here we describe the status of lld, including major improvements
13from the previous release. All lld releases may be downloaded
1914from the `LLVM releases web site <http://llvm.org/releases/>`_.
2015
2116Non-comprehensive list of changes in this release
......@@ -24,20 +19,81 @@ Non-comprehensive list of changes in this release
2419ELF Improvements
2520----------------
2621
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``
2873
2974COFF Improvements
3075-----------------
3176
3277* A GNU ld style frontend for the COFF linker has been added for MinGW.
3378 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
3580 a PE/COFF target is chosen, those parameters are rewritten into the
3681 lld-link style parameters and the COFF linker is invoked instead.
3782
3883* Initial support for the ARM64 architecture has been added.
3984
40MachO 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
95WebAssembly Improvements
96------------------------
4297
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(
621621 // Fall into llvm_unreachable().
622622 break;
623623 }
624 llvm_unreachable("invalid x86_64 Reference Kind");
624625}
625626
626627void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,
deps/lld/test/COFF/pdb-type-server-missing.yaml+2-5
......@@ -1,13 +1,10 @@
11# This is an object compiled with /Zi (see the LF_TYPESERVER2 record) without an
22# adjacent type server PDB. Test that LLD fails gracefully on it.
33
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
74# 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
96
10# CHECK: error: Type server PDB was not found
7# CHECK: warning: Type server PDB for {{.*}}.obj is invalid, ignoring debug info.
118
129--- !COFF
1310header:
deps/lld/test/ELF/pie.s+1-1
......@@ -48,7 +48,7 @@
4848# CHECK: Type: PT_DYNAMIC
4949
5050## Check -nopie
51# RUN: ld.lld -no-pie %t1.o -o %t2
51# RUN: ld.lld -nopie %t1.o -o %t2
5252# RUN: llvm-readobj -file-headers -r %t2 | FileCheck %s --check-prefix=NOPIE
5353# NOPIE-NOT: Type: SharedObject
5454
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