[PATCH] D57569: [ELF] Default to --no-allow-shlib-undefined for executables
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 1 15:31:30 PST 2019
MaskRay updated this revision to Diff 184861.
MaskRay added a comment.
Update docs/ld.lld.1
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57569/new/
https://reviews.llvm.org/D57569
Files:
ELF/Driver.cpp
docs/ld.lld.1
test/ELF/allow-shlib-undefined.s
test/ELF/unresolved-symbols.s
Index: test/ELF/unresolved-symbols.s
===================================================================
--- test/ELF/unresolved-symbols.s
+++ test/ELF/unresolved-symbols.s
@@ -27,21 +27,21 @@
# ERRUND: >>> referenced by {{.*}}:(.text+0x1)
## Also ignore all should not produce error for symbols from DSOs.
-# RUN: ld.lld %t1.o %t.so -o %t1_3 --unresolved-symbols=ignore-all
+# RUN: ld.lld %t1.o %t.so -o %t1_3 --allow-shlib-undefined --unresolved-symbols=ignore-all
# RUN: llvm-readobj %t1_3 > /dev/null 2>&1
## Ignoring undefines in objects should not produce error for symbol from object.
# RUN: ld.lld %t1.o %t2.o -o %t2 --unresolved-symbols=ignore-in-object-files
# RUN: llvm-readobj %t2 > /dev/null 2>&1
## And still should not should produce for undefines from DSOs.
-# RUN: ld.lld %t1.o %t.so -o /dev/null --unresolved-symbols=ignore-in-object-files
+# RUN: ld.lld %t1.o %t.so -o /dev/null --allow-shlib-undefined --unresolved-symbols=ignore-in-object-files
# RUN: llvm-readobj %t2 > /dev/null 2>&1
## 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 | \
# RUN: FileCheck -check-prefix=ERRUND %s
## And should not produce errors for symbols from DSO.
-# RUN: ld.lld %t1.o %t.so -o %t3_1 --unresolved-symbols=ignore-in-shared-libs
+# RUN: ld.lld %t1.o %t.so -o %t3_1 --allow-shlib-undefined --unresolved-symbols=ignore-in-shared-libs
# RUN: llvm-readobj %t3_1 > /dev/null 2>&1
## Ignoring undefines in shared libs should not produce error for symbol from object
Index: test/ELF/allow-shlib-undefined.s
===================================================================
--- test/ELF/allow-shlib-undefined.s
+++ test/ELF/allow-shlib-undefined.s
@@ -6,9 +6,12 @@
# RUN: %p/Inputs/allow-shlib-undefined.s -o %t1.o
# RUN: ld.lld -shared %t1.o -o %t.so
-# RUN: ld.lld %t.o %t.so -o /dev/null
# RUN: ld.lld --allow-shlib-undefined %t.o %t.so -o /dev/null
# 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
+# -shared defaults to --allow-shlib-undefined
+# RUN: ld.lld -shared %t.o %t.so -o /dev/null
# RUN: echo | llvm-mc -filetype=obj -triple=x86_64-unknown-linux -o %tempty.o
# RUN: ld.lld -shared %tempty.o -o %tempty.so
Index: docs/ld.lld.1
===================================================================
--- docs/ld.lld.1
+++ docs/ld.lld.1
@@ -46,6 +46,9 @@
.It Fl -allow-multiple-definition
Do not error if a symbol is defined multiple times.
The first definition will be used.
+.It Fl -allow-shlib-undefined
+Allow unresolved references in shared libraries.
+This option is enabled by default when linking an shared library.
.It Fl -apply-dynamic-relocs
Apply link-time values for dynamic relocations.
.It Fl -as-needed
@@ -242,6 +245,9 @@
.It Fl -Map Ns = Ns Ar file , Fl M Ar file
Print a link map to
.Ar file .
+.It Fl -no-allow-shlib-undefined
+Do not allow unresolved references in shared libraries.
+This option is enabled by default when linking an executable.
.It Fl -no-as-needed
Always set
.Dv DT_NEEDED
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -756,8 +756,9 @@
Args.hasFlag(OPT_allow_multiple_definition,
OPT_no_allow_multiple_definition, false) ||
hasZOption(Args, "muldefs");
- Config->AllowShlibUndefined = Args.hasFlag(
- OPT_allow_shlib_undefined, OPT_no_allow_shlib_undefined, true);
+ Config->AllowShlibUndefined =
+ Args.hasFlag(OPT_allow_shlib_undefined, OPT_no_allow_shlib_undefined,
+ Args.hasArg(OPT_shared));
Config->AuxiliaryList = args::getStrings(Args, OPT_auxiliary);
Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic);
Config->BsymbolicFunctions = Args.hasArg(OPT_Bsymbolic_functions);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57569.184861.patch
Type: text/x-patch
Size: 3998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190201/4f8da47b/attachment.bin>
More information about the llvm-commits
mailing list