[LLD][COFF][NFC] Store impSym as DefinedImportData in ImportFile. (#107162)

This commit is contained in:
Jacek Caban 2024-09-04 11:49:50 +02:00 committed by GitHub
parent d25e24a0eb
commit 519b36925c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 6 deletions

View File

@ -1059,8 +1059,7 @@ void ImportFile::parse() {
// address pointed by the __imp_ symbol. (This allows you to call
// DLL functions just like regular non-DLL functions.)
if (hdr->getType() == llvm::COFF::IMPORT_CODE)
thunkSym = ctx.symtab.addImportThunk(
name, cast_or_null<DefinedImportData>(impSym), hdr->Machine);
thunkSym = ctx.symtab.addImportThunk(name, impSym, hdr->Machine);
}
BitcodeFile::BitcodeFile(COFFLinkerContext &ctx, MemoryBufferRef mb,

View File

@ -346,7 +346,7 @@ public:
static bool classof(const InputFile *f) { return f->kind() == ImportKind; }
MachineTypes getMachineType() const override;
Symbol *impSym = nullptr;
DefinedImportData *impSym = nullptr;
Symbol *thunkSym = nullptr;
std::string dllName;

View File

@ -771,12 +771,12 @@ Symbol *SymbolTable::addCommon(InputFile *f, StringRef n, uint64_t size,
return s;
}
Symbol *SymbolTable::addImportData(StringRef n, ImportFile *f) {
DefinedImportData *SymbolTable::addImportData(StringRef n, ImportFile *f) {
auto [s, wasInserted] = insert(n, nullptr);
s->isUsedInRegularObj = true;
if (wasInserted || isa<Undefined>(s) || s->isLazy()) {
replaceSymbol<DefinedImportData>(s, n, f);
return s;
return cast<DefinedImportData>(s);
}
reportDuplicate(s, f);

View File

@ -102,7 +102,7 @@ public:
Symbol *addCommon(InputFile *f, StringRef n, uint64_t size,
const llvm::object::coff_symbol_generic *s = nullptr,
CommonChunk *c = nullptr);
Symbol *addImportData(StringRef n, ImportFile *f);
DefinedImportData *addImportData(StringRef n, ImportFile *f);
Symbol *addImportThunk(StringRef name, DefinedImportData *s,
uint16_t machine);
void addLibcall(StringRef name);