[lld] [LLD][COFF] Process all live import symbols in getSymbols() (PR #109117)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 05:19:22 PDT 2024
================
@@ -122,16 +122,9 @@ static void getSymbols(const COFFLinkerContext &ctx,
if (!file->live)
continue;
- if (!file->thunkSym)
- continue;
-
- if (!file->thunkSym->isLive())
- continue;
-
- syms.push_back(thunkSym);
-
- if (auto *impSym = dyn_cast_or_null<Defined>(file->impSym))
- syms.push_back(impSym);
+ syms.push_back(file->impSym);
----------------
mstorsjo wrote:
I asked about this in https://github.com/llvm/llvm-project/pull/108459#discussion_r1758748174 before, but I didn't quite grasp the response then, but now I understand.
So if we have another object file referencing e.g. `__imp_func` (which is an undefined reference from the scope of that object file, originally), that defined symbol will get picked up and added to the list of symbols to include in the loop above, looping over `ctx.objFileInstances`.
That's why a regular reference to `__imp_func`, without referencing `func` at all, would have been listed in the map file just fine. But if we pull in `__imp_func` via an `-export:` option, it isn't so we need to include it here. Now I get it!
https://github.com/llvm/llvm-project/pull/109117
More information about the llvm-commits
mailing list