Fix another case we were using the wrong visibility.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 16 Jan 2018 18:21:23 +0000 (18:21 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 16 Jan 2018 18:21:23 +0000 (18:21 +0000)
llvm-svn: 322580

lld/ELF/Relocations.cpp
lld/test/ELF/Inputs/undef-shared2.s [new file with mode: 0644]
lld/test/ELF/undef-shared2.s [new file with mode: 0644]

index acd6b62..1b956c4 100644 (file)
@@ -613,7 +613,7 @@ static bool maybeReportUndefined(Symbol &Sym, InputSectionBase &Sec,
     return false;
 
   bool CanBeExternal =
-      Sym.computeBinding() != STB_LOCAL && Sym.getVisibility() == STV_DEFAULT;
+      Sym.computeBinding() != STB_LOCAL && Sym.Visibility == STV_DEFAULT;
   if (Config->UnresolvedSymbols == UnresolvedPolicy::Ignore && CanBeExternal)
     return false;
 
diff --git a/lld/test/ELF/Inputs/undef-shared2.s b/lld/test/ELF/Inputs/undef-shared2.s
new file mode 100644 (file)
index 0000000..8742073
--- /dev/null
@@ -0,0 +1,2 @@
+.data
+.quad foo
diff --git a/lld/test/ELF/undef-shared2.s b/lld/test/ELF/undef-shared2.s
new file mode 100644 (file)
index 0000000..3c53040
--- /dev/null
@@ -0,0 +1,10 @@
+# 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/undef-shared2.s -o %t2.o
+# RUN: not ld.lld %t.o %t2.o -o %t.so -shared 2>&1 | FileCheck %s
+# RUN: not ld.lld %t2.o %t.o -o %t.so -shared 2>&1 | FileCheck %s
+
+# CHECK: error: undefined symbol: foo
+
+.data
+.quad foo
+.protected foo