Skip to content

[LLD][COFF] Store __imp_ symbols as Defined in InputFile #109115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lld/COFF/InputFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class ImportFile : public InputFile {
MachineTypes getMachineType() const override;

DefinedImportData *impSym = nullptr;
Symbol *thunkSym = nullptr;
Defined *thunkSym = nullptr;
ImportThunkChunkARM64EC *impchkThunk = nullptr;
std::string dllName;

Expand All @@ -365,7 +365,7 @@ class ImportFile : public InputFile {
// Auxiliary IAT symbols and chunks on ARM64EC.
DefinedImportData *impECSym = nullptr;
Chunk *auxLocation = nullptr;
Symbol *auxThunkSym = nullptr;
Defined *auxThunkSym = nullptr;
DefinedImportData *auxImpCopySym = nullptr;
Chunk *auxCopyLocation = nullptr;

Expand Down
3 changes: 1 addition & 2 deletions lld/COFF/MapFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ static void getSymbols(const COFFLinkerContext &ctx,
if (!file->thunkSym->isLive())
continue;

if (auto *thunkSym = dyn_cast<Defined>(file->thunkSym))
syms.push_back(thunkSym);
syms.push_back(file->thunkSym);

if (auto *impSym = dyn_cast_or_null<Defined>(file->impSym))
syms.push_back(impSym);
Expand Down
6 changes: 3 additions & 3 deletions lld/COFF/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,13 @@ DefinedImportData *SymbolTable::addImportData(StringRef n, ImportFile *f,
return nullptr;
}

Symbol *SymbolTable::addImportThunk(StringRef name, DefinedImportData *id,
ImportThunkChunk *chunk) {
Defined *SymbolTable::addImportThunk(StringRef name, DefinedImportData *id,
ImportThunkChunk *chunk) {
auto [s, wasInserted] = insert(name, nullptr);
s->isUsedInRegularObj = true;
if (wasInserted || isa<Undefined>(s) || s->isLazy()) {
replaceSymbol<DefinedImportThunk>(s, ctx, name, id, chunk);
return s;
return cast<Defined>(s);
}

reportDuplicate(s, id->file);
Expand Down
4 changes: 2 additions & 2 deletions lld/COFF/SymbolTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class SymbolTable {
CommonChunk *c = nullptr);
DefinedImportData *addImportData(StringRef n, ImportFile *f,
Chunk *&location);
Symbol *addImportThunk(StringRef name, DefinedImportData *s,
ImportThunkChunk *chunk);
Defined *addImportThunk(StringRef name, DefinedImportData *s,
ImportThunkChunk *chunk);
void addLibcall(StringRef name);
void addEntryThunk(Symbol *from, Symbol *to);
void addExitThunk(Symbol *from, Symbol *to);
Expand Down
Loading