[ELF] Reword --no-allow-shlib-undefined diagnostic

Use a format more similar to unresolved references from regular object
files. It's probably easier to read for people who are less familiar
with the linker diagnostics.

Reviewed By: ikudrin

Differential Revision: https://reviews.llvm.org/D129790
This commit is contained in:
Fangrui Song 2022-07-15 01:29:58 -07:00
parent ae15e6a952
commit 51b9e099d5
4 changed files with 10 additions and 7 deletions

View File

@ -1973,8 +1973,8 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
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));
}
}

View File

@ -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

View File

@ -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 | \

View File

@ -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