summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Writer.cpp9
-rw-r--r--lld/test/ELF/undef-shared.s14
2 files changed, 21 insertions, 2 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6f42386dde2..0f82ef62487 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -730,8 +730,13 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &S,
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))
diff --git a/lld/test/ELF/undef-shared.s b/lld/test/ELF/undef-shared.s
new file mode 100644
index 00000000000..ea7f06e5d36
--- /dev/null
+++ b/lld/test/ELF/undef-shared.s
@@ -0,0 +1,14 @@
+# 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
OpenPOWER on IntegriCloud