[PATCH] D81028: [ELF] Append " [--no-allow-shlib-undefined]" to the corresponding diagnostics
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 2 13:10:45 PDT 2020
MaskRay created this revision.
MaskRay added reviewers: grimar, psmith, ruiu, thakis.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
--no-allow-shlib-undefined (enabled by default when linking an
executable) rejects unresolved references in shared objects.
Users may be confuse it with the common diagnostics of unresolved symbols in
object files (LLD: "undefined symbol: foo"; GNU ld/gold: "undefined reference to")
Learn from GCC/clang " [-Wfoo]": append the option name to the
diagnostics. Users can find relevant information by searching
"--no-allow-shlib-undefined". It should also be obvious to them that
the positive form --allow-shlib-undefined can suppress the error.
Also downgrade the error to a warning if --noinhibit-exec is used (compatible
with GNU ld and gold).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81028
Files:
lld/ELF/Writer.cpp
lld/test/ELF/allow-shlib-undefined.s
lld/test/ELF/wrap-shlib-undefined.s
Index: lld/test/ELF/wrap-shlib-undefined.s
===================================================================
--- lld/test/ELF/wrap-shlib-undefined.s
+++ lld/test/ELF/wrap-shlib-undefined.s
@@ -6,7 +6,7 @@
## --no-allow-shlib-undefined errors because __real_foo is not defined.
# RUN: not ld.lld %t.o %t.so -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
-# ERR: undefined reference to __real_foo
+# ERR: undefined reference to __real_foo [--no-allow-shlib-undefined]
## --wrap=foo defines __real_foo.
# RUN: ld.lld %t.o %t.so --wrap=foo -o %t
Index: lld/test/ELF/allow-shlib-undefined.s
===================================================================
--- lld/test/ELF/allow-shlib-undefined.s
+++ lld/test/ELF/allow-shlib-undefined.s
@@ -9,6 +9,7 @@
# RUN: not ld.lld --no-allow-shlib-undefined %t.o %t.so -o /dev/null 2>&1 | FileCheck %s
# Executable defaults to --no-allow-shlib-undefined
# RUN: not ld.lld %t.o %t.so -o /dev/null 2>&1 | FileCheck %s
+# RUN: ld.lld %t.o %t.so --noinhibit-exec -o /dev/null 2>&1 | FileCheck %s
# -shared defaults to --allow-shlib-undefined
# RUN: ld.lld -shared %t.o %t.so -o /dev/null
@@ -27,4 +28,4 @@
_start:
callq _shared at PLT
-# CHECK: undefined reference to _unresolved
+# CHECK: {{.*}}.so: undefined reference to _unresolved [--no-allow-shlib-undefined]
Index: lld/ELF/Writer.cpp
===================================================================
--- lld/ELF/Writer.cpp
+++ lld/ELF/Writer.cpp
@@ -1980,7 +1980,8 @@
if (sym->isUndefined() && !sym->isWeak())
if (auto *f = dyn_cast_or_null<SharedFile>(sym->file))
if (f->allNeededIsKnown)
- error(toString(f) + ": undefined reference to " + toString(*sym));
+ errorOrWarn(toString(f) + ": undefined reference to " +
+ toString(*sym) + " [--no-allow-shlib-undefined]");
}
// Now that we have defined all possible global symbols including linker-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81028.267961.patch
Type: text/x-patch
Size: 1945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200602/09c0719c/attachment.bin>
More information about the llvm-commits
mailing list