forked from OSchip/llvm-project
[Hexagon][Mips] Rename template arguments <arch>ELFType to ELFT
In all other ELF related classes we use `ELFT` abbreviation. llvm-svn: 234088
This commit is contained in:
parent
a5f1ae1ad0
commit
1649aea9c6
|
@ -17,11 +17,10 @@ namespace elf {
|
|||
typedef llvm::object::ELFType<llvm::support::little, 2, false> HexagonELFType;
|
||||
class HexagonLinkingContext;
|
||||
|
||||
template <class HexagonELFType> class HexagonRuntimeFile
|
||||
: public RuntimeFile<HexagonELFType> {
|
||||
template <class ELFT> class HexagonRuntimeFile : public RuntimeFile<ELFT> {
|
||||
public:
|
||||
HexagonRuntimeFile(HexagonLinkingContext &ctx)
|
||||
: RuntimeFile<HexagonELFType>(ctx, "Hexagon runtime file") {}
|
||||
: RuntimeFile<ELFT>(ctx, "Hexagon runtime file") {}
|
||||
};
|
||||
} // elf
|
||||
} // lld
|
||||
|
|
|
@ -17,13 +17,11 @@ template <typename ELFT> class HexagonTargetLayout;
|
|||
class HexagonLinkingContext;
|
||||
|
||||
/// \brief Handle Hexagon SData section
|
||||
template <class HexagonELFType>
|
||||
class SDataSection : public AtomSection<HexagonELFType> {
|
||||
template <class ELFT> class SDataSection : public AtomSection<ELFT> {
|
||||
public:
|
||||
SDataSection(const HexagonLinkingContext &ctx)
|
||||
: AtomSection<HexagonELFType>(
|
||||
ctx, ".sdata", DefinedAtom::typeDataFast, 0,
|
||||
HexagonTargetLayout<HexagonELFType>::ORDER_SDATA) {
|
||||
: AtomSection<ELFT>(ctx, ".sdata", DefinedAtom::typeDataFast, 0,
|
||||
HexagonTargetLayout<ELFT>::ORDER_SDATA) {
|
||||
this->_type = SHT_PROGBITS;
|
||||
this->_flags = SHF_ALLOC | SHF_WRITE;
|
||||
this->_alignment = 4096;
|
||||
|
@ -49,8 +47,7 @@ public:
|
|||
|
||||
}; // SDataSection
|
||||
|
||||
template <class HexagonELFType>
|
||||
void SDataSection<HexagonELFType>::doPreFlight() {
|
||||
template <class ELFT> void SDataSection<ELFT>::doPreFlight() {
|
||||
// sort the atoms on the alignments they have been set
|
||||
std::stable_sort(this->_atoms.begin(), this->_atoms.end(),
|
||||
[](const lld::AtomLayout * A,
|
||||
|
|
|
@ -22,28 +22,28 @@ namespace elf {
|
|||
class HexagonLinkingContext;
|
||||
|
||||
/// \brief TargetLayout for Hexagon
|
||||
template <class HexagonELFType>
|
||||
class HexagonTargetLayout final : public TargetLayout<HexagonELFType> {
|
||||
template <class ELFT>
|
||||
class HexagonTargetLayout final : public TargetLayout<ELFT> {
|
||||
public:
|
||||
enum HexagonSectionOrder {
|
||||
ORDER_SDATA = 205
|
||||
};
|
||||
|
||||
HexagonTargetLayout(HexagonLinkingContext &hti)
|
||||
: TargetLayout<HexagonELFType>(hti), _sdataSection() {
|
||||
_sdataSection = new (_alloc) SDataSection<HexagonELFType>(hti);
|
||||
: TargetLayout<ELFT>(hti), _sdataSection() {
|
||||
_sdataSection = new (_alloc) SDataSection<ELFT>(hti);
|
||||
}
|
||||
|
||||
/// \brief Return the section order for a input section
|
||||
typename TargetLayout<HexagonELFType>::SectionOrder
|
||||
typename TargetLayout<ELFT>::SectionOrder
|
||||
getSectionOrder(StringRef name, int32_t contentType,
|
||||
int32_t contentPermissions) override {
|
||||
if ((contentType == DefinedAtom::typeDataFast) ||
|
||||
(contentType == DefinedAtom::typeZeroFillFast))
|
||||
return ORDER_SDATA;
|
||||
|
||||
return TargetLayout<HexagonELFType>::getSectionOrder(name, contentType,
|
||||
contentPermissions);
|
||||
return TargetLayout<ELFT>::getSectionOrder(name, contentType,
|
||||
contentPermissions);
|
||||
}
|
||||
|
||||
/// \brief Return the appropriate input section name.
|
||||
|
@ -55,34 +55,31 @@ public:
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return TargetLayout<HexagonELFType>::getInputSectionName(da);
|
||||
return TargetLayout<ELFT>::getInputSectionName(da);
|
||||
}
|
||||
|
||||
/// \brief Gets or creates a section.
|
||||
AtomSection<HexagonELFType> *
|
||||
createSection(StringRef name, int32_t contentType,
|
||||
DefinedAtom::ContentPermissions contentPermissions,
|
||||
typename TargetLayout<HexagonELFType>::SectionOrder
|
||||
sectionOrder) override {
|
||||
AtomSection<ELFT> *createSection(
|
||||
StringRef name, int32_t contentType,
|
||||
DefinedAtom::ContentPermissions contentPermissions,
|
||||
typename TargetLayout<ELFT>::SectionOrder sectionOrder) override {
|
||||
if ((contentType == DefinedAtom::typeDataFast) ||
|
||||
(contentType == DefinedAtom::typeZeroFillFast))
|
||||
return _sdataSection;
|
||||
return TargetLayout<HexagonELFType>::createSection(
|
||||
name, contentType, contentPermissions, sectionOrder);
|
||||
return TargetLayout<ELFT>::createSection(name, contentType,
|
||||
contentPermissions, sectionOrder);
|
||||
}
|
||||
|
||||
/// \brief get the segment type for the section thats defined by the target
|
||||
typename TargetLayout<HexagonELFType>::SegmentType
|
||||
getSegmentType(Section<HexagonELFType> *section) const override {
|
||||
typename TargetLayout<ELFT>::SegmentType
|
||||
getSegmentType(Section<ELFT> *section) const override {
|
||||
if (section->order() == ORDER_SDATA)
|
||||
return PT_LOAD;
|
||||
|
||||
return TargetLayout<HexagonELFType>::getSegmentType(section);
|
||||
return TargetLayout<ELFT>::getSegmentType(section);
|
||||
}
|
||||
|
||||
Section<HexagonELFType> *getSDataSection() const {
|
||||
return _sdataSection;
|
||||
}
|
||||
Section<ELFT> *getSDataSection() const { return _sdataSection; }
|
||||
|
||||
uint64_t getGOTSymAddr() {
|
||||
if (!_gotSymAtom.hasValue())
|
||||
|
@ -94,7 +91,7 @@ public:
|
|||
|
||||
private:
|
||||
llvm::BumpPtrAllocator _alloc;
|
||||
SDataSection<HexagonELFType> *_sdataSection = nullptr;
|
||||
SDataSection<ELFT> *_sdataSection = nullptr;
|
||||
llvm::Optional<AtomLayout *> _gotSymAtom;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,21 +15,19 @@
|
|||
namespace lld {
|
||||
namespace elf {
|
||||
|
||||
template <class ELFType> class MipsTargetLayout;
|
||||
template <class ELFT> class MipsTargetLayout;
|
||||
|
||||
template <class MipsELFType>
|
||||
class MipsDynamicTable : public DynamicTable<MipsELFType> {
|
||||
template <class ELFT> class MipsDynamicTable : public DynamicTable<ELFT> {
|
||||
public:
|
||||
MipsDynamicTable(const ELFLinkingContext &ctx,
|
||||
MipsTargetLayout<MipsELFType> &layout)
|
||||
: DynamicTable<MipsELFType>(ctx, layout, ".dynamic",
|
||||
TargetLayout<MipsELFType>::ORDER_DYNAMIC),
|
||||
MipsDynamicTable(const ELFLinkingContext &ctx, MipsTargetLayout<ELFT> &layout)
|
||||
: DynamicTable<ELFT>(ctx, layout, ".dynamic",
|
||||
TargetLayout<ELFT>::ORDER_DYNAMIC),
|
||||
_targetLayout(layout) {}
|
||||
|
||||
void createDefaultEntries() override {
|
||||
DynamicTable<MipsELFType>::createDefaultEntries();
|
||||
DynamicTable<ELFT>::createDefaultEntries();
|
||||
|
||||
typename DynamicTable<MipsELFType>::Elf_Dyn dyn;
|
||||
typename DynamicTable<ELFT>::Elf_Dyn dyn;
|
||||
|
||||
// Version id for the Runtime Linker Interface.
|
||||
dyn.d_un.d_val = 1;
|
||||
|
@ -69,7 +67,7 @@ public:
|
|||
}
|
||||
|
||||
void updateDynamicTable() override {
|
||||
DynamicTable<MipsELFType>::updateDynamicTable();
|
||||
DynamicTable<ELFT>::updateDynamicTable();
|
||||
|
||||
// Assign the minimum segment address to the DT_MIPS_BASE_ADDRESS tag.
|
||||
auto baseAddr = std::numeric_limits<uint64_t>::max();
|
||||
|
@ -106,7 +104,7 @@ private:
|
|||
std::size_t _dt_gotsym;
|
||||
std::size_t _dt_pltgot;
|
||||
std::size_t _dt_baseaddr;
|
||||
MipsTargetLayout<MipsELFType> &_targetLayout;
|
||||
MipsTargetLayout<ELFT> &_targetLayout;
|
||||
};
|
||||
|
||||
} // end namespace elf
|
||||
|
|
|
@ -16,12 +16,12 @@ template <typename ELFT> class MipsTargetLayout;
|
|||
class MipsLinkingContext;
|
||||
|
||||
/// \brief Handle Mips GOT section
|
||||
template <class ELFType> class MipsGOTSection : public AtomSection<ELFType> {
|
||||
template <class ELFT> class MipsGOTSection : public AtomSection<ELFT> {
|
||||
public:
|
||||
MipsGOTSection(const MipsLinkingContext &ctx)
|
||||
: AtomSection<ELFType>(ctx, ".got", DefinedAtom::typeGOT,
|
||||
DefinedAtom::permRW_,
|
||||
MipsTargetLayout<ELFType>::ORDER_GOT),
|
||||
: AtomSection<ELFT>(ctx, ".got", DefinedAtom::typeGOT,
|
||||
DefinedAtom::permRW_,
|
||||
MipsTargetLayout<ELFT>::ORDER_GOT),
|
||||
_hasNonLocal(false), _localCount(0) {
|
||||
this->_flags |= SHF_MIPS_GPREL;
|
||||
this->_alignment = 4;
|
||||
|
@ -60,14 +60,14 @@ public:
|
|||
case LLD_R_MIPS_GLOBAL_GOT:
|
||||
_hasNonLocal = true;
|
||||
_posMap[r->target()] = _posMap.size();
|
||||
return AtomSection<ELFType>::appendAtom(atom);
|
||||
return AtomSection<ELFT>::appendAtom(atom);
|
||||
case R_MIPS_TLS_TPREL32:
|
||||
case R_MIPS_TLS_DTPREL32:
|
||||
case R_MIPS_TLS_TPREL64:
|
||||
case R_MIPS_TLS_DTPREL64:
|
||||
_hasNonLocal = true;
|
||||
_tlsMap[r->target()] = _tlsMap.size();
|
||||
return AtomSection<ELFType>::appendAtom(atom);
|
||||
return AtomSection<ELFT>::appendAtom(atom);
|
||||
case R_MIPS_TLS_DTPMOD32:
|
||||
case R_MIPS_TLS_DTPMOD64:
|
||||
_hasNonLocal = true;
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
if (!_hasNonLocal)
|
||||
++_localCount;
|
||||
|
||||
return AtomSection<ELFType>::appendAtom(atom);
|
||||
return AtomSection<ELFT>::appendAtom(atom);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -96,12 +96,12 @@ private:
|
|||
};
|
||||
|
||||
/// \brief Handle Mips PLT section
|
||||
template <class ELFType> class MipsPLTSection : public AtomSection<ELFType> {
|
||||
template <class ELFT> class MipsPLTSection : public AtomSection<ELFT> {
|
||||
public:
|
||||
MipsPLTSection(const MipsLinkingContext &ctx)
|
||||
: AtomSection<ELFType>(ctx, ".plt", DefinedAtom::typeGOT,
|
||||
DefinedAtom::permR_X,
|
||||
MipsTargetLayout<ELFType>::ORDER_PLT) {}
|
||||
: AtomSection<ELFT>(ctx, ".plt", DefinedAtom::typeGOT,
|
||||
DefinedAtom::permR_X,
|
||||
MipsTargetLayout<ELFT>::ORDER_PLT) {}
|
||||
|
||||
const AtomLayout *findPLTLayout(const Atom *plt) const {
|
||||
auto it = _pltLayoutMap.find(plt);
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
}
|
||||
|
||||
const lld::AtomLayout *appendAtom(const Atom *atom) override {
|
||||
const auto *layout = AtomSection<ELFType>::appendAtom(atom);
|
||||
const auto *layout = AtomSection<ELFT>::appendAtom(atom);
|
||||
|
||||
const DefinedAtom *da = cast<DefinedAtom>(atom);
|
||||
|
||||
|
|
Loading…
Reference in New Issue