[lld] 51b9e09 - [ELF] Reword --no-allow-shlib-undefined diagnostic

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 15 01:30:05 PDT 2022


Author: Fangrui Song
Date: 2022-07-15T01:29:58-07:00
New Revision: 51b9e099d50d95fbda5d067f5b3d0984f5afff44

URL: https://github.com/llvm/llvm-project/commit/51b9e099d50d95fbda5d067f5b3d0984f5afff44
DIFF: https://github.com/llvm/llvm-project/commit/51b9e099d50d95fbda5d067f5b3d0984f5afff44.diff

LOG: [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

Added: 
    

Modified: 
    lld/ELF/Writer.cpp
    lld/test/ELF/allow-shlib-undefined.s
    lld/test/ELF/unresolved-symbols.s
    lld/test/ELF/wrap-shlib-undefined.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 705cc7bf97661..2994e79cd1de2 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -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));
     }
   }
 

diff  --git a/lld/test/ELF/allow-shlib-undefined.s b/lld/test/ELF/allow-shlib-undefined.s
index 4c0e06e5d0092..515fa618e7bee 100644
--- a/lld/test/ELF/allow-shlib-undefined.s
+++ b/lld/test/ELF/allow-shlib-undefined.s
@@ -41,6 +41,9 @@
 _start:
   callq _shared at 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
index ac7279c1a7bda..68fe1e7065a84 100644
--- 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
index b5546a678aca1..96c4629cb497e 100644
--- 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


        


More information about the llvm-commits mailing list