diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 652b0e83b849..9af0bbdec837 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -488,8 +488,8 @@ void SymbolTable::addShared(StringRef Name, SharedFile &File, // An undefined symbol with non default visibility must be satisfied // in the same DSO. - if (WasInserted || ((S->isUndefined() || S->isLazy()) && - S->getVisibility() == STV_DEFAULT)) { + if (WasInserted || + ((S->isUndefined() || S->isLazy()) && S->Visibility == STV_DEFAULT)) { uint8_t Binding = S->Binding; replaceSymbol(S, File, Name, Sym.getBinding(), Sym.st_other, Sym.getType(), Sym.st_value, Sym.st_size, diff --git a/lld/test/ELF/Inputs/hidden-shared-err2.s b/lld/test/ELF/Inputs/hidden-shared-err2.s new file mode 100644 index 000000000000..aedd19d396fb --- /dev/null +++ b/lld/test/ELF/Inputs/hidden-shared-err2.s @@ -0,0 +1 @@ +.quad foo diff --git a/lld/test/ELF/hidden-shared-err.s b/lld/test/ELF/hidden-shared-err.s index 923f5f9666a2..e6d424c24824 100644 --- a/lld/test/ELF/hidden-shared-err.s +++ b/lld/test/ELF/hidden-shared-err.s @@ -2,10 +2,15 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/hidden-shared-err.s -o %t2.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/hidden-shared-err2.s -o %t3.o + # RUN: ld.lld -shared -o %t2.so %t2.o # RUN: not ld.lld %t.o %t2.so -o %t 2>&1 | FileCheck %s # RUN: not ld.lld %t2.so %t.o -o %t 2>&1 | FileCheck %s +# RUN: not ld.lld %t.o %t3.o %t2.so -o %t 2>&1 | FileCheck %s +# RUN: not ld.lld %t3.o %t.o %t2.so -o %t 2>&1 | FileCheck %s + # CHECK: undefined symbol: foo .global _start