[PATCH] D13468: [ELF2] -z now option implemented

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 7 08:02:12 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL249551: [ELF2] -z now option implemented (authored by grimar).

Changed prior to commit:
  http://reviews.llvm.org/D13468?vs=36710&id=36746#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13468

Files:
  lld/trunk/ELF/Config.h
  lld/trunk/ELF/Driver.cpp
  lld/trunk/ELF/Options.td
  lld/trunk/ELF/OutputSections.cpp
  lld/trunk/test/elf2/now.s

Index: lld/trunk/ELF/Config.h
===================================================================
--- lld/trunk/ELF/Config.h
+++ lld/trunk/ELF/Config.h
@@ -44,6 +44,7 @@
   bool ExportDynamic;
   bool NoInhibitExec;
   bool NoUndefined;
+  bool ZNow = false;
   bool Shared;
   bool Static = false;
   bool WholeArchive = false;
Index: lld/trunk/ELF/OutputSections.cpp
===================================================================
--- lld/trunk/ELF/OutputSections.cpp
+++ lld/trunk/ELF/OutputSections.cpp
@@ -269,6 +269,8 @@
     ++NumEntries; // DT_INIT
   if (FiniSym)
     ++NumEntries; // DT_FINI
+  if (Config->ZNow)
+    ++NumEntries; // DT_FLAGS_1
 
   ++NumEntries; // DT_NULL
 
@@ -341,6 +343,9 @@
   if (FiniSym)
     WritePtr(DT_FINI, getSymVA(*FiniSym, BssSec));
 
+  if (Config->ZNow)
+    WriteVal(DT_FLAGS_1, DF_1_NOW);
+
   WriteVal(DT_NULL, 0);
 }
 
Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -186,6 +186,11 @@
   Config->NoUndefined = Args.hasArg(OPT_no_undefined);
   Config->Shared = Args.hasArg(OPT_shared);
 
+  for (auto *Arg : Args.filtered(OPT_z)) {
+    if (Arg->getValue() == StringRef("now"))
+      Config->ZNow = true;
+  }
+
   for (auto *Arg : Args) {
     switch (Arg->getOption().getID()) {
     case OPT_l:
Index: lld/trunk/ELF/Options.td
===================================================================
--- lld/trunk/ELF/Options.td
+++ lld/trunk/ELF/Options.td
@@ -82,6 +82,9 @@
 def whole_archive : Flag<["--"], "whole-archive">,
   HelpText<"Force load of all members in a static library">;
 
+def z : JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
+  HelpText<"Linker option extensions">;
+
 // Aliases
 def alias_Bdynamic_call_shared: Flag<["-"], "call_shared">, Alias<Bdynamic>;
 def alias_Bdynamic_dy: Flag<["-"], "dy">, Alias<Bdynamic>;
@@ -114,4 +117,3 @@
 def start_group : Flag<["--"], "start-group">;
 def strip_all : Flag<["--"], "strip-all">;
 def version_script : Separate<["--"], "version-script">;
-def z : Separate<["-"], "z">;
Index: lld/trunk/test/elf2/now.s
===================================================================
--- lld/trunk/test/elf2/now.s
+++ lld/trunk/test/elf2/now.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: lld -flavor gnu2 -shared %t -o %t.so
+# RUN: lld -flavor gnu2 -z now %t %t.so -o %t1
+# RUN: lld -flavor gnu2 %t %t.so -o %t2
+# RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=NOW %s
+# RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s
+
+# NOW: DynamicSection [
+# NOW:   0x000000006FFFFFFB FLAGS_1 NOW
+# NOW: ]
+
+# CHECK: DynamicSection [
+# CHECK-NOT:   0x000000006FFFFFFB FLAGS_1 NOW
+# CHECK: ]
+
+.globl _start
+_start:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13468.36746.patch
Type: text/x-patch
Size: 2835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151007/243e04f8/attachment.bin>


More information about the llvm-commits mailing list