[lld] r250914 - ELF2: Simplify DT_FLAGS{,_1} handling. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 21 10:47:10 PDT 2015
Author: ruiu
Date: Wed Oct 21 12:47:10 2015
New Revision: 250914
URL: http://llvm.org/viewvc/llvm-project?rev=250914&view=rev
Log:
ELF2: Simplify DT_FLAGS{,_1} handling. NFC.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=250914&r1=250913&r2=250914&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Oct 21 12:47:10 2015
@@ -159,11 +159,12 @@ void LinkerDriver::createFiles(opt::Inpu
Config->Undefined.push_back(Arg->getValue());
for (auto *Arg : Args.filtered(OPT_z)) {
- if (Arg->getValue() == StringRef("nodelete"))
+ StringRef S = Arg->getValue();
+ if (S == "nodelete")
Config->ZNodelete = true;
- else if (Arg->getValue() == StringRef("now"))
+ else if (S == "now")
Config->ZNow = true;
- else if (Arg->getValue() == StringRef("origin"))
+ else if (S == "origin")
Config->ZOrigin = true;
}
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250914&r1=250913&r2=250914&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Oct 21 12:47:10 2015
@@ -349,9 +349,23 @@ template <class ELFT> void DynamicSectio
++NumEntries; // DT_INIT
if (FiniSym)
++NumEntries; // DT_FINI
- if (Config->Bsymbolic || Config->ZNow || Config->ZOrigin)
+
+ if (Config->Bsymbolic)
+ DtFlags |= DF_SYMBOLIC;
+ if (Config->ZNodelete)
+ DtFlags1 |= DF_1_NODELETE;
+ if (Config->ZNow) {
+ DtFlags |= DF_BIND_NOW;
+ DtFlags1 |= DF_1_NOW;
+ }
+ if (Config->ZOrigin) {
+ DtFlags |= DF_ORIGIN;
+ DtFlags1 |= DF_1_ORIGIN;
+ }
+
+ if (DtFlags)
++NumEntries; // DT_FLAGS
- if (Config->ZNodelete || Config->ZNow || Config->ZOrigin)
+ if (DtFlags1)
++NumEntries; // DT_FLAGS_1
++NumEntries; // DT_NULL
@@ -428,26 +442,10 @@ template <class ELFT> void DynamicSectio
WritePtr(DT_INIT, getSymVA<ELFT>(*InitSym));
if (FiniSym)
WritePtr(DT_FINI, getSymVA<ELFT>(*FiniSym));
-
- uint32_t Flags = 0;
- if (Config->Bsymbolic)
- Flags |= DF_SYMBOLIC;
- if (Config->ZNow)
- Flags |= DF_BIND_NOW;
- if (Config->ZOrigin)
- Flags |= DF_ORIGIN;
- if (Flags)
- WriteVal(DT_FLAGS, Flags);
- Flags = 0;
- if (Config->ZNodelete)
- Flags |= DF_1_NODELETE;
- if (Config->ZNow)
- Flags |= DF_1_NOW;
- if (Config->ZOrigin)
- Flags |= DF_1_ORIGIN;
- if (Flags)
- WriteVal(DT_FLAGS_1, Flags);
-
+ if (DtFlags)
+ WriteVal(DT_FLAGS, DtFlags);
+ if (DtFlags1)
+ WriteVal(DT_FLAGS_1, DtFlags1);
WriteVal(DT_NULL, 0);
}
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=250914&r1=250913&r2=250914&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Wed Oct 21 12:47:10 2015
@@ -305,6 +305,8 @@ private:
SymbolTable<ELFT> &SymTab;
const ELFSymbolBody<ELFT> *InitSym = nullptr;
const ELFSymbolBody<ELFT> *FiniSym = nullptr;
+ uint32_t DtFlags = 0;
+ uint32_t DtFlags1 = 0;
};
// All output sections that are hadnled by the linker specially are
More information about the llvm-commits
mailing list