Skip to content

Commit

Permalink
[ELF] Reword --no-allow-shlib-undefined diagnostic
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MaskRay committed Jul 15, 2022
1 parent ae15e6a commit 51b9e09
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lld/ELF/Writer.cpp
Expand Up @@ -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));
}
}

Expand Down
9 changes: 6 additions & 3 deletions lld/test/ELF/allow-shlib-undefined.s
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lld/test/ELF/unresolved-symbols.s
Expand Up @@ -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 | \
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/wrap-shlib-undefined.s
Expand Up @@ -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
Expand Down

0 comments on commit 51b9e09

Please sign in to comment.