Skip to content

Commit

Permalink
[ELF] Rename LazyObject to LazySymbol. NFC
Browse files Browse the repository at this point in the history
LazySymbol (used by wasm port) is a more accurate name (the struct is
not about an object). However, the ELF port calls this LazyObject likely
because we used to have LazyArchive (removed by
https://reviews.llvm.org/D119074), and LazyObject has a similar naming
convention (LazyObjectSymbol would be better, but it is too long).

Reviewers: dschuff

Pull Request: #78809
  • Loading branch information
MaskRay committed Jan 20, 2024
1 parent 4684507 commit 7071a25
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lld/ELF/InputFiles.cpp
Expand Up @@ -1739,7 +1739,7 @@ void BitcodeFile::parseLazy() {
for (auto [i, irSym] : llvm::enumerate(obj->symbols()))
if (!irSym.isUndefined()) {
auto *sym = symtab.insert(saver().save(irSym.getName()));
sym->resolve(LazyObject{*this});
sym->resolve(LazySymbol{*this});
symbols[i] = sym;
}
}
Expand Down Expand Up @@ -1821,7 +1821,7 @@ template <class ELFT> void ObjFile<ELFT>::parseLazy() {
if (eSyms[i].st_shndx == SHN_UNDEF)
continue;
symbols[i] = symtab.insert(CHECK(eSyms[i].getName(stringTable), this));
symbols[i]->resolve(LazyObject{*this});
symbols[i]->resolve(LazySymbol{*this});
if (!lazy)
break;
}
Expand Down
6 changes: 3 additions & 3 deletions lld/ELF/Symbols.cpp
Expand Up @@ -40,7 +40,7 @@ LLVM_ATTRIBUTE_UNUSED static inline void assertSymbols() {
AssertSymbol<CommonSymbol>();
AssertSymbol<Undefined>();
AssertSymbol<SharedSymbol>();
AssertSymbol<LazyObject>();
AssertSymbol<LazySymbol>();
}

// Returns a symbol for an error message.
Expand Down Expand Up @@ -146,7 +146,7 @@ static uint64_t getSymVA(const Symbol &sym, int64_t addend) {
case Symbol::SharedKind:
case Symbol::UndefinedKind:
return 0;
case Symbol::LazyObjectKind:
case Symbol::LazyKind:
llvm_unreachable("lazy symbol reached writer");
case Symbol::CommonKind:
llvm_unreachable("common symbol reached writer");
Expand Down Expand Up @@ -623,7 +623,7 @@ void Symbol::resolve(const Defined &other) {
other.overwrite(*this);
}

void Symbol::resolve(const LazyObject &other) {
void Symbol::resolve(const LazySymbol &other) {
if (isPlaceholder()) {
other.overwrite(*this);
return;
Expand Down
22 changes: 11 additions & 11 deletions lld/ELF/Symbols.h
Expand Up @@ -37,7 +37,7 @@ class InputSectionBase;
class SharedSymbol;
class Symbol;
class Undefined;
class LazyObject;
class LazySymbol;
class InputFile;

void printTraceSymbol(const Symbol &sym, StringRef name);
Expand Down Expand Up @@ -76,7 +76,7 @@ class Symbol {
CommonKind,
SharedKind,
UndefinedKind,
LazyObjectKind,
LazyKind,
};

Kind kind() const { return static_cast<Kind>(symbolKind); }
Expand Down Expand Up @@ -181,7 +181,7 @@ class Symbol {

bool isLocal() const { return binding == llvm::ELF::STB_LOCAL; }

bool isLazy() const { return symbolKind == LazyObjectKind; }
bool isLazy() const { return symbolKind == LazyKind; }

// True if this is an undefined weak symbol. This only works once
// all input files have been added.
Expand Down Expand Up @@ -237,7 +237,7 @@ class Symbol {
void resolve(const Undefined &other);
void resolve(const CommonSymbol &other);
void resolve(const Defined &other);
void resolve(const LazyObject &other);
void resolve(const LazySymbol &other);
void resolve(const SharedSymbol &other);

// If this is a lazy symbol, extract an input file and add the symbol
Expand Down Expand Up @@ -471,7 +471,7 @@ class SharedSymbol : public Symbol {
uint32_t alignment;
};

// LazyObject symbols represent symbols in object files between --start-lib and
// LazySymbol symbols represent symbols in object files between --start-lib and
// --end-lib options. LLD also handles traditional archives as if all the files
// in the archive are surrounded by --start-lib and --end-lib.
//
Expand All @@ -480,14 +480,14 @@ class SharedSymbol : public Symbol {
// and the lazy. We represent that with a lazy symbol with a weak binding. This
// means that code looking for undefined symbols normally also has to take lazy
// symbols into consideration.
class LazyObject : public Symbol {
class LazySymbol : public Symbol {
public:
LazyObject(InputFile &file)
: Symbol(LazyObjectKind, &file, {}, llvm::ELF::STB_GLOBAL,
LazySymbol(InputFile &file)
: Symbol(LazyKind, &file, {}, llvm::ELF::STB_GLOBAL,
llvm::ELF::STV_DEFAULT, llvm::ELF::STT_NOTYPE) {}
void overwrite(Symbol &sym) const { Symbol::overwrite(sym, LazyObjectKind); }
void overwrite(Symbol &sym) const { Symbol::overwrite(sym, LazyKind); }

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

// Some linker-generated symbols need to be created as
Expand Down Expand Up @@ -541,7 +541,7 @@ union SymbolUnion {
alignas(CommonSymbol) char b[sizeof(CommonSymbol)];
alignas(Undefined) char c[sizeof(Undefined)];
alignas(SharedSymbol) char d[sizeof(SharedSymbol)];
alignas(LazyObject) char e[sizeof(LazyObject)];
alignas(LazySymbol) char e[sizeof(LazySymbol)];
};

template <typename... T> Defined *makeDefined(T &&...args) {
Expand Down

0 comments on commit 7071a25

Please sign in to comment.