[lld] r250771 - [ELF2] Introduce support for -z nodelete.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 19 17:20:21 PDT 2015
Author: davide
Date: Mon Oct 19 19:20:20 2015
New Revision: 250771
URL: http://llvm.org/viewvc/llvm-project?rev=250771&view=rev
Log:
[ELF2] Introduce support for -z nodelete.
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/OutputSections.cpp
lld/trunk/test/elf2/dt_flags.s
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=250771&r1=250770&r2=250771&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Mon Oct 19 19:20:20 2015
@@ -57,6 +57,7 @@ struct Configuration {
bool Shared;
bool Static = false;
bool Verbose;
+ bool ZNodelete = false;
bool ZNow = false;
ELFKind EKind = ELFNoneKind;
uint16_t EMachine = llvm::ELF::EM_NONE;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=250771&r1=250770&r2=250771&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon Oct 19 19:20:20 2015
@@ -158,9 +158,13 @@ void LinkerDriver::createFiles(opt::Inpu
for (auto *Arg : Args.filtered(OPT_undefined))
Config->Undefined.push_back(Arg->getValue());
- for (auto *Arg : Args.filtered(OPT_z))
- if (Arg->getValue() == StringRef("now"))
+ // FIXME: Group -z options together in Config.
+ for (auto *Arg : Args.filtered(OPT_z)) {
+ if (Arg->getValue() == StringRef("nodelete"))
+ Config->ZNodelete = true;
+ else if (Arg->getValue() == StringRef("now"))
Config->ZNow = true;
+ }
for (auto *Arg : Args) {
switch (Arg->getOption().getID()) {
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250771&r1=250770&r2=250771&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon Oct 19 19:20:20 2015
@@ -296,7 +296,7 @@ template <class ELFT> void DynamicSectio
++NumEntries; // DT_FINI
if (Config->Bsymbolic)
++NumEntries; // DT_FLAGS
- if (Config->ZNow)
+ if (Config->ZNodelete || Config->ZNow)
++NumEntries; // DT_FLAGS_1
++NumEntries; // DT_NULL
@@ -374,6 +374,8 @@ template <class ELFT> void DynamicSectio
if (Flags)
WriteVal(DT_FLAGS, Flags);
Flags = 0;
+ if (Config->ZNodelete)
+ Flags |= DF_1_NODELETE;
if (Config->ZNow)
Flags |= DF_1_NOW;
if (Flags)
Modified: lld/trunk/test/elf2/dt_flags.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/dt_flags.s?rev=250771&r1=250770&r2=250771&view=diff
==============================================================================
--- lld/trunk/test/elf2/dt_flags.s (original)
+++ lld/trunk/test/elf2/dt_flags.s Mon Oct 19 19:20:20 2015
@@ -9,12 +9,12 @@
# FLAGS: DynamicSection [
# FLAGS: 0x000000000000001E FLAGS SYMBOLIC
-# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW
+# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE
# FLAGS: ]
# CHECK: DynamicSection [
# CHECK-NOT: 0x000000000000001E FLAGS SYMBOLIC
-# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW
+# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE
# CHECK: ]
.globl _start
More information about the llvm-commits
mailing list