diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1973,8 +1973,8 @@ continue; for (Symbol *sym : file->requiredSymbols) if (sym->isUndefined() && !sym->isWeak()) - diagnose(toString(file) + ": undefined reference to " + - toString(*sym) + " [--no-allow-shlib-undefined]"); + diagnose("undefined reference due to --no-allow-shlib-undefined: " + + toString(*sym) + "\n>>> referenced by " + toString(file)); } } diff --git a/lld/test/ELF/allow-shlib-undefined.s b/lld/test/ELF/allow-shlib-undefined.s --- a/lld/test/ELF/allow-shlib-undefined.s +++ b/lld/test/ELF/allow-shlib-undefined.s @@ -41,6 +41,9 @@ _start: callq _shared@PLT -# CHECK: error: {{.*}}.so: undefined reference to _unresolved [--no-allow-shlib-undefined] -# CHECK2: error: {{.*}}2.so: undefined reference to _unresolved [--no-allow-shlib-undefined] -# WARN: warning: {{.*}}.so: undefined reference to _unresolved [--no-allow-shlib-undefined] +# CHECK: error: undefined reference due to --no-allow-shlib-undefined: _unresolved +# CHECK-NEXT: >>> referenced by {{.*}}.so +# CHECK2: error: undefined reference due to --no-allow-shlib-undefined: _unresolved +# CHECK2-NEXT: >>> referenced by {{.*}}2.so +# WARN: warning: undefined reference due to --no-allow-shlib-undefined: _unresolved +# WARN-NEXT: >>> referenced by {{.*}}.so diff --git a/lld/test/ELF/unresolved-symbols.s b/lld/test/ELF/unresolved-symbols.s --- a/lld/test/ELF/unresolved-symbols.s +++ b/lld/test/ELF/unresolved-symbols.s @@ -36,7 +36,7 @@ ## --unresolved-symbols overrides a previous --allow-shlib-undefined. # RUN: not ld.lld %t1.o %t.so -o /dev/null --allow-shlib-undefined --unresolved-symbols=ignore-in-object-files 2>&1 | FileCheck %s --check-prefix=SHLIB -# SHLIB: error: {{.*}}.so: undefined reference to undef [--no-allow-shlib-undefined] +# SHLIB: error: undefined reference due to --no-allow-shlib-undefined: undef ## Ignoring undefines in shared should produce error for symbol from object. # RUN: not ld.lld %t2.o -o /dev/null --unresolved-symbols=ignore-in-shared-libs 2>&1 | \ diff --git a/lld/test/ELF/wrap-shlib-undefined.s b/lld/test/ELF/wrap-shlib-undefined.s --- a/lld/test/ELF/wrap-shlib-undefined.s +++ b/lld/test/ELF/wrap-shlib-undefined.s @@ -17,7 +17,7 @@ ## --no-allow-shlib-undefined errors because __real_foo is not defined. # RUN: not ld.lld %t/main.o %t/bar.so -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s -# ERR: {{.*}}.so: undefined reference to __real_foo [--no-allow-shlib-undefined] +# ERR: error: undefined reference due to --no-allow-shlib-undefined: __real_foo ## --wrap=foo defines __real_foo. # RUN: ld.lld %t/main.o %t/bar.so --wrap=foo -o %t2