diff --git a/lld/MachO/Arch/ARM.cpp b/lld/MachO/Arch/ARM.cpp --- a/lld/MachO/Arch/ARM.cpp +++ b/lld/MachO/Arch/ARM.cpp @@ -29,7 +29,7 @@ int64_t getEmbeddedAddend(MemoryBufferRef, uint64_t offset, const relocation_info) const override; - void relocateOne(uint8_t *loc, const Reloc &, uint64_t va, + void relocateOne(uint8_t *loc, const macho::Reloc &, uint64_t va, uint64_t pc) const override; void writeStub(uint8_t *buf, const Symbol &, uint64_t) const override; @@ -45,7 +45,7 @@ void relaxGotLoad(uint8_t *loc, uint8_t type) const override; uint64_t getPageSize() const override { return 4 * 1024; } - void handleDtraceReloc(const Symbol *sym, const Reloc &r, + void handleDtraceReloc(const Symbol *sym, const macho::Reloc &r, uint8_t *loc) const override; }; } // namespace @@ -101,7 +101,7 @@ using Cond = Bitfield::Element; using Imm24 = Bitfield::Element; -void ARM::relocateOne(uint8_t *loc, const Reloc &r, uint64_t value, +void ARM::relocateOne(uint8_t *loc, const macho::Reloc &r, uint64_t value, uint64_t pc) const { switch (r.type) { case ARM_RELOC_BR24: { @@ -180,7 +180,7 @@ return &t; } -void ARM::handleDtraceReloc(const Symbol *sym, const Reloc &r, +void ARM::handleDtraceReloc(const Symbol *sym, const macho::Reloc &r, uint8_t *loc) const { if (config->outputType == MH_OBJECT) return; diff --git a/lld/MachO/EhFrame.cpp b/lld/MachO/EhFrame.cpp --- a/lld/MachO/EhFrame.cpp +++ b/lld/MachO/EhFrame.cpp @@ -109,16 +109,16 @@ static void createSubtraction(PointerUnion a, PointerUnion b, uint64_t off, uint8_t length, - SmallVectorImpl *newRelocs) { + SmallVectorImpl *newRelocs) { auto subtrahend = a; auto minuend = b; if (Invert) std::swap(subtrahend, minuend); assert(subtrahend.is()); - Reloc subtrahendReloc(target->subtractorRelocType, /*pcrel=*/false, length, - off, /*addend=*/0, subtrahend); - Reloc minuendReloc(target->unsignedRelocType, /*pcrel=*/false, length, off, - (Invert ? 1 : -1) * off, minuend); + macho::Reloc subtrahendReloc(target->subtractorRelocType, /*pcrel=*/false, + length, off, /*addend=*/0, subtrahend); + macho::Reloc minuendReloc(target->unsignedRelocType, /*pcrel=*/false, length, + off, (Invert ? 1 : -1) * off, minuend); newRelocs->push_back(subtrahendReloc); newRelocs->push_back(minuendReloc); } diff --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp --- a/lld/MachO/ICF.cpp +++ b/lld/MachO/ICF.cpp @@ -105,7 +105,7 @@ return false; if (ia->relocs.size() != ib->relocs.size()) return false; - auto f = [](const Reloc &ra, const Reloc &rb) { + auto f = [](const macho::Reloc &ra, const macho::Reloc &rb) { if (ra.type != rb.type) return false; if (ra.pcrel != rb.pcrel) @@ -178,7 +178,7 @@ if (verboseDiagnostics) ++equalsVariableCount; assert(ia->relocs.size() == ib->relocs.size()); - auto f = [this](const Reloc &ra, const Reloc &rb) { + auto f = [this](const macho::Reloc &ra, const macho::Reloc &rb) { // We already filtered out mismatching values/addends in equalsConstant. if (ra.referent == rb.referent) return true; @@ -286,7 +286,7 @@ for (icfPass = 0; icfPass < 2; ++icfPass) { parallelForEach(icfInputs, [&](ConcatInputSection *isec) { uint32_t hash = isec->icfEqClass[icfPass % 2]; - for (const Reloc &r : isec->relocs) { + for (const macho::Reloc &r : isec->relocs) { if (auto *sym = r.referent.dyn_cast()) { if (auto *defined = dyn_cast(sym)) { if (defined->isec) { @@ -386,7 +386,7 @@ const InputSection *isec = addrSigSection->subsections[0].isec; - for (const Reloc &r : isec->relocs) { + for (const macho::Reloc &r : isec->relocs) { if (auto *sym = r.referent.dyn_cast()) markSymAsAddrSig(sym); else @@ -442,7 +442,7 @@ // We have to do this copying serially as the BumpPtrAllocator is not // thread-safe. FIXME: Make a thread-safe allocator. MutableArrayRef copy = isec->data.copy(bAlloc()); - for (const Reloc &r : isec->relocs) + for (const macho::Reloc &r : isec->relocs) target->relocateOne(copy.data() + r.offset, r, /*va=*/0, /*relocVA=*/0); isec->data = copy; diff --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp --- a/lld/MachO/InputSection.cpp +++ b/lld/MachO/InputSection.cpp @@ -31,8 +31,8 @@ // Verify ConcatInputSection's size on 64-bit builds. The size of std::vector // can differ based on STL debug levels (e.g. iterator debugging on MSVC's STL), // so account for that. -static_assert(sizeof(void *) != 8 || - sizeof(ConcatInputSection) == sizeof(std::vector) + 88, +static_assert(sizeof(void *) != 8 || sizeof(ConcatInputSection) == + sizeof(std::vector) + 88, "Try to minimize ConcatInputSection's size, we create many " "instances of it"); @@ -166,7 +166,7 @@ memcpy(buf, data.data(), data.size()); for (size_t i = 0; i < relocs.size(); i++) { - const Reloc &r = relocs[i]; + const macho::Reloc &r = relocs[i]; uint8_t *loc = buf + r.offset; uint64_t referentVA = 0; @@ -174,7 +174,7 @@ target->hasAttr(r.type, RelocAttrBits::UNSIGNED); if (target->hasAttr(r.type, RelocAttrBits::SUBTRAHEND)) { const Symbol *fromSym = r.referent.get(); - const Reloc &minuend = relocs[++i]; + const macho::Reloc &minuend = relocs[++i]; uint64_t minuendVA; if (const Symbol *toSym = minuend.referent.dyn_cast()) minuendVA = toSym->getVA() + minuend.addend; diff --git a/lld/MachO/Relocations.cpp b/lld/MachO/Relocations.cpp --- a/lld/MachO/Relocations.cpp +++ b/lld/MachO/Relocations.cpp @@ -18,11 +18,12 @@ using namespace lld; using namespace lld::macho; -static_assert(sizeof(void *) != 8 || sizeof(Reloc) == 24, +static_assert(sizeof(void *) != 8 || sizeof(macho::Reloc) == 24, "Try to minimize Reloc's size; we create many instances"); bool macho::validateSymbolRelocation(const Symbol *sym, - const InputSection *isec, const Reloc &r) { + const InputSection *isec, + const macho::Reloc &r) { const RelocAttrs &relocAttrs = target->getRelocAttrs(r.type); bool valid = true; auto message = [&](const Twine &diagnostic) { @@ -82,7 +83,7 @@ return nullptr; } -void macho::reportRangeError(void *loc, const Reloc &r, const Twine &v, +void macho::reportRangeError(void *loc, const macho::Reloc &r, const Twine &v, uint8_t bits, int64_t min, uint64_t max) { std::string hint; uint64_t off = reinterpret_cast(loc) - in.bufferStart; diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp --- a/lld/MachO/UnwindInfoSection.cpp +++ b/lld/MachO/UnwindInfoSection.cpp @@ -249,7 +249,7 @@ // that are referenced from many places, at least some of them likely // live, it wouldn't reduce number of got entries. for (size_t i = 0; i < isec->relocs.size(); ++i) { - Reloc &r = isec->relocs[i]; + macho::Reloc &r = isec->relocs[i]; assert(target->hasAttr(r.type, RelocAttrBits::UNSIGNED)); // Since compact unwind sections aren't part of the inputSections vector, // they don't get canonicalized by scanRelocations(), so we have to do the @@ -375,7 +375,7 @@ cu.functionLength = support::endian::read32le(buf + cuOffsets.functionLength); cu.encoding = support::endian::read32le(buf + cuOffsets.encoding); - for (const Reloc &r : d->unwindEntry->relocs) { + for (const macho::Reloc &r : d->unwindEntry->relocs) { if (r.offset == cuOffsets.personality) { cu.personality = r.referent.get(); } else if (r.offset == cuOffsets.lsda) {