[lld] r355909 - [LLD][ELF] - Show symbols visibility in "undefined symbol..." error messages.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 04:10:29 PDT 2019
Author: grimar
Date: Tue Mar 12 04:10:29 2019
New Revision: 355909
URL: http://llvm.org/viewvc/llvm-project?rev=355909&view=rev
Log:
[LLD][ELF] - Show symbols visibility in "undefined symbol..." error messages.
This teaches LLD to report visibility when showing undefined symbol errors
and fixes https://bugs.llvm.org/show_bug.cgi?id=40770.
Differential revision: https://reviews.llvm.org/D58577
Modified:
lld/trunk/ELF/Relocations.cpp
lld/trunk/test/ELF/executable-undefined-protected-ignoreall.s
lld/trunk/test/ELF/hidden-shared-err.s
lld/trunk/test/ELF/lto/setting-dso-local.ll
lld/trunk/test/ELF/undef-shared.s
lld/trunk/test/ELF/undef-shared2.s
lld/trunk/test/ELF/warn-unresolved-symbols-hidden.s
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=355909&r1=355908&r2=355909&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Tue Mar 12 04:10:29 2019
@@ -676,8 +676,14 @@ static bool maybeReportUndefined(Symbol
if (Config->UnresolvedSymbols == UnresolvedPolicy::Ignore && CanBeExternal)
return false;
- std::string Msg =
- "undefined symbol: " + toString(Sym) + "\n>>> referenced by ";
+ std::string Msg = "undefined ";
+ if (Sym.Visibility == STV_INTERNAL)
+ Msg += "internal ";
+ else if (Sym.Visibility == STV_HIDDEN)
+ Msg += "hidden ";
+ else if (Sym.Visibility == STV_PROTECTED)
+ Msg += "protected ";
+ Msg += "symbol: " + toString(Sym) + "\n>>> referenced by ";
std::string Src = Sec.getSrcMsg(Sym, Offset);
if (!Src.empty())
Modified: lld/trunk/test/ELF/executable-undefined-protected-ignoreall.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/executable-undefined-protected-ignoreall.s?rev=355909&r1=355908&r2=355909&view=diff
==============================================================================
--- lld/trunk/test/ELF/executable-undefined-protected-ignoreall.s (original)
+++ lld/trunk/test/ELF/executable-undefined-protected-ignoreall.s Tue Mar 12 04:10:29 2019
@@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: not ld.lld %t -o /dev/null --unresolved-symbols=ignore-all -pie 2>&1 | FileCheck %s
-# CHECK: error: undefined symbol: foo
+# CHECK: error: undefined protected symbol: foo
.protected foo
_start:
Modified: lld/trunk/test/ELF/hidden-shared-err.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/hidden-shared-err.s?rev=355909&r1=355908&r2=355909&view=diff
==============================================================================
--- lld/trunk/test/ELF/hidden-shared-err.s (original)
+++ lld/trunk/test/ELF/hidden-shared-err.s Tue Mar 12 04:10:29 2019
@@ -11,7 +11,7 @@
# 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
+# CHECK: undefined hidden symbol: foo
.global _start
_start:
Modified: lld/trunk/test/ELF/lto/setting-dso-local.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/setting-dso-local.ll?rev=355909&r1=355908&r2=355909&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/setting-dso-local.ll (original)
+++ lld/trunk/test/ELF/lto/setting-dso-local.ll Tue Mar 12 04:10:29 2019
@@ -2,7 +2,7 @@
; RUN: llvm-as %s -o %t1.o
; RUN: not ld.lld -o %t %t1.o 2>&1 | FileCheck %s
-; CHECK: undefined symbol: foobar
+; CHECK: undefined hidden symbol: foobar
; We used to crash setting foobar to non-dso_local
Modified: lld/trunk/test/ELF/undef-shared.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/undef-shared.s?rev=355909&r1=355908&r2=355909&view=diff
==============================================================================
--- lld/trunk/test/ELF/undef-shared.s (original)
+++ lld/trunk/test/ELF/undef-shared.s Tue Mar 12 04:10:29 2019
@@ -2,17 +2,17 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s
-# CHECK: error: undefined symbol: hidden
+# CHECK: error: undefined hidden symbol: hidden
# CHECK: >>> referenced by {{.*}}:(.data+0x0)
.global hidden
.hidden hidden
-# CHECK: error: undefined symbol: internal
+# CHECK: error: undefined internal symbol: internal
# CHECK: >>> referenced by {{.*}}:(.data+0x8)
.global internal
.internal internal
-# CHECK: error: undefined symbol: protected
+# CHECK: error: undefined protected symbol: protected
# CHECK: >>> referenced by {{.*}}:(.data+0x10)
.global protected
.protected protected
Modified: lld/trunk/test/ELF/undef-shared2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/undef-shared2.s?rev=355909&r1=355908&r2=355909&view=diff
==============================================================================
--- lld/trunk/test/ELF/undef-shared2.s (original)
+++ lld/trunk/test/ELF/undef-shared2.s Tue Mar 12 04:10:29 2019
@@ -4,7 +4,7 @@
# 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
+# CHECK: error: undefined protected symbol: foo
.data
.quad foo
Modified: lld/trunk/test/ELF/warn-unresolved-symbols-hidden.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/warn-unresolved-symbols-hidden.s?rev=355909&r1=355908&r2=355909&view=diff
==============================================================================
--- lld/trunk/test/ELF/warn-unresolved-symbols-hidden.s (original)
+++ lld/trunk/test/ELF/warn-unresolved-symbols-hidden.s Tue Mar 12 04:10:29 2019
@@ -3,8 +3,8 @@
# RUN: not ld.lld -shared %t.o -o /dev/null -z defs --warn-unresolved-symbols 2>&1| FileCheck %s
# CHECK: warning: undefined symbol: foo
-# CHECK: error: undefined symbol: bar
-# CHECK: error: undefined symbol: zed
+# CHECK: error: undefined hidden symbol: bar
+# CHECK: error: undefined protected symbol: zed
.data
.quad foo
More information about the llvm-commits
mailing list