[PATCH] D31122: [LLD] Add -z nodlopen option

Mark Kettenis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 19 03:46:52 PDT 2017


kettenis created this revision.

Add -z nodlopen option.  This option sets the DF_1_NOOPEN flag, indicating that the generated DSO should not be dlopen'ed.

This option is used by one of the OpenBSD regression tests to check if the flag is respected by our dynamic linker.


https://reviews.llvm.org/D31122

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/SyntheticSections.cpp
  test/ELF/dt_flags.s


Index: test/ELF/dt_flags.s
===================================================================
--- test/ELF/dt_flags.s
+++ test/ELF/dt_flags.s
@@ -2,19 +2,19 @@
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 # RUN: ld.lld -shared %t -o %t.so
-# RUN: ld.lld -z now -z nodelete -z origin -Bsymbolic %t %t.so -o %t1
+# RUN: ld.lld -z now -z nodelete -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
 # RUN: ld.lld %t %t.so -o %t2
 # RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s
 # RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s
 
 # FLAGS: DynamicSection [
 # FLAGS:   0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# FLAGS:   0x000000006FFFFFFB FLAGS_1 NOW NODELETE ORIGIN
+# FLAGS:   0x000000006FFFFFFB FLAGS_1 NOW NODELETE NOOPEN ORIGIN
 # FLAGS: ]
 
 # CHECK: DynamicSection [
 # CHECK-NOT:   0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# CHECK-NOT:   0x000000006FFFFFFB FLAGS_1 NOW NODELETE ORIGIN
+# CHECK-NOT:   0x000000006FFFFFFB FLAGS_1 NOW NODELETE NOOPEN ORIGIN
 # CHECK: ]
 
 .globl _start
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1051,6 +1051,8 @@
     DtFlags |= DF_SYMBOLIC;
   if (Config->ZNodelete)
     DtFlags1 |= DF_1_NODELETE;
+  if (Config->ZNodlopen)
+    DtFlags1 |= DF_1_NOOPEN;
   if (Config->ZNow) {
     DtFlags |= DF_BIND_NOW;
     DtFlags1 |= DF_1_NOW;
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -602,6 +602,7 @@
   Config->ZExecstack = hasZOption(Args, "execstack");
   Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc");
   Config->ZNodelete = hasZOption(Args, "nodelete");
+  Config->ZNodlopen = hasZOption(Args, "nodlopen");
   Config->ZNow = hasZOption(Args, "now");
   Config->ZOrigin = hasZOption(Args, "origin");
   Config->ZRelro = !hasZOption(Args, "norelro");
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -141,6 +141,7 @@
   bool ZExecstack;
   bool ZNocopyreloc;
   bool ZNodelete;
+  bool ZNodlopen;
   bool ZNow;
   bool ZOrigin;
   bool ZRelro;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31122.92269.patch
Type: text/x-patch
Size: 2250 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170319/fc7997f1/attachment.bin>


More information about the llvm-commits mailing list