authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-12-01 11:59:14-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-12-01 11:59:14-05:00
log77b530b50aedd1cf9943e1d4fdd97a364fe9a921
tree032324f8f10a6b57beb807b6ed1c649d747975ec
parentb4120423a5f0785e950739ab8c1324691971d680

updated embedded LLD to 5.0.1rc2


13 files changed, 85 insertions(+), 89 deletions(-)

deps/lld-prebuilt/lld/Config/Version.inc+2-2
......@@ -1,5 +1,5 @@
1#define LLD_VERSION 5.0.0
2#define LLD_VERSION_STRING "5.0.0"
1#define LLD_VERSION 5.0.1
2#define LLD_VERSION_STRING "5.0.1"
33#define LLD_VERSION_MAJOR 5
44#define LLD_VERSION_MINOR 0
55#define LLD_REVISION_STRING ""
deps/lld/COFF/Driver.cpp+4-2
......@@ -61,7 +61,6 @@ bool link(ArrayRef<const char *> Args, raw_ostream &Diag) {
6161 (ErrorOS == &llvm::errs() && Process::StandardErrHasColors());
6262 Driver = make<LinkerDriver>();
6363 Driver->link(Args);
64 freeArena();
6564 return !ErrorCount;
6665}
6766
......@@ -1031,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
10311030 if (!Args.hasArgNoClaim(OPT_INPUT)) {
10321031 fixupExports();
10331032 createImportLibrary(/*AsLib=*/true);
1034 return;
1033 exit(0);
10351034 }
10361035
10371036 // Handle /delayload
......@@ -1173,6 +1172,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
11731172
11741173 // Write the result.
11751174 writeResult(&Symtab);
1175
1176 // Call exit to avoid calling destructors.
1177 exit(0);
11761178}
11771179
11781180} // namespace coff
deps/lld/ELF/LinkerScript.cpp+1-1
......@@ -751,7 +751,7 @@ void LinkerScript::adjustSectionsAfterSorting() {
751751 if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base)) {
752752 Cmd->MemRegion = findMemoryRegion(Cmd);
753753 // Handle align (e.g. ".foo : ALIGN(16) { ... }").
754 if (Cmd->AlignExpr && Cmd->Sec)
754 if (Cmd->AlignExpr)
755755 Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
756756 }
757757 }
deps/lld/ELF/SyntheticSections.cpp+9-3
......@@ -427,10 +427,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Piece,
427427 &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
428428
429429 // Search for an existing CIE by CIE contents/relocation target pair.
430 CieRecord *Cie = &CieMap[{Piece.data(), Personality}];
430 CieRecord *&Cie = CieMap[{Piece.data(), Personality}];
431431
432432 // If not found, create a new one.
433 if (Cie->Piece == nullptr) {
433 if (!Cie) {
434 Cie = make<CieRecord>();
434435 Cie->Piece = &Piece;
435436 Cies.push_back(Cie);
436437 }
......@@ -522,9 +523,14 @@ template <class ELFT>
522523static void writeCieFde(uint8_t *Buf, ArrayRef<uint8_t> D) {
523524 memcpy(Buf, D.data(), D.size());
524525
526 size_t Aligned = alignTo(D.size(), sizeof(typename ELFT::uint));
527
528 // Zero-clear trailing padding if it exists.
529 memset(Buf + D.size(), 0, Aligned - D.size());
530
525531 // Fix the size field. -4 since size does not include the size field itself.
526532 const endianness E = ELFT::TargetEndianness;
527 write32<E>(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4);
533 write32<E>(Buf, Aligned - 4);
528534}
529535
530536template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() {
deps/lld/ELF/SyntheticSections.h+2-1
......@@ -103,7 +103,8 @@ private:
103103 std::vector<CieRecord *> Cies;
104104
105105 // CIE records are uniquified by their contents and personality functions.
106 llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
106 llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord *>
107 CieMap;
107108};
108109
109110class GotSection : public SyntheticSection {
deps/lld/lib/ReaderWriter/MachO/ArchHandler.h-4
......@@ -112,10 +112,6 @@ public:
112112 /// info in final executables.
113113 virtual bool isLazyPointer(const Reference &);
114114
115 /// Reference from an __stub_helper entry to the required offset of the
116 /// lazy bind commands.
117 virtual Reference::KindValue lazyImmediateLocationKind() = 0;
118
119115 /// Returns true if the specified relocation is paired to the next relocation.
120116 virtual bool isPairedReloc(const normalized::Relocation &) = 0;
121117
deps/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp-4
......@@ -67,10 +67,6 @@ public:
6767 return invalid;
6868 }
6969
70 Reference::KindValue lazyImmediateLocationKind() override {
71 return lazyImmediateLocation;
72 }
73
7470 Reference::KindValue pointerKind() override {
7571 return invalid;
7672 }
deps/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp-4
......@@ -127,10 +127,6 @@ public:
127127 return pointer64;
128128 }
129129
130 Reference::KindValue lazyImmediateLocationKind() override {
131 return lazyImmediateLocation;
132 }
133
134130 uint32_t dwarfCompactUnwindType() override {
135131 return 0x03000000;
136132 }
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp-4
......@@ -70,10 +70,6 @@ public:
7070 return delta32;
7171 }
7272
73 Reference::KindValue lazyImmediateLocationKind() override {
74 return lazyImmediateLocation;
75 }
76
7773 Reference::KindValue unwindRefToEhFrameKind() override {
7874 return invalid;
7975 }
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp+1-5
......@@ -116,10 +116,6 @@ public:
116116 return unwindFDEToFunction;
117117 }
118118
119 Reference::KindValue lazyImmediateLocationKind() override {
120 return lazyImmediateLocation;
121 }
122
123119 Reference::KindValue unwindRefToEhFrameKind() override {
124120 return unwindInfoToEhFrame;
125121 }
......@@ -621,7 +617,7 @@ void ArchHandler_x86_64::applyFixupFinal(
621617 // Fall into llvm_unreachable().
622618 break;
623619 }
624 return;
620 llvm_unreachable("invalid x86_64 Reference Kind");
625621}
626622
627623void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,
deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp-57
......@@ -172,8 +172,6 @@ private:
172172 SymbolScope &symbolScope);
173173 void appendSection(SectionInfo *si, NormalizedFile &file);
174174 uint32_t sectionIndexForAtom(const Atom *atom);
175 void fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset,
176 NormalizedFile &file);
177175
178176 typedef llvm::DenseMap<const Atom*, uint32_t> AtomToIndex;
179177 struct AtomAndIndex { const Atom *atom; uint32_t index; SymbolScope scope; };
......@@ -1425,8 +1423,6 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
14251423
14261424 uint8_t segmentIndex;
14271425 uint64_t segmentStartAddr;
1428 uint32_t offsetInBindInfo = 0;
1429
14301426 for (SectionInfo *sect : _sectionInfos) {
14311427 segIndexForSection(sect, segmentIndex, segmentStartAddr);
14321428 for (const AtomInfo &info : sect->atomsAndOffsets) {
......@@ -1471,59 +1467,6 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
14711467 bind.symbolName = targ->name();
14721468 bind.addend = ref->addend();
14731469 nFile.lazyBindingInfo.push_back(bind);
1474
1475 // Now that we know the segmentOffset and the ordinal attribute,
1476 // we can fix the helper's code
1477
1478 fixLazyReferenceImm(atom, offsetInBindInfo, nFile);
1479
1480 // 5 bytes for opcodes + variable sizes (target name + \0 and offset
1481 // encode's size)
1482 offsetInBindInfo +=
1483 6 + targ->name().size() + llvm::getULEB128Size(bind.segOffset);
1484 if (bind.ordinal > BIND_IMMEDIATE_MASK)
1485 offsetInBindInfo += llvm::getULEB128Size(bind.ordinal);
1486 }
1487 }
1488 }
1489 }
1490}
1491
1492void Util::fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset,
1493 NormalizedFile &file) {
1494 for (const auto &ref : *atom) {
1495 const DefinedAtom *da = dyn_cast<DefinedAtom>(ref->target());
1496 if (da == nullptr)
1497 return;
1498
1499 const Reference *helperRef = nullptr;
1500 for (const Reference *hr : *da) {
1501 if (hr->kindValue() == _archHandler.lazyImmediateLocationKind()) {
1502 helperRef = hr;
1503 break;
1504 }
1505 }
1506 if (helperRef == nullptr)
1507 continue;
1508
1509 // TODO: maybe get the fixed atom content from _archHandler ?
1510 for (SectionInfo *sectInfo : _sectionInfos) {
1511 for (const AtomInfo &atomInfo : sectInfo->atomsAndOffsets) {
1512 if (atomInfo.atom == helperRef->target()) {
1513 auto sectionContent =
1514 file.sections[sectInfo->normalizedSectionIndex].content;
1515 uint8_t *rawb =
1516 file.ownedAllocations.Allocate<uint8_t>(sectionContent.size());
1517 llvm::MutableArrayRef<uint8_t> newContent{rawb,
1518 sectionContent.size()};
1519 std::copy(sectionContent.begin(), sectionContent.end(),
1520 newContent.begin());
1521 llvm::support::ulittle32_t *loc =
1522 reinterpret_cast<llvm::support::ulittle32_t *>(
1523 &newContent[atomInfo.offsetInSection +
1524 helperRef->offsetInAtom()]);
1525 *loc = offset;
1526 file.sections[sectInfo->normalizedSectionIndex].content = newContent;
15271470 }
15281471 }
15291472 }
deps/lld/test/ELF/eh-frame-padding-no-rosegment.s created+64
......@@ -0,0 +1,64 @@
1// REQUIRES: x86
2
3.cfi_startproc
4.cfi_personality 0x1b, bar
5.cfi_endproc
6
7.global bar
8.hidden bar
9bar:
10
11// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
12
13// Check the size of the CIE (0x18 + 4) and FDE (0x10 + 4)
14// RUN: llvm-readobj -s -section-data %t.o | FileCheck --check-prefix=OBJ %s
15
16// OBJ: Name: .eh_frame
17// OBJ-NEXT: Type:
18// OBJ-NEXT: Flags [
19// OBJ-NEXT: SHF_ALLOC
20// OBJ-NEXT: ]
21// OBJ-NEXT: Address:
22// OBJ-NEXT: Offset:
23// OBJ-NEXT: Size:
24// OBJ-NEXT: Link:
25// OBJ-NEXT: Info:
26// OBJ-NEXT: AddressAlignment:
27// OBJ-NEXT: EntrySize:
28// OBJ-NEXT: SectionData (
29// OBJ-NEXT: 0000: 18000000 00000000 017A5052 00017810
30// OBJ-NEXT: 0010: 061B0000 00001B0C 07089001 10000000
31// OBJ-NEXT: 0020: 20000000 00000000 00000000 00000000
32// OBJ-NEXT: )
33
34// RUN: ld.lld %t.o -no-rosegment -o %t -shared
35
36// Check that .eh_frame is in the same segment as .text
37// RUN: llvm-readobj -l --elf-output-style=GNU %t | FileCheck --check-prefix=PHDR %s
38
39// PHDR: Segment Sections
40// PHDR: .text
41// PHDR-SAME: .eh_frame
42
43// Check that the CIE and FDE are padded with 0x00 and not 0xCC when the
44// .eh_frame section is placed in the executable segment
45// RUN: llvm-readobj -s -section-data %t | FileCheck %s
46
47// CHECK: Name: .eh_frame
48// CHECK-NEXT: Type:
49// CHECK-NEXT: Flags
50// CHECK-NEXT: SHF_ALLOC
51// CHECK-NEXT: ]
52// CHECK-NEXT: Address:
53// CHECK-NEXT: Offset:
54// CHECK-NEXT: Size:
55// CHECK-NEXT: Link:
56// CHECK-NEXT: Info:
57// CHECK-NEXT: AddressAlignment:
58// CHECK-NEXT: EntrySize:
59// CHECK-NEXT: SectionData (
60// CHECK-NEXT: 0000: 1C000000 00000000 017A5052 00017810
61// CHECK-NEXT: 0010: 061BBEFF FFFF1B0C 07089001 00000000
62// CHECK-NEXT: 0020: 14000000 24000000 A8FFFFFF 00000000
63// CHECK-NEXT: 0030: 00000000 00000000
64// CHECK-NEXT: )
deps/lld/test/mach-o/lazy-bind-x86_64.yaml+2-2
......@@ -80,8 +80,8 @@ undefined-symbols:
8080
8181# CHECK-HELPERS:Disassembly of section __TEXT,__stub_helper:
8282# CHECK-HELPERS: 68 00 00 00 00 pushq $0
83# CHECK-HELPERS: 68 0b 00 00 00 pushq $11
84# CHECK-HELPERS: 68 16 00 00 00 pushq $22
83# CHECK-HELPERS: 68 10 00 00 00 pushq $16
84# CHECK-HELPERS: 68 20 00 00 00 pushq $32
8585
8686# Make sure the stub helper is correctly aligned
8787# CHECK-DYLIBS: sectname __stub_helper