[lld] r250799 - [ELF2] Correctly set bits when -z now is specified.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 19 21:58:40 PDT 2015
Author: davide
Date: Mon Oct 19 23:58:40 2015
New Revision: 250799
URL: http://llvm.org/viewvc/llvm-project?rev=250799&view=rev
Log:
[ELF2] Correctly set bits when -z now is specified.
The option now just sets NOW bit in DT_FLAGS_1 but some loaders
seem to require also BIND_NOW bit to be set in DT_FLAGS. This is,
also, what ld.bfd and gold do.
Differential Revision: http://reviews.llvm.org/D13883
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/test/elf2/dt_flags.s
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250799&r1=250798&r2=250799&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon Oct 19 23:58:40 2015
@@ -294,7 +294,7 @@ template <class ELFT> void DynamicSectio
++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 @@ template <class ELFT> void DynamicSectio
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;
Modified: lld/trunk/test/elf2/dt_flags.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/dt_flags.s?rev=250799&r1=250798&r2=250799&view=diff
==============================================================================
--- lld/trunk/test/elf2/dt_flags.s (original)
+++ lld/trunk/test/elf2/dt_flags.s Mon Oct 19 23:58:40 2015
@@ -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: ]
More information about the llvm-commits
mailing list