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,5 +1,5 @@
1#define LLD_VERSION 5.0.01#define LLD_VERSION 5.0.1
2#define LLD_VERSION_STRING "5.0.0"2#define LLD_VERSION_STRING "5.0.1"
3#define LLD_VERSION_MAJOR 53#define LLD_VERSION_MAJOR 5
4#define LLD_VERSION_MINOR 04#define LLD_VERSION_MINOR 0
5#define LLD_REVISION_STRING ""5#define LLD_REVISION_STRING ""
deps/lld/COFF/Driver.cpp+4-2
...@@ -61,7 +61,6 @@ bool link(ArrayRef<const char *> Args, raw_ostream &Diag) {...@@ -61,7 +61,6 @@ bool link(ArrayRef<const char *> Args, raw_ostream &Diag) {
61 (ErrorOS == &llvm::errs() && Process::StandardErrHasColors());61 (ErrorOS == &llvm::errs() && Process::StandardErrHasColors());
62 Driver = make<LinkerDriver>();62 Driver = make<LinkerDriver>();
63 Driver->link(Args);63 Driver->link(Args);
64 freeArena();
65 return !ErrorCount;64 return !ErrorCount;
66}65}
6766
...@@ -1031,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {...@@ -1031,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
1031 if (!Args.hasArgNoClaim(OPT_INPUT)) {1030 if (!Args.hasArgNoClaim(OPT_INPUT)) {
1032 fixupExports();1031 fixupExports();
1033 createImportLibrary(/*AsLib=*/true);1032 createImportLibrary(/*AsLib=*/true);
1034 return;1033 exit(0);
1035 }1034 }
10361035
1037 // Handle /delayload1036 // Handle /delayload
...@@ -1173,6 +1172,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {...@@ -1173,6 +1172,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
11731172
1174 // Write the result.1173 // Write the result.
1175 writeResult(&Symtab);1174 writeResult(&Symtab);
1175
1176 // Call exit to avoid calling destructors.
1177 exit(0);
1176}1178}
11771179
1178} // namespace coff1180} // namespace coff
deps/lld/ELF/LinkerScript.cpp+1-1
...@@ -751,7 +751,7 @@ void LinkerScript::adjustSectionsAfterSorting() {...@@ -751,7 +751,7 @@ void LinkerScript::adjustSectionsAfterSorting() {
751 if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base)) {751 if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base)) {
752 Cmd->MemRegion = findMemoryRegion(Cmd);752 Cmd->MemRegion = findMemoryRegion(Cmd);
753 // Handle align (e.g. ".foo : ALIGN(16) { ... }").753 // Handle align (e.g. ".foo : ALIGN(16) { ... }").
754 if (Cmd->AlignExpr && Cmd->Sec)754 if (Cmd->AlignExpr)
755 Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());755 Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
756 }756 }
757 }757 }
deps/lld/ELF/SyntheticSections.cpp+9-3
...@@ -427,10 +427,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Piece,...@@ -427,10 +427,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Piece,
427 &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);427 &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
428428
429 // Search for an existing CIE by CIE contents/relocation target pair.429 // 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
432 // If not found, create a new one.432 // If not found, create a new one.
433 if (Cie->Piece == nullptr) {433 if (!Cie) {
434 Cie = make<CieRecord>();
434 Cie->Piece = &Piece;435 Cie->Piece = &Piece;
435 Cies.push_back(Cie);436 Cies.push_back(Cie);
436 }437 }
...@@ -522,9 +523,14 @@ template <class ELFT>...@@ -522,9 +523,14 @@ template <class ELFT>
522static void writeCieFde(uint8_t *Buf, ArrayRef<uint8_t> D) {523static void writeCieFde(uint8_t *Buf, ArrayRef<uint8_t> D) {
523 memcpy(Buf, D.data(), D.size());524 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
525 // Fix the size field. -4 since size does not include the size field itself.531 // Fix the size field. -4 since size does not include the size field itself.
526 const endianness E = ELFT::TargetEndianness;532 const endianness E = ELFT::TargetEndianness;
527 write32<E>(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4);533 write32<E>(Buf, Aligned - 4);
528}534}
529535
530template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() {536template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() {
deps/lld/ELF/SyntheticSections.h+2-1
...@@ -103,7 +103,8 @@ private:...@@ -103,7 +103,8 @@ private:
103 std::vector<CieRecord *> Cies;103 std::vector<CieRecord *> Cies;
104104
105 // CIE records are uniquified by their contents and personality functions.105 // 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;
107};108};
108109
109class GotSection : public SyntheticSection {110class GotSection : public SyntheticSection {
deps/lld/lib/ReaderWriter/MachO/ArchHandler.h-4
...@@ -112,10 +112,6 @@ public:...@@ -112,10 +112,6 @@ public:
112 /// info in final executables.112 /// info in final executables.
113 virtual bool isLazyPointer(const Reference &);113 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
119 /// Returns true if the specified relocation is paired to the next relocation.115 /// Returns true if the specified relocation is paired to the next relocation.
120 virtual bool isPairedReloc(const normalized::Relocation &) = 0;116 virtual bool isPairedReloc(const normalized::Relocation &) = 0;
121117
deps/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp-4
...@@ -67,10 +67,6 @@ public:...@@ -67,10 +67,6 @@ public:
67 return invalid;67 return invalid;
68 }68 }
6969
70 Reference::KindValue lazyImmediateLocationKind() override {
71 return lazyImmediateLocation;
72 }
73
74 Reference::KindValue pointerKind() override {70 Reference::KindValue pointerKind() override {
75 return invalid;71 return invalid;
76 }72 }
deps/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp-4
...@@ -127,10 +127,6 @@ public:...@@ -127,10 +127,6 @@ public:
127 return pointer64;127 return pointer64;
128 }128 }
129129
130 Reference::KindValue lazyImmediateLocationKind() override {
131 return lazyImmediateLocation;
132 }
133
134 uint32_t dwarfCompactUnwindType() override {130 uint32_t dwarfCompactUnwindType() override {
135 return 0x03000000;131 return 0x03000000;
136 }132 }
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp-4
...@@ -70,10 +70,6 @@ public:...@@ -70,10 +70,6 @@ public:
70 return delta32;70 return delta32;
71 }71 }
7272
73 Reference::KindValue lazyImmediateLocationKind() override {
74 return lazyImmediateLocation;
75 }
76
77 Reference::KindValue unwindRefToEhFrameKind() override {73 Reference::KindValue unwindRefToEhFrameKind() override {
78 return invalid;74 return invalid;
79 }75 }
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp+1-5
...@@ -116,10 +116,6 @@ public:...@@ -116,10 +116,6 @@ public:
116 return unwindFDEToFunction;116 return unwindFDEToFunction;
117 }117 }
118118
119 Reference::KindValue lazyImmediateLocationKind() override {
120 return lazyImmediateLocation;
121 }
122
123 Reference::KindValue unwindRefToEhFrameKind() override {119 Reference::KindValue unwindRefToEhFrameKind() override {
124 return unwindInfoToEhFrame;120 return unwindInfoToEhFrame;
125 }121 }
...@@ -621,7 +617,7 @@ void ArchHandler_x86_64::applyFixupFinal(...@@ -621,7 +617,7 @@ void ArchHandler_x86_64::applyFixupFinal(
621 // Fall into llvm_unreachable().617 // Fall into llvm_unreachable().
622 break;618 break;
623 }619 }
624 return;620 llvm_unreachable("invalid x86_64 Reference Kind");
625}621}
626622
627void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,623void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,
deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp-57
...@@ -172,8 +172,6 @@ private:...@@ -172,8 +172,6 @@ private:
172 SymbolScope &symbolScope);172 SymbolScope &symbolScope);
173 void appendSection(SectionInfo *si, NormalizedFile &file);173 void appendSection(SectionInfo *si, NormalizedFile &file);
174 uint32_t sectionIndexForAtom(const Atom *atom);174 uint32_t sectionIndexForAtom(const Atom *atom);
175 void fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset,
176 NormalizedFile &file);
177175
178 typedef llvm::DenseMap<const Atom*, uint32_t> AtomToIndex;176 typedef llvm::DenseMap<const Atom*, uint32_t> AtomToIndex;
179 struct AtomAndIndex { const Atom *atom; uint32_t index; SymbolScope scope; };177 struct AtomAndIndex { const Atom *atom; uint32_t index; SymbolScope scope; };
...@@ -1425,8 +1423,6 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,...@@ -1425,8 +1423,6 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
14251423
1426 uint8_t segmentIndex;1424 uint8_t segmentIndex;
1427 uint64_t segmentStartAddr;1425 uint64_t segmentStartAddr;
1428 uint32_t offsetInBindInfo = 0;
1429
1430 for (SectionInfo *sect : _sectionInfos) {1426 for (SectionInfo *sect : _sectionInfos) {
1431 segIndexForSection(sect, segmentIndex, segmentStartAddr);1427 segIndexForSection(sect, segmentIndex, segmentStartAddr);
1432 for (const AtomInfo &info : sect->atomsAndOffsets) {1428 for (const AtomInfo &info : sect->atomsAndOffsets) {
...@@ -1471,59 +1467,6 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,...@@ -1471,59 +1467,6 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
1471 bind.symbolName = targ->name();1467 bind.symbolName = targ->name();
1472 bind.addend = ref->addend();1468 bind.addend = ref->addend();
1473 nFile.lazyBindingInfo.push_back(bind);1469 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;
1527 }1470 }
1528 }1471 }
1529 }1472 }
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:...@@ -80,8 +80,8 @@ undefined-symbols:
8080
81# CHECK-HELPERS:Disassembly of section __TEXT,__stub_helper:81# CHECK-HELPERS:Disassembly of section __TEXT,__stub_helper:
82# CHECK-HELPERS: 68 00 00 00 00 pushq $082# CHECK-HELPERS: 68 00 00 00 00 pushq $0
83# CHECK-HELPERS: 68 0b 00 00 00 pushq $1183# CHECK-HELPERS: 68 10 00 00 00 pushq $16
84# CHECK-HELPERS: 68 16 00 00 00 pushq $2284# CHECK-HELPERS: 68 20 00 00 00 pushq $32
8585
86# Make sure the stub helper is correctly aligned86# Make sure the stub helper is correctly aligned
87# CHECK-DYLIBS: sectname __stub_helper87# CHECK-DYLIBS: sectname __stub_helper