[PATCH] D13883: [ELF2] Correctly set bits when -z now is specified
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 19 17:53:05 PDT 2015
davide created this revision.
davide added reviewers: ruiu, rafael, grimar.
davide added a subscriber: llvm-commits.
The option now just sets NOW bit in DT_FLAGS_1 but some loaders (e.g. FreeBSD) seem to requier also BIND_NOW bit to be set in DT_FLAGS. This is, also, what ld.bfd and gold do.
http://reviews.llvm.org/D13883
Files:
ELF/OutputSections.cpp
test/elf2/dt_flags.s
Index: test/elf2/dt_flags.s
===================================================================
--- test/elf2/dt_flags.s
+++ test/elf2/dt_flags.s
@@ -8,12 +8,12 @@
# RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s
# FLAGS: DynamicSection [
-# FLAGS: 0x000000000000001E FLAGS SYMBOLIC
+# FLAGS: 0x000000000000001E FLAGS SYMBOLIC BIND_NOW
# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE
# FLAGS: ]
# CHECK: DynamicSection [
-# CHECK-NOT: 0x000000000000001E FLAGS SYMBOLIC
+# CHECK-NOT: 0x000000000000001E FLAGS SYMBOLIC BIND_NOW
# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE
# CHECK: ]
Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ ELF/OutputSections.cpp
@@ -294,7 +294,7 @@
++NumEntries; // DT_INIT
if (FiniSym)
++NumEntries; // DT_FINI
- if (Config->Bsymbolic)
+ if (Config->Bsymbolic || Config->ZNow)
++NumEntries; // DT_FLAGS
if (Config->ZNodelete || Config->ZNow)
++NumEntries; // DT_FLAGS_1
@@ -371,6 +371,8 @@
uint32_t Flags = 0;
if (Config->Bsymbolic)
Flags |= DF_SYMBOLIC;
+ if (Config->ZNow)
+ Flags |= DF_BIND_NOW;
if (Flags)
WriteVal(DT_FLAGS, Flags);
Flags = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13883.37821.patch
Type: text/x-patch
Size: 1247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151020/929e7ce5/attachment.bin>
More information about the llvm-commits
mailing list