forked from OSchip/llvm-project
[ELF] Add some Mips*Section to InStruct and change make<Mips*Section> to std::make_unique
Similar to D116143. My x86-64 lld executable is 20+KiB smaller.
This commit is contained in:
parent
c0b986aa0c
commit
988a03c585
|
@ -100,7 +100,7 @@ template <class ELFT> void MipsAbiFlagsSection<ELFT>::writeTo(uint8_t *buf) {
|
|||
}
|
||||
|
||||
template <class ELFT>
|
||||
MipsAbiFlagsSection<ELFT> *MipsAbiFlagsSection<ELFT>::create() {
|
||||
std::unique_ptr<MipsAbiFlagsSection<ELFT>> MipsAbiFlagsSection<ELFT>::create() {
|
||||
Elf_Mips_ABIFlags flags = {};
|
||||
bool create = false;
|
||||
|
||||
|
@ -142,7 +142,7 @@ MipsAbiFlagsSection<ELFT> *MipsAbiFlagsSection<ELFT>::create() {
|
|||
};
|
||||
|
||||
if (create)
|
||||
return make<MipsAbiFlagsSection<ELFT>>(flags);
|
||||
return std::make_unique<MipsAbiFlagsSection<ELFT>>(flags);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ template <class ELFT> void MipsOptionsSection<ELFT>::writeTo(uint8_t *buf) {
|
|||
}
|
||||
|
||||
template <class ELFT>
|
||||
MipsOptionsSection<ELFT> *MipsOptionsSection<ELFT>::create() {
|
||||
std::unique_ptr<MipsOptionsSection<ELFT>> MipsOptionsSection<ELFT>::create() {
|
||||
// N64 ABI only.
|
||||
if (!ELFT::Is64Bits)
|
||||
return nullptr;
|
||||
|
@ -204,7 +204,7 @@ MipsOptionsSection<ELFT> *MipsOptionsSection<ELFT>::create() {
|
|||
}
|
||||
};
|
||||
|
||||
return make<MipsOptionsSection<ELFT>>(reginfo);
|
||||
return std::make_unique<MipsOptionsSection<ELFT>>(reginfo);
|
||||
}
|
||||
|
||||
// MIPS .reginfo section.
|
||||
|
@ -222,7 +222,7 @@ template <class ELFT> void MipsReginfoSection<ELFT>::writeTo(uint8_t *buf) {
|
|||
}
|
||||
|
||||
template <class ELFT>
|
||||
MipsReginfoSection<ELFT> *MipsReginfoSection<ELFT>::create() {
|
||||
std::unique_ptr<MipsReginfoSection<ELFT>> MipsReginfoSection<ELFT>::create() {
|
||||
// Section should be alive for O32 and N32 ABIs only.
|
||||
if (ELFT::Is64Bits)
|
||||
return nullptr;
|
||||
|
@ -249,7 +249,7 @@ MipsReginfoSection<ELFT> *MipsReginfoSection<ELFT>::create() {
|
|||
sec->getFile<ELFT>()->mipsGp0 = r->ri_gp_value;
|
||||
};
|
||||
|
||||
return make<MipsReginfoSection<ELFT>>(reginfo);
|
||||
return std::make_unique<MipsReginfoSection<ELFT>>(reginfo);
|
||||
}
|
||||
|
||||
InputSection *elf::createInterpSection() {
|
||||
|
@ -3813,7 +3813,10 @@ void InStruct::reset() {
|
|||
gotPlt.reset();
|
||||
igotPlt.reset();
|
||||
ppc64LongBranchTarget.reset();
|
||||
mipsAbiFlags.reset();
|
||||
mipsGot.reset();
|
||||
mipsOptions.reset();
|
||||
mipsReginfo.reset();
|
||||
mipsRldMap.reset();
|
||||
partEnd.reset();
|
||||
partIndex.reset();
|
||||
|
|
|
@ -980,7 +980,7 @@ class MipsAbiFlagsSection final : public SyntheticSection {
|
|||
using Elf_Mips_ABIFlags = llvm::object::Elf_Mips_ABIFlags<ELFT>;
|
||||
|
||||
public:
|
||||
static MipsAbiFlagsSection *create();
|
||||
static std::unique_ptr<MipsAbiFlagsSection> create();
|
||||
|
||||
MipsAbiFlagsSection(Elf_Mips_ABIFlags flags);
|
||||
size_t getSize() const override { return sizeof(Elf_Mips_ABIFlags); }
|
||||
|
@ -996,7 +996,7 @@ template <class ELFT> class MipsOptionsSection final : public SyntheticSection {
|
|||
using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo<ELFT>;
|
||||
|
||||
public:
|
||||
static MipsOptionsSection *create();
|
||||
static std::unique_ptr<MipsOptionsSection<ELFT>> create();
|
||||
|
||||
MipsOptionsSection(Elf_Mips_RegInfo reginfo);
|
||||
void writeTo(uint8_t *buf) override;
|
||||
|
@ -1014,7 +1014,7 @@ template <class ELFT> class MipsReginfoSection final : public SyntheticSection {
|
|||
using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo<ELFT>;
|
||||
|
||||
public:
|
||||
static MipsReginfoSection *create();
|
||||
static std::unique_ptr<MipsReginfoSection> create();
|
||||
|
||||
MipsReginfoSection(Elf_Mips_RegInfo reginfo);
|
||||
size_t getSize() const override { return sizeof(Elf_Mips_RegInfo); }
|
||||
|
@ -1244,7 +1244,10 @@ struct InStruct {
|
|||
std::unique_ptr<GotPltSection> gotPlt;
|
||||
std::unique_ptr<IgotPltSection> igotPlt;
|
||||
std::unique_ptr<PPC64LongBranchTargetSection> ppc64LongBranchTarget;
|
||||
std::unique_ptr<SyntheticSection> mipsAbiFlags;
|
||||
std::unique_ptr<MipsGotSection> mipsGot;
|
||||
std::unique_ptr<SyntheticSection> mipsOptions;
|
||||
std::unique_ptr<SyntheticSection> mipsReginfo;
|
||||
std::unique_ptr<MipsRldMapSection> mipsRldMap;
|
||||
std::unique_ptr<SyntheticSection> partEnd;
|
||||
std::unique_ptr<SyntheticSection> partIndex;
|
||||
|
|
|
@ -327,12 +327,12 @@ template <class ELFT> void elf::createSyntheticSections() {
|
|||
in.mipsRldMap = std::make_unique<MipsRldMapSection>();
|
||||
add(*in.mipsRldMap);
|
||||
}
|
||||
if (auto *sec = MipsAbiFlagsSection<ELFT>::create())
|
||||
add(*sec);
|
||||
if (auto *sec = MipsOptionsSection<ELFT>::create())
|
||||
add(*sec);
|
||||
if (auto *sec = MipsReginfoSection<ELFT>::create())
|
||||
add(*sec);
|
||||
if ((in.mipsAbiFlags = MipsAbiFlagsSection<ELFT>::create()))
|
||||
add(*in.mipsAbiFlags);
|
||||
if ((in.mipsOptions = MipsOptionsSection<ELFT>::create()))
|
||||
add(*in.mipsOptions);
|
||||
if ((in.mipsReginfo = MipsReginfoSection<ELFT>::create()))
|
||||
add(*in.mipsReginfo);
|
||||
}
|
||||
|
||||
StringRef relaDynName = config->isRela ? ".rela.dyn" : ".rel.dyn";
|
||||
|
|
Loading…
Reference in New Issue