[lld] [LLD][COFF] Fix handling of weak aliases referencing lazy symbols (PR #112243)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 14 12:41:50 PDT 2024


================
@@ -112,20 +112,20 @@ DefinedImportThunk::DefinedImportThunk(COFFLinkerContext &ctx, StringRef name,
                                        ImportThunkChunk *chunk)
     : Defined(DefinedImportThunkKind, name), wrappedSym(s), data(chunk) {}
 
-Defined *Undefined::getWeakAlias() {
+Symbol *Undefined::getWeakAlias() {
   // A weak alias may be a weak alias to another symbol, so check recursively.
   DenseSet<Symbol *> weakChain;
   for (Symbol *a = weakAlias; a; a = cast<Undefined>(a)->weakAlias) {
----------------
mstorsjo wrote:

So... previously, this `cast<Undefined>(a)` was broken (invoking UB etc), if we had a weak alias which pointed at something which wasn't either `Undefined` or `Defined`?

https://github.com/llvm/llvm-project/pull/112243


More information about the llvm-commits mailing list