[lld] [LLD] [COFF] Make weak aliases to implementations take priority over null pointers (PR #190491)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 14:29:47 PDT 2026
================
@@ -88,10 +88,16 @@ static void checkAndSetWeakAlias(SymbolTable &symtab, InputFile *f,
// Weak aliases as produced by GCC are named in the form
// .weak.<weaksymbol>.<othersymbol>, where <othersymbol> is the name
// of another symbol emitted near the weak symbol.
- // Just use the definition from the first object file that defined
- // this weak symbol.
- if (symtab.ctx.config.allowDuplicateWeak)
+ if (symtab.ctx.config.allowDuplicateWeak) {
+ // If the alias we had points at absolute zero, and we get another
+ // weak symbol which isn't absolute, prefer that one.
+ if (isa<DefinedAbsolute>(u->weakAlias) &&
+ dyn_cast<DefinedAbsolute>(u->weakAlias)->getVA() == 0 &&
+ !isa<DefinedAbsolute>(target)) {
----------------
mstorsjo wrote:
Right, that also probably sounds reasonable. I can update the code to make it do that as well, but I'm not sure if it is warranted to actually add a testcase for that as well, or what do you think?
https://github.com/llvm/llvm-project/pull/190491
More information about the llvm-commits
mailing list