template <class ELFT>
static void reportUndefined(SymbolTable<ELFT> &Symtab, SymbolBody *Sym) {
- if ((Config->Relocatable || Config->Shared) && !Config->NoUndefined)
- return;
+ if (!Config->NoUndefined) {
+ if (Config->Relocatable)
+ return;
+ if (Config->Shared)
+ if (Sym->Backref->Visibility == STV_DEFAULT)
+ return;
+ }
std::string Msg = "undefined symbol: " + Sym->getName().str();
if (InputFile *File = Symtab.findFile(Sym))
--- /dev/null
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
+
+# CHECK: undefined symbol: hidden in {{.*}}
+.global hidden
+.hidden hidden
+
+# CHECK: undefined symbol: internal in {{.*}}
+.global internal
+.internal internal
+
+# CHECK: undefined symbol: protected in {{.*}}
+.global protected
+.protected protected