Skip to content

Commit 870bf55

Browse files
authored
[LLD][COFF] Handle manually defined __imp_ pointers in LTO
1 parent 0044198 commit 870bf55

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lld/COFF/InputFiles.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,12 @@ void BitcodeFile::parse() {
10591059
} else {
10601060
sym = ctx.symtab.addRegular(this, symName, nullptr, fakeSC, 0,
10611061
objSym.isWeak());
1062+
// Model all symbols with the __imp_ prefix as having external
1063+
// references. If one LTO object defines a __imp_<foo> symbol, and
1064+
// another LTO object refers to <foo> with dllimport, make sure the
1065+
// __imp_ symbol is kept.
1066+
if (symName.starts_with("__imp_"))
1067+
sym->isUsedInRegularObj = true;
10621068
}
10631069
symbols.push_back(sym);
10641070
if (objSym.isUsed())

0 commit comments

Comments
 (0)