Index: ELF/Symbols.cpp =================================================================== --- ELF/Symbols.cpp +++ ELF/Symbols.cpp @@ -410,6 +410,10 @@ if (Traced) printTraceSymbol(&Other); + // Ignore undefined symbols in a SharedFile. + if (isa_and_nonnull(Other.File)) + return; + if (isUndefined()) { // The binding may "upgrade" from weak to non-weak. if (Other.Binding != STB_WEAK) Index: test/ELF/weak-undef-shared.s =================================================================== --- test/ELF/weak-undef-shared.s +++ test/ELF/weak-undef-shared.s @@ -24,6 +24,11 @@ # RUN: ld.lld %t2.o %t.so %t1.o -o %t # RUN: llvm-readelf --dyn-syms %t | FileCheck --check-prefix=GLOBAL %s +## Check the binding (weak) is not affected by the STB_GLOBAL undefined +## reference in %t2.so +# RUN: ld.lld %t1.o %t2.so -o %t +# RUN: llvm-readelf --dyn-syms %t | FileCheck --check-prefix=WEAK %s + # WEAK: NOTYPE WEAK DEFAULT UND foo # GLOBAL: NOTYPE GLOBAL DEFAULT UND foo