[PATCH] D20169: [ELF] implemented -z defs option
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 06:49:13 PDT 2016
grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: grimar, llvm-commits.
Just do not allow to link shared library if there are
undefined symbols.
This fixes PR27447
http://reviews.llvm.org/D20169
Files:
ELF/Config.h
ELF/Driver.cpp
ELF/Writer.cpp
test/ELF/zdefs.s
Index: test/ELF/zdefs.s
===================================================================
--- test/ELF/zdefs.s
+++ test/ELF/zdefs.s
@@ -0,0 +1,7 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld -shared %t.o -o %t1.so
+
+# RUN: not ld.lld -z defs -shared %t.o -o %t1.so 2>&1 | FileCheck -check-prefix=ERR %s
+# ERR: undefined symbol: foo
+
+callq foo at PLT
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -793,7 +793,7 @@
if (!Config->NoUndefined) {
if (Config->Relocatable)
return;
- if (Config->Shared)
+ if (Config->Shared && !Config->ZDefs)
if (Sym->symbol()->Visibility == STV_DEFAULT)
return;
}
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -353,6 +353,7 @@
error("number of threads must be > 0");
Config->ZCombreloc = !hasZOption(Args, "nocombreloc");
+ Config->ZDefs = hasZOption(Args, "defs");
Config->ZExecStack = hasZOption(Args, "execstack");
Config->ZNodelete = hasZOption(Args, "nodelete");
Config->ZNow = hasZOption(Args, "now");
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -89,6 +89,7 @@
bool VersionScript = false;
bool WarnCommon;
bool ZCombreloc;
+ bool ZDefs;
bool ZExecStack;
bool ZNodelete;
bool ZNow;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20169.56902.patch
Type: text/x-patch
Size: 1490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160511/26a33359/attachment.bin>
More information about the llvm-commits
mailing list