[lld] r298167 - Define Config::isLE and Config::wordsize.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 17 16:28:41 PDT 2017
Author: ruiu
Date: Fri Mar 17 18:28:41 2017
New Revision: 298167
URL: http://llvm.org/viewvc/llvm-project?rev=298167&view=rev
Log:
Define Config::isLE and Config::wordsize.
isLE() return true if the target is little-endian.
wordsize() returns 8 for 64-bit and 4 for 32-bit.
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/EhFrame.cpp
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=298167&r1=298166&r2=298167&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Mar 17 18:28:41 2017
@@ -168,6 +168,12 @@ struct Configuration {
// Returns true if target is 64 bit.
bool is64() const { return EKind == ELF64LEKind || EKind == ELF64BEKind; }
+ // Returns true if the target is little endian.
+ bool isLE() const { return EKind == ELF32LEKind || EKind == ELF64LEKind; }
+
+ // Returns 4 or 8 for ELF32 or ELF64, respectively.
+ int wordsize() const { return is64() ? 8 : 4; }
+
// The ELF spec defines two types of relocation table entries, RELA and
// REL. RELA is a triplet of (offset, info, addend) while REL is a
// tuple of (offset, info). Addends for REL are implicit and read from
Modified: lld/trunk/ELF/EhFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/EhFrame.cpp?rev=298167&r1=298166&r2=298167&view=diff
==============================================================================
--- lld/trunk/ELF/EhFrame.cpp (original)
+++ lld/trunk/ELF/EhFrame.cpp Fri Mar 17 18:28:41 2017
@@ -127,7 +127,7 @@ template <class ELFT> static size_t getA
switch (Enc & 0x0f) {
case DW_EH_PE_absptr:
case DW_EH_PE_signed:
- return ELFT::Is64Bits ? 8 : 4;
+ return Config->wordsize();
case DW_EH_PE_udata2:
case DW_EH_PE_sdata2:
return 2;
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=298167&r1=298166&r2=298167&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Mar 17 18:28:41 2017
@@ -81,8 +81,7 @@ template <class ELFT> void elf::ObjectFi
DWARFContextInMemory Dwarf(*Obj, &ObjInfo);
DwarfLine.reset(new DWARFDebugLine(&Dwarf.getLineSection().Relocs));
DataExtractor LineData(Dwarf.getLineSection().Data,
- ELFT::TargetEndianness == support::little,
- ELFT::Is64Bits ? 8 : 4);
+ Config->isLE(), Config->wordsize());
// The second parameter is offset in .debug_line section
// for compilation unit (CU) of interest. We have only one
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=298167&r1=298166&r2=298167&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Fri Mar 17 18:28:41 2017
@@ -950,7 +950,7 @@ void GotPltSection::writeTo(uint8_t *Buf
Buf += Target->GotPltHeaderEntriesNum * Target->GotPltEntrySize;
for (const SymbolBody *B : Entries) {
Target->writeGotPlt(Buf, *B);
- Buf += Config->is64() ? 8 : 4;
+ Buf += Config->wordsize();
}
}
@@ -974,7 +974,7 @@ size_t IgotPltSection::getSize() const {
void IgotPltSection::writeTo(uint8_t *Buf) {
for (const SymbolBody *B : Entries) {
Target->writeIgotPlt(Buf, *B);
- Buf += Config->is64() ? 8 : 4;
+ Buf += Config->wordsize();
}
}
@@ -2194,7 +2194,7 @@ size_t MergeSyntheticSection::getSize()
MipsRldMapSection::MipsRldMapSection()
: SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
- Config->is64() ? 8 : 4, ".rld_map") {}
+ Config->wordsize(), ".rld_map") {}
void MipsRldMapSection::writeTo(uint8_t *Buf) {
// Apply filler from linker script.
@@ -2226,7 +2226,7 @@ void ARMExidxSentinelSection<ELFT>::writ
ThunkSection::ThunkSection(OutputSection *OS, uint64_t Off)
: SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS,
- Config->is64() ? 8 : 4, ".text.thunk") {
+ Config->wordsize(), ".text.thunk") {
this->OutSec = OS;
this->OutSecOff = Off;
}
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=298167&r1=298166&r2=298167&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Fri Mar 17 18:28:41 2017
@@ -718,7 +718,7 @@ private:
class MipsRldMapSection : public SyntheticSection {
public:
MipsRldMapSection();
- size_t getSize() const override { return Config->is64() ? 8 : 4; }
+ size_t getSize() const override { return Config->wordsize(); }
void writeTo(uint8_t *Buf) override;
};
More information about the llvm-commits
mailing list