diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1980,7 +1980,8 @@ if (sym->isUndefined() && !sym->isWeak()) if (auto *f = dyn_cast_or_null(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- 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 @@ -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@PLT -# CHECK: undefined reference to _unresolved +# CHECK: {{.*}}.so: undefined reference to _unresolved [--no-allow-shlib-undefined] 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 @@ -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: {{.*}}.so: 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