Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -676,8 +676,16 @@ if (Config->UnresolvedSymbols == UnresolvedPolicy::Ignore && CanBeExternal) return false; - std::string Msg = - "undefined symbol: " + toString(Sym) + "\n>>> referenced by "; + std::string Visibility = " "; + if (Sym.Visibility == STV_INTERNAL) + Visibility = " internal "; + else if (Sym.Visibility == STV_HIDDEN) + Visibility = " hidden "; + else if (Sym.Visibility == STV_PROTECTED) + Visibility = " protected "; + + std::string Msg = "undefined" + Visibility + "symbol: " + toString(Sym) + + "\n>>> referenced by "; std::string Src = Sec.getSrcMsg(Sym, Offset); if (!Src.empty()) Index: test/ELF/executable-undefined-protected-ignoreall.s =================================================================== --- test/ELF/executable-undefined-protected-ignoreall.s +++ test/ELF/executable-undefined-protected-ignoreall.s @@ -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: Index: test/ELF/hidden-shared-err.s =================================================================== --- test/ELF/hidden-shared-err.s +++ test/ELF/hidden-shared-err.s @@ -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: Index: test/ELF/lto/setting-dso-local.ll =================================================================== --- test/ELF/lto/setting-dso-local.ll +++ test/ELF/lto/setting-dso-local.ll @@ -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 Index: test/ELF/undef-shared.s =================================================================== --- test/ELF/undef-shared.s +++ test/ELF/undef-shared.s @@ -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 Index: test/ELF/undef-shared2.s =================================================================== --- test/ELF/undef-shared2.s +++ test/ELF/undef-shared2.s @@ -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 Index: test/ELF/warn-unresolved-symbols-hidden.s =================================================================== --- test/ELF/warn-unresolved-symbols-hidden.s +++ test/ELF/warn-unresolved-symbols-hidden.s @@ -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