Within `lld/macho/`, only `InputFiles.cpp` and `Symbols.h` require the `macho::` namespace qualifier to disambiguate references to `class Symbol`.
Add braces to outer `for` of a 5-level single-line `if`/`for` nest.
Differential Revision: https://reviews.llvm.org/D99555
void relocateOne(uint8_t *loc, const Reloc &, uint64_t va,
uint64_t pc) const override;
- void writeStub(uint8_t *buf, const macho::Symbol &) const override;
+ void writeStub(uint8_t *buf, const Symbol &) const override;
void writeStubHelperHeader(uint8_t *buf) const override;
void writeStubHelperEntry(uint8_t *buf, const DylibSymbol &,
uint64_t entryAddr) const override;
0xd61f0200, // 08: br x16
};
-void ARM64::writeStub(uint8_t *buf8, const macho::Symbol &sym) const {
+void ARM64::writeStub(uint8_t *buf8, const Symbol &sym) const {
auto *buf32 = reinterpret_cast<uint32_t *>(buf8);
uint64_t pcPageBits =
pageBits(in.stubs->addr + sym.stubsIndex * sizeof(stubCode));
void relocateOne(uint8_t *loc, const Reloc &, uint64_t va,
uint64_t relocVA) const override;
- void writeStub(uint8_t *buf, const macho::Symbol &) const override;
+ void writeStub(uint8_t *buf, const Symbol &) const override;
void writeStubHelperHeader(uint8_t *buf) const override;
void writeStubHelperEntry(uint8_t *buf, const DylibSymbol &,
uint64_t entryAddr) const override;
0xff, 0x25, 0, 0, 0, 0, // jmpq *__la_symbol_ptr(%rip)
};
-void X86_64::writeStub(uint8_t *buf, const macho::Symbol &sym) const {
+void X86_64::writeStub(uint8_t *buf, const Symbol &sym) const {
memcpy(buf, stub, 2); // just copy the two nonzero bytes
uint64_t stubAddr = in.stubs->addr + sym.stubsIndex * sizeof(stub);
writeRipRelative({&sym, "stub"}, buf, stubAddr, sizeof(stub),
// any CommonSymbols.
static void replaceCommonSymbols() {
TimeTraceScope timeScope("Replace common symbols");
- for (macho::Symbol *sym : symtab->getSymbols()) {
+ for (Symbol *sym : symtab->getSymbols()) {
auto *common = dyn_cast<CommonSymbol>(sym);
if (common == nullptr)
continue;
uint64_t InputSection::getVA() const { return parent->addr + outSecOff; }
-static uint64_t resolveSymbolVA(uint8_t *loc, const lld::macho::Symbol &sym,
- uint8_t type) {
+static uint64_t resolveSymbolVA(uint8_t *loc, const Symbol &sym, uint8_t type) {
const RelocAttrs &relocAttrs = target->getRelocAttrs(type);
if (relocAttrs.hasAttr(RelocAttrBits::BRANCH)) {
if (sym.isInStubs())
// Construct a map from symbols to their stringified representations.
// Demangling symbols (which is what toString() does) is slow, so
// we do that in batch using parallel-for.
-static DenseMap<macho::Symbol *, std::string>
+static DenseMap<Symbol *, std::string>
getSymbolStrings(ArrayRef<Defined *> syms) {
std::vector<std::string> str(syms.size());
parallelForEachN(0, syms.size(), [&](size_t i) {
os << toString(*syms[i]);
});
- DenseMap<macho::Symbol *, std::string> ret;
+ DenseMap<Symbol *, std::string> ret;
for (size_t i = 0, e = syms.size(); i < e; ++i)
ret[syms[i]] = std::move(str[i]);
return ret;
// Collect symbol info that we want to print out.
std::vector<Defined *> syms = getSymbols();
SymbolMapTy sectionSyms = getSectionSyms(syms);
- DenseMap<lld::macho::Symbol *, std::string> symStr = getSymbolStrings(syms);
+ DenseMap<Symbol *, std::string> symStr = getSymbolStrings(syms);
// Dump table of sections
os << "# Sections:\n";
os << "# Symbols:\n";
os << "# Address\t File Name\n";
for (InputSection *isec : inputSections) {
- for (macho::Symbol *sym : sectionSyms[isec]) {
+ for (Symbol *sym : sectionSyms[isec]) {
os << format("0x%08llX\t[%3u] %s\n", sym->getVA(),
readerToFileOrdinal[sym->getFile()], symStr[sym].c_str());
}
return (compactUnwindSection != nullptr);
}
-SmallDenseMap<std::pair<InputSection *, uint64_t /* addend */>, macho::Symbol *>
+SmallDenseMap<std::pair<InputSection *, uint64_t /* addend */>, Symbol *>
personalityTable;
// Compact unwind relocations have different semantics, so we handle them in a
offsetof(struct CompactUnwindEntry64, personality))
continue;
- if (auto *s = r.referent.dyn_cast<lld::macho::Symbol *>()) {
+ if (auto *s = r.referent.dyn_cast<Symbol *>()) {
if (auto *undefined = dyn_cast<Undefined>(s)) {
treatUndefinedSymbol(*undefined);
// treatUndefinedSymbol() can replace s with a DylibSymbol; re-check.
}
if (auto *defined = dyn_cast<Defined>(s)) {
// Check if we have created a synthetic symbol at the same address.
- macho::Symbol *&personality =
+ Symbol *&personality =
personalityTable[{defined->isec, defined->value}];
if (personality == nullptr) {
personality = defined;
// 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.
- macho::Symbol *&s = personalityTable[{referentIsec, r.addend}];
+ Symbol *&s = personalityTable[{referentIsec, r.addend}];
if (s == nullptr) {
s = make<Defined>("<internal>", nullptr, referentIsec, r.addend, false,
false, false);
for (const Reloc &r : isec->relocs) {
uint64_t referentVA = 0;
- if (auto *referentSym = r.referent.dyn_cast<macho::Symbol *>()) {
+ if (auto *referentSym = r.referent.dyn_cast<Symbol *>()) {
if (!isa<Undefined>(referentSym)) {
assert(referentSym->isInGot());
if (auto *defined = dyn_cast<Defined>(referentSym))
return false;
}
-static void prepareSymbolRelocation(lld::macho::Symbol *sym,
- const InputSection *isec, const Reloc &r) {
+static void prepareSymbolRelocation(Symbol *sym, const InputSection *isec,
+ const Reloc &r) {
const RelocAttrs &relocAttrs = target->getRelocAttrs(r.type);
if (relocAttrs.hasAttr(RelocAttrBits::BRANCH)) {
// minuend, and doesn't have the usual UNSIGNED semantics. We don't want
// to emit rebase opcodes for it.
it = std::next(it);
- assert(isa<Defined>(it->referent.dyn_cast<lld::macho::Symbol *>()));
+ assert(isa<Defined>(it->referent.dyn_cast<Symbol *>()));
continue;
}
- if (auto *sym = r.referent.dyn_cast<lld::macho::Symbol *>()) {
+ if (auto *sym = r.referent.dyn_cast<Symbol *>()) {
if (auto *undefined = dyn_cast<Undefined>(sym))
treatUndefinedSymbol(*undefined);
// treatUndefinedSymbol() can replace sym with a DylibSymbol; re-check.
void Writer::scanSymbols() {
TimeTraceScope timeScope("Scan symbols");
- for (const macho::Symbol *sym : symtab->getSymbols()) {
+ for (const Symbol *sym : symtab->getSymbols()) {
if (const auto *defined = dyn_cast<Defined>(sym)) {
if (defined->overridesWeakDef)
in.weakBinding->addNonWeakDefinition(defined);
};
// TODO: Make sure this handles weak symbols correctly.
- for (const InputFile *file : inputFiles)
+ for (const InputFile *file : inputFiles) {
if (isa<ObjFile>(file))
- for (lld::macho::Symbol *sym : file->symbols)
+ for (Symbol *sym : file->symbols)
if (auto *d = dyn_cast<Defined>(sym))
addSym(*d);
+ }
return sectionPriorities;
}