[PATCH] D48329: [ELF] Support -z initfirst

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 19 19:10:43 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL335090: [ELF] Support -z initfirst (authored by MaskRay, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D48329

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


Index: lld/trunk/test/ELF/dt_flags.s
===================================================================
--- lld/trunk/test/ELF/dt_flags.s
+++ lld/trunk/test/ELF/dt_flags.s
@@ -3,7 +3,7 @@
 # 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 nodlopen -z origin -Bsymbolic %t %t.so -o %t1
+# RUN: ld.lld -z initfirst -z now -z nodelete -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
 # RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s
 
 # RUN: ld.lld %t %t.so -o %t2
@@ -14,12 +14,12 @@
 
 # FLAGS: DynamicSection [
 # FLAGS:   0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# FLAGS:   0x000000006FFFFFFB FLAGS_1 NOW NODELETE NOOPEN ORIGIN
+# FLAGS:   0x000000006FFFFFFB FLAGS_1 NOW NODELETE INITFIRST NOOPEN ORIGIN
 # FLAGS: ]
 
 # CHECK: DynamicSection [
-# CHECK-NOT:   0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# CHECK-NOT:   0x000000006FFFFFFB FLAGS_1 NOW NODELETE NOOPEN ORIGIN
+# CHECK-NOT:   FLAGS
+# CHECK-NOT:   FLAGS_1
 # CHECK: ]
 
 .globl _start
Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -784,6 +784,7 @@
   Config->ZCopyreloc = getZFlag(Args, "copyreloc", "nocopyreloc", true);
   Config->ZExecstack = getZFlag(Args, "execstack", "noexecstack", false);
   Config->ZHazardplt = hasZOption(Args, "hazardplt");
+  Config->ZInitfirst = hasZOption(Args, "initfirst");
   Config->ZKeepTextSectionPrefix = getZFlag(
       Args, "keep-text-section-prefix", "nokeep-text-section-prefix", false);
   Config->ZNodelete = hasZOption(Args, "nodelete");
Index: lld/trunk/ELF/SyntheticSections.cpp
===================================================================
--- lld/trunk/ELF/SyntheticSections.cpp
+++ lld/trunk/ELF/SyntheticSections.cpp
@@ -1239,6 +1239,8 @@
   uint32_t DtFlags1 = 0;
   if (Config->Bsymbolic)
     DtFlags |= DF_SYMBOLIC;
+  if (Config->ZInitfirst)
+    DtFlags1 |= DF_1_INITFIRST;
   if (Config->ZNodelete)
     DtFlags1 |= DF_1_NODELETE;
   if (Config->ZNodlopen)
Index: lld/trunk/ELF/Config.h
===================================================================
--- lld/trunk/ELF/Config.h
+++ lld/trunk/ELF/Config.h
@@ -172,6 +172,7 @@
   bool ZCopyreloc;
   bool ZExecstack;
   bool ZHazardplt;
+  bool ZInitfirst;
   bool ZKeepTextSectionPrefix;
   bool ZNodelete;
   bool ZNodlopen;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48329.152015.patch
Type: text/x-patch
Size: 2461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180620/7d2f6a92/attachment.bin>


More information about the llvm-commits mailing list