[lld] 5de7467 - [lld-macho] Fix debug build
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 11 17:21:34 PDT 2021
Author: Jez Ng
Date: 2021-06-11T20:21:27-04:00
New Revision: 5de7467e9821485f492eb97fafd796e1db4c6bb5
URL: https://github.com/llvm/llvm-project/commit/5de7467e9821485f492eb97fafd796e1db4c6bb5
DIFF: https://github.com/llvm/llvm-project/commit/5de7467e9821485f492eb97fafd796e1db4c6bb5.diff
LOG: [lld-macho] Fix debug build
D103977 broke a bunch of stuff as I had only tested the release build
which eliminated asserts.
I've retained the asserts where possible, but I also removed a bunch
instead of adding a whole lot of verbose ConcatInputSection casts.
Added:
Modified:
lld/MachO/InputSection.cpp
lld/MachO/InputSection.h
lld/MachO/MapFile.cpp
lld/MachO/UnwindInfoSection.cpp
Removed:
################################################################################
diff --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp
index 995637dd7e79..909fe69f1605 100644
--- a/lld/MachO/InputSection.cpp
+++ b/lld/MachO/InputSection.cpp
@@ -48,7 +48,7 @@ static uint64_t resolveSymbolVA(const Symbol *sym, uint8_t type) {
return sym->getVA();
}
-void InputSection::writeTo(uint8_t *buf) {
+void ConcatInputSection::writeTo(uint8_t *buf) {
assert(!shouldOmitFromOutput());
if (getFileSize() == 0)
@@ -68,7 +68,6 @@ void InputSection::writeTo(uint8_t *buf) {
minuendVA = toSym->getVA() + minuend.addend;
else {
auto *referentIsec = minuend.referent.get<InputSection *>();
- assert(!referentIsec->shouldOmitFromOutput());
minuendVA = referentIsec->getVA(minuend.addend);
}
referentVA = minuendVA - fromSym->getVA();
@@ -87,10 +86,9 @@ void InputSection::writeTo(uint8_t *buf) {
referentVA -= firstTLVDataSection->addr;
}
} else if (auto *referentIsec = r.referent.dyn_cast<InputSection *>()) {
- assert(!referentIsec->shouldOmitFromOutput());
referentVA = referentIsec->getVA(r.addend);
}
- target->relocateOne(loc, r, referentVA, getVA(r.offset));
+ target->relocateOne(loc, r, referentVA, getVA() + r.offset);
}
}
diff --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h
index b01092e12f10..dc7b239d554f 100644
--- a/lld/MachO/InputSection.h
+++ b/lld/MachO/InputSection.h
@@ -46,8 +46,6 @@ class InputSection {
virtual bool isLive(uint64_t off) const = 0;
virtual void markLive(uint64_t off) = 0;
- void writeTo(uint8_t *buf);
-
InputFile *file = nullptr;
StringRef name;
StringRef segname;
@@ -96,6 +94,7 @@ class ConcatInputSection : public InputSection {
void markLive(uint64_t off) override { live = true; }
bool isCoalescedWeak() const { return wasCoalesced && numRefs == 0; }
bool shouldOmitFromOutput() const { return !live || isCoalescedWeak(); }
+ void writeTo(uint8_t *buf);
static bool classof(const InputSection *isec) {
return isec->kind() == ConcatKind;
diff --git a/lld/MachO/MapFile.cpp b/lld/MachO/MapFile.cpp
index 37789e3f2948..fd48dd9b870f 100644
--- a/lld/MachO/MapFile.cpp
+++ b/lld/MachO/MapFile.cpp
@@ -63,14 +63,10 @@ static std::vector<Defined *> getSymbols() {
std::vector<Defined *> v;
for (InputFile *file : inputFiles)
if (isa<ObjFile>(file))
- for (Symbol *sym : file->symbols) {
+ for (Symbol *sym : file->symbols)
if (auto *d = dyn_cast_or_null<Defined>(sym))
- if (d->isLive() && d->isec && d->getFile() == file) {
- assert(!d->isec->isCoalescedWeak() &&
- "file->symbols should store resolved symbols");
+ if (d->isLive() && d->isec && d->getFile() == file)
v.push_back(d);
- }
- }
return v;
}
@@ -146,7 +142,6 @@ void macho::writeMapFile() {
os << "# Address\t File Name\n";
for (InputSection *isec : inputSections) {
auto symsIt = sectionSyms.find(isec);
- assert(!isec->shouldOmitFromOutput() || (symsIt == sectionSyms.end()));
if (symsIt == sectionSyms.end())
continue;
for (Symbol *sym : symsIt->second) {
diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp
index 705b0dfdae27..d024b335702e 100644
--- a/lld/MachO/UnwindInfoSection.cpp
+++ b/lld/MachO/UnwindInfoSection.cpp
@@ -174,8 +174,6 @@ void UnwindInfoSectionImpl<Ptr>::prepareRelocations(ConcatInputSection *isec) {
}
if (auto *referentIsec = r.referent.dyn_cast<InputSection *>()) {
- assert(!referentIsec->isCoalescedWeak());
-
// Personality functions can be referenced via section relocations
// if they live in the same object file. Create placeholder synthetic
// symbols for them in the GOT.
More information about the llvm-commits
mailing list