Commit 77b530b50a
Changed files (13)
deps
lld
lld-prebuilt
lld
Config
deps/lld/COFF/Driver.cpp
@@ -61,7 +61,6 @@ bool link(ArrayRef<const char *> Args, raw_ostream &Diag) {
(ErrorOS == &llvm::errs() && Process::StandardErrHasColors());
Driver = make<LinkerDriver>();
Driver->link(Args);
- freeArena();
return !ErrorCount;
}
@@ -1031,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
if (!Args.hasArgNoClaim(OPT_INPUT)) {
fixupExports();
createImportLibrary(/*AsLib=*/true);
- return;
+ exit(0);
}
// Handle /delayload
@@ -1173,6 +1172,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
// Write the result.
writeResult(&Symtab);
+
+ // Call exit to avoid calling destructors.
+ exit(0);
}
} // namespace coff
deps/lld/ELF/LinkerScript.cpp
@@ -751,7 +751,7 @@ void LinkerScript::adjustSectionsAfterSorting() {
if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base)) {
Cmd->MemRegion = findMemoryRegion(Cmd);
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
- if (Cmd->AlignExpr && Cmd->Sec)
+ if (Cmd->AlignExpr)
Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
}
}
deps/lld/ELF/SyntheticSections.cpp
@@ -427,10 +427,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Piece,
&Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
// Search for an existing CIE by CIE contents/relocation target pair.
- CieRecord *Cie = &CieMap[{Piece.data(), Personality}];
+ CieRecord *&Cie = CieMap[{Piece.data(), Personality}];
// If not found, create a new one.
- if (Cie->Piece == nullptr) {
+ if (!Cie) {
+ Cie = make<CieRecord>();
Cie->Piece = &Piece;
Cies.push_back(Cie);
}
@@ -522,9 +523,14 @@ template <class ELFT>
static void writeCieFde(uint8_t *Buf, ArrayRef<uint8_t> D) {
memcpy(Buf, D.data(), D.size());
+ size_t Aligned = alignTo(D.size(), sizeof(typename ELFT::uint));
+
+ // Zero-clear trailing padding if it exists.
+ memset(Buf + D.size(), 0, Aligned - D.size());
+
// Fix the size field. -4 since size does not include the size field itself.
const endianness E = ELFT::TargetEndianness;
- write32<E>(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4);
+ write32<E>(Buf, Aligned - 4);
}
template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() {
deps/lld/ELF/SyntheticSections.h
@@ -103,7 +103,8 @@ private:
std::vector<CieRecord *> Cies;
// CIE records are uniquified by their contents and personality functions.
- llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
+ llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord *>
+ CieMap;
};
class GotSection : public SyntheticSection {
deps/lld/lib/ReaderWriter/MachO/ArchHandler.h
@@ -112,10 +112,6 @@ public:
/// info in final executables.
virtual bool isLazyPointer(const Reference &);
- /// Reference from an __stub_helper entry to the required offset of the
- /// lazy bind commands.
- virtual Reference::KindValue lazyImmediateLocationKind() = 0;
-
/// Returns true if the specified relocation is paired to the next relocation.
virtual bool isPairedReloc(const normalized::Relocation &) = 0;
deps/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
@@ -67,10 +67,6 @@ public:
return invalid;
}
- Reference::KindValue lazyImmediateLocationKind() override {
- return lazyImmediateLocation;
- }
-
Reference::KindValue pointerKind() override {
return invalid;
}
deps/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
@@ -127,10 +127,6 @@ public:
return pointer64;
}
- Reference::KindValue lazyImmediateLocationKind() override {
- return lazyImmediateLocation;
- }
-
uint32_t dwarfCompactUnwindType() override {
return 0x03000000;
}
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
@@ -70,10 +70,6 @@ public:
return delta32;
}
- Reference::KindValue lazyImmediateLocationKind() override {
- return lazyImmediateLocation;
- }
-
Reference::KindValue unwindRefToEhFrameKind() override {
return invalid;
}
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
@@ -116,10 +116,6 @@ public:
return unwindFDEToFunction;
}
- Reference::KindValue lazyImmediateLocationKind() override {
- return lazyImmediateLocation;
- }
-
Reference::KindValue unwindRefToEhFrameKind() override {
return unwindInfoToEhFrame;
}
@@ -621,7 +617,7 @@ void ArchHandler_x86_64::applyFixupFinal(
// Fall into llvm_unreachable().
break;
}
- return;
+ llvm_unreachable("invalid x86_64 Reference Kind");
}
void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,
deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -172,8 +172,6 @@ private:
SymbolScope &symbolScope);
void appendSection(SectionInfo *si, NormalizedFile &file);
uint32_t sectionIndexForAtom(const Atom *atom);
- void fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset,
- NormalizedFile &file);
typedef llvm::DenseMap<const Atom*, uint32_t> AtomToIndex;
struct AtomAndIndex { const Atom *atom; uint32_t index; SymbolScope scope; };
@@ -1425,8 +1423,6 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
uint8_t segmentIndex;
uint64_t segmentStartAddr;
- uint32_t offsetInBindInfo = 0;
-
for (SectionInfo *sect : _sectionInfos) {
segIndexForSection(sect, segmentIndex, segmentStartAddr);
for (const AtomInfo &info : sect->atomsAndOffsets) {
@@ -1471,59 +1467,6 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
bind.symbolName = targ->name();
bind.addend = ref->addend();
nFile.lazyBindingInfo.push_back(bind);
-
- // Now that we know the segmentOffset and the ordinal attribute,
- // we can fix the helper's code
-
- fixLazyReferenceImm(atom, offsetInBindInfo, nFile);
-
- // 5 bytes for opcodes + variable sizes (target name + \0 and offset
- // encode's size)
- offsetInBindInfo +=
- 6 + targ->name().size() + llvm::getULEB128Size(bind.segOffset);
- if (bind.ordinal > BIND_IMMEDIATE_MASK)
- offsetInBindInfo += llvm::getULEB128Size(bind.ordinal);
- }
- }
- }
- }
-}
-
-void Util::fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset,
- NormalizedFile &file) {
- for (const auto &ref : *atom) {
- const DefinedAtom *da = dyn_cast<DefinedAtom>(ref->target());
- if (da == nullptr)
- return;
-
- const Reference *helperRef = nullptr;
- for (const Reference *hr : *da) {
- if (hr->kindValue() == _archHandler.lazyImmediateLocationKind()) {
- helperRef = hr;
- break;
- }
- }
- if (helperRef == nullptr)
- continue;
-
- // TODO: maybe get the fixed atom content from _archHandler ?
- for (SectionInfo *sectInfo : _sectionInfos) {
- for (const AtomInfo &atomInfo : sectInfo->atomsAndOffsets) {
- if (atomInfo.atom == helperRef->target()) {
- auto sectionContent =
- file.sections[sectInfo->normalizedSectionIndex].content;
- uint8_t *rawb =
- file.ownedAllocations.Allocate<uint8_t>(sectionContent.size());
- llvm::MutableArrayRef<uint8_t> newContent{rawb,
- sectionContent.size()};
- std::copy(sectionContent.begin(), sectionContent.end(),
- newContent.begin());
- llvm::support::ulittle32_t *loc =
- reinterpret_cast<llvm::support::ulittle32_t *>(
- &newContent[atomInfo.offsetInSection +
- helperRef->offsetInAtom()]);
- *loc = offset;
- file.sections[sectInfo->normalizedSectionIndex].content = newContent;
}
}
}
deps/lld/test/ELF/eh-frame-padding-no-rosegment.s
@@ -0,0 +1,64 @@
+// REQUIRES: x86
+
+.cfi_startproc
+.cfi_personality 0x1b, bar
+.cfi_endproc
+
+.global bar
+.hidden bar
+bar:
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+
+// Check the size of the CIE (0x18 + 4) and FDE (0x10 + 4)
+// RUN: llvm-readobj -s -section-data %t.o | FileCheck --check-prefix=OBJ %s
+
+// OBJ: Name: .eh_frame
+// OBJ-NEXT: Type:
+// OBJ-NEXT: Flags [
+// OBJ-NEXT: SHF_ALLOC
+// OBJ-NEXT: ]
+// OBJ-NEXT: Address:
+// OBJ-NEXT: Offset:
+// OBJ-NEXT: Size:
+// OBJ-NEXT: Link:
+// OBJ-NEXT: Info:
+// OBJ-NEXT: AddressAlignment:
+// OBJ-NEXT: EntrySize:
+// OBJ-NEXT: SectionData (
+// OBJ-NEXT: 0000: 18000000 00000000 017A5052 00017810
+// OBJ-NEXT: 0010: 061B0000 00001B0C 07089001 10000000
+// OBJ-NEXT: 0020: 20000000 00000000 00000000 00000000
+// OBJ-NEXT: )
+
+// RUN: ld.lld %t.o -no-rosegment -o %t -shared
+
+// Check that .eh_frame is in the same segment as .text
+// RUN: llvm-readobj -l --elf-output-style=GNU %t | FileCheck --check-prefix=PHDR %s
+
+// PHDR: Segment Sections
+// PHDR: .text
+// PHDR-SAME: .eh_frame
+
+// Check that the CIE and FDE are padded with 0x00 and not 0xCC when the
+// .eh_frame section is placed in the executable segment
+// RUN: llvm-readobj -s -section-data %t | FileCheck %s
+
+// CHECK: Name: .eh_frame
+// CHECK-NEXT: Type:
+// CHECK-NEXT: Flags
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size:
+// CHECK-NEXT: Link:
+// CHECK-NEXT: Info:
+// CHECK-NEXT: AddressAlignment:
+// CHECK-NEXT: EntrySize:
+// CHECK-NEXT: SectionData (
+// CHECK-NEXT: 0000: 1C000000 00000000 017A5052 00017810
+// CHECK-NEXT: 0010: 061BBEFF FFFF1B0C 07089001 00000000
+// CHECK-NEXT: 0020: 14000000 24000000 A8FFFFFF 00000000
+// CHECK-NEXT: 0030: 00000000 00000000
+// CHECK-NEXT: )
deps/lld/test/mach-o/lazy-bind-x86_64.yaml
@@ -80,8 +80,8 @@ undefined-symbols:
# CHECK-HELPERS:Disassembly of section __TEXT,__stub_helper:
# CHECK-HELPERS: 68 00 00 00 00 pushq $0
-# CHECK-HELPERS: 68 0b 00 00 00 pushq $11
-# CHECK-HELPERS: 68 16 00 00 00 pushq $22
+# CHECK-HELPERS: 68 10 00 00 00 pushq $16
+# CHECK-HELPERS: 68 20 00 00 00 pushq $32
# Make sure the stub helper is correctly aligned
# CHECK-DYLIBS: sectname __stub_helper
deps/lld-prebuilt/lld/Config/Version.inc
@@ -1,5 +1,5 @@
-#define LLD_VERSION 5.0.0
-#define LLD_VERSION_STRING "5.0.0"
+#define LLD_VERSION 5.0.1
+#define LLD_VERSION_STRING "5.0.1"
#define LLD_VERSION_MAJOR 5
#define LLD_VERSION_MINOR 0
#define LLD_REVISION_STRING ""