Skip to content

Commit

Permalink
[lld-macho] Rename LazySymbol to LazyArchive. NFC
Browse files Browse the repository at this point in the history
D116913 will add LazyObject. Rename LazySymbol to LazyArchive to avoid confusion
and mirror ELF.

Reviewed By: #lld-macho, Jez Ng

Differential Revision: https://reviews.llvm.org/D116914
  • Loading branch information
MaskRay committed Jan 12, 2022
1 parent 1f5dceb commit 97a5dcc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lld/MachO/InputFiles.cpp
Expand Up @@ -1426,7 +1426,7 @@ ArchiveFile::ArchiveFile(std::unique_ptr<object::Archive> &&f)

void ArchiveFile::addLazySymbols() {
for (const object::Archive::Symbol &sym : file->symbols())
symtab->addLazy(sym.getName(), this, sym);
symtab->addLazyArchive(sym.getName(), this, sym);
}

static Expected<InputFile *> loadArchiveMember(MemoryBufferRef mb,
Expand Down
10 changes: 5 additions & 5 deletions lld/MachO/SymbolTable.cpp
Expand Up @@ -113,7 +113,7 @@ Symbol *SymbolTable::addUndefined(StringRef name, InputFile *file,

if (wasInserted)
replaceSymbol<Undefined>(s, name, file, refState);
else if (auto *lazy = dyn_cast<LazySymbol>(s))
else if (auto *lazy = dyn_cast<LazyArchive>(s))
lazy->fetchArchiveMember();
else if (auto *dynsym = dyn_cast<DylibSymbol>(s))
dynsym->reference(refState);
Expand Down Expand Up @@ -178,22 +178,22 @@ Symbol *SymbolTable::addDynamicLookup(StringRef name) {
return addDylib(name, /*file=*/nullptr, /*isWeakDef=*/false, /*isTlv=*/false);
}

Symbol *SymbolTable::addLazy(StringRef name, ArchiveFile *file,
const object::Archive::Symbol &sym) {
Symbol *SymbolTable::addLazyArchive(StringRef name, ArchiveFile *file,
const object::Archive::Symbol &sym) {
Symbol *s;
bool wasInserted;
std::tie(s, wasInserted) = insert(name, file);

if (wasInserted) {
replaceSymbol<LazySymbol>(s, file, sym);
replaceSymbol<LazyArchive>(s, file, sym);
} else if (isa<Undefined>(s)) {
file->fetch(sym);
} else if (auto *dysym = dyn_cast<DylibSymbol>(s)) {
if (dysym->isWeakDef()) {
if (dysym->getRefState() != RefState::Unreferenced)
file->fetch(sym);
else
replaceSymbol<LazySymbol>(s, file, sym);
replaceSymbol<LazyArchive>(s, file, sym);
}
}
return s;
Expand Down
4 changes: 2 additions & 2 deletions lld/MachO/SymbolTable.h
Expand Up @@ -51,8 +51,8 @@ class SymbolTable {
Symbol *addDylib(StringRef name, DylibFile *file, bool isWeakDef, bool isTlv);
Symbol *addDynamicLookup(StringRef name);

Symbol *addLazy(StringRef name, ArchiveFile *file,
const llvm::object::Archive::Symbol &sym);
Symbol *addLazyArchive(StringRef name, ArchiveFile *file,
const llvm::object::Archive::Symbol &sym);

Defined *addSynthetic(StringRef name, InputSection *, uint64_t value,
bool isPrivateExtern, bool includeInSymtab,
Expand Down
2 changes: 1 addition & 1 deletion lld/MachO/Symbols.cpp
Expand Up @@ -101,4 +101,4 @@ uint64_t DylibSymbol::getVA() const {
return isInStubs() ? getStubVA() : Symbol::getVA();
}
void LazySymbol::fetchArchiveMember() { getFile()->fetch(sym); }
void LazyArchive::fetchArchiveMember() { getFile()->fetch(sym); }
12 changes: 6 additions & 6 deletions lld/MachO/Symbols.h
Expand Up @@ -37,7 +37,7 @@ class Symbol {
UndefinedKind,
CommonKind,
DylibKind,
LazyKind,
LazyArchiveKind,
};

virtual ~Symbol() {}
Expand Down Expand Up @@ -280,15 +280,15 @@ class DylibSymbol : public Symbol {
const bool tlv : 1;
};

class LazySymbol : public Symbol {
class LazyArchive : public Symbol {
public:
LazySymbol(ArchiveFile *file, const llvm::object::Archive::Symbol &sym)
: Symbol(LazyKind, sym.getName(), file), sym(sym) {}
LazyArchive(ArchiveFile *file, const llvm::object::Archive::Symbol &sym)
: Symbol(LazyArchiveKind, sym.getName(), file), sym(sym) {}

ArchiveFile *getFile() const { return cast<ArchiveFile>(file); }
void fetchArchiveMember();

static bool classof(const Symbol *s) { return s->kind() == LazyKind; }
static bool classof(const Symbol *s) { return s->kind() == LazyArchiveKind; }

private:
const llvm::object::Archive::Symbol sym;
Expand All @@ -299,7 +299,7 @@ union SymbolUnion {
alignas(Undefined) char b[sizeof(Undefined)];
alignas(CommonSymbol) char c[sizeof(CommonSymbol)];
alignas(DylibSymbol) char d[sizeof(DylibSymbol)];
alignas(LazySymbol) char e[sizeof(LazySymbol)];
alignas(LazyArchive) char e[sizeof(LazyArchive)];
};

template <typename T, typename... ArgT>
Expand Down
2 changes: 1 addition & 1 deletion lld/MachO/UnwindInfoSection.cpp
Expand Up @@ -226,7 +226,7 @@ void UnwindInfoSectionImpl<Ptr>::prepareRelocations(ConcatInputSection *isec) {
// (See discussions/alternatives already considered on D107533)
if (!defined->isExternal())
if (Symbol *sym = symtab->find(defined->getName()))
if (sym->kind() != Symbol::LazyKind)
if (sym->kind() != Symbol::LazyArchiveKind)
r.referent = s = sym;
}
if (auto *undefined = dyn_cast<Undefined>(s)) {
Expand Down

0 comments on commit 97a5dcc

Please sign in to comment.