[PATCH] D13468: [ELF2] -z now option implemented
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 00:47:56 PDT 2015
grimar updated this revision to Diff 36710.
grimar added a comment.
All review comments addressed.
http://reviews.llvm.org/D13468
Files:
ELF/Config.h
ELF/Driver.cpp
ELF/Options.td
ELF/OutputSections.cpp
test/elf2/now.s
Index: test/elf2/now.s
===================================================================
--- test/elf2/now.s
+++ 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:
Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ 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: ELF/Options.td
===================================================================
--- ELF/Options.td
+++ ELF/Options.td
@@ -79,6 +79,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>;
@@ -112,4 +115,3 @@
def start_group : Flag<["--"], "start-group">;
def strip_all : Flag<["--"], "strip-all">;
def version_script : Separate<["--"], "version-script">;
-def z : Separate<["-"], "z">;
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -136,6 +136,12 @@
Config->NoUndefined = Args.hasArg(OPT_no_undefined);
Config->Shared = Args.hasArg(OPT_shared);
+ for (auto *Arg : Args.filtered(OPT_z)) {
+ StringRef Opt = Arg->getValue();
+ if (Opt == "now")
+ Config->ZNow = true;
+ }
+
for (auto *Arg : Args) {
switch (Arg->getOption().getID()) {
case OPT_l:
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -35,6 +35,7 @@
bool ExportDynamic;
bool NoInhibitExec;
bool NoUndefined;
+ bool ZNow = false;
bool Shared;
bool Static = false;
bool WholeArchive = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13468.36710.patch
Type: text/x-patch
Size: 2700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151007/bda28ffd/attachment.bin>
More information about the llvm-commits
mailing list