mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-15 04:00:56 +00:00
Simplify MipsReginfoInputSection.
MipsReginfoInputSection is basically just a container of Elf_Mips_Reginfo struct. This patch makes that struct directly accessible from others. llvm-svn: 256984
This commit is contained in:
parent
32791cc3e1
commit
70eed364fc
@ -92,7 +92,9 @@ typename ObjectFile<ELFT>::Elf_Sym_Range ObjectFile<ELFT>::getLocalSymbols() {
|
||||
}
|
||||
|
||||
template <class ELFT> uint32_t ObjectFile<ELFT>::getMipsGp0() const {
|
||||
return MipsReginfo ? MipsReginfo->getGp0() : 0;
|
||||
if (MipsReginfo)
|
||||
return MipsReginfo->Reginfo->ri_gp_value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
|
@ -348,22 +348,13 @@ MergeInputSection<ELFT>::getOffset(uintX_t Offset) {
|
||||
|
||||
template <class ELFT>
|
||||
MipsReginfoInputSection<ELFT>::MipsReginfoInputSection(ObjectFile<ELFT> *F,
|
||||
const Elf_Shdr *Header)
|
||||
: InputSectionBase<ELFT>(F, Header, InputSectionBase<ELFT>::MipsReginfo) {}
|
||||
|
||||
template <class ELFT>
|
||||
uint32_t MipsReginfoInputSection<ELFT>::getGeneralMask() const {
|
||||
const Elf_Shdr *Hdr)
|
||||
: InputSectionBase<ELFT>(F, Hdr, InputSectionBase<ELFT>::MipsReginfo) {
|
||||
// Initialize this->Reginfo.
|
||||
ArrayRef<uint8_t> D = this->getSectionData();
|
||||
if (D.size() != sizeof(Elf_Mips_RegInfo))
|
||||
if (D.size() != sizeof(Elf_Mips_RegInfo<ELFT>))
|
||||
error("Invalid size of .reginfo section");
|
||||
return reinterpret_cast<const Elf_Mips_RegInfo *>(D.data())->ri_gprmask;
|
||||
}
|
||||
|
||||
template <class ELFT> uint32_t MipsReginfoInputSection<ELFT>::getGp0() const {
|
||||
ArrayRef<uint8_t> D = this->getSectionData();
|
||||
if (D.size() != sizeof(Elf_Mips_RegInfo))
|
||||
error("Invalid size of .reginfo section");
|
||||
return reinterpret_cast<const Elf_Mips_RegInfo *>(D.data())->ri_gp_value;
|
||||
Reginfo = reinterpret_cast<const Elf_Mips_RegInfo<ELFT> *>(D.data());
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
|
@ -177,16 +177,13 @@ public:
|
||||
// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
|
||||
template <class ELFT>
|
||||
class MipsReginfoInputSection : public InputSectionBase<ELFT> {
|
||||
typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
|
||||
typedef typename llvm::object::ELFFile<ELFT>::Elf_Shdr Elf_Shdr;
|
||||
|
||||
public:
|
||||
MipsReginfoInputSection(ObjectFile<ELFT> *F, const Elf_Shdr *Header);
|
||||
|
||||
uint32_t getGeneralMask() const;
|
||||
uint32_t getGp0() const;
|
||||
|
||||
MipsReginfoInputSection(ObjectFile<ELFT> *F, const Elf_Shdr *Hdr);
|
||||
static bool classof(const InputSectionBase<ELFT> *S);
|
||||
|
||||
const llvm::object::Elf_Mips_RegInfo<ELFT> *Reginfo;
|
||||
};
|
||||
|
||||
} // namespace elf2
|
||||
|
@ -1412,13 +1412,14 @@ template <class ELFT>
|
||||
void MipsReginfoOutputSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||
auto *R = reinterpret_cast<Elf_Mips_RegInfo *>(Buf);
|
||||
R->ri_gp_value = getMipsGpAddr<ELFT>();
|
||||
R->ri_gprmask = GeneralMask;
|
||||
R->ri_gprmask = GprMask;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
void MipsReginfoOutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) {
|
||||
// Copy input object file's .reginfo gprmask to output.
|
||||
auto *S = cast<MipsReginfoInputSection<ELFT>>(C);
|
||||
GeneralMask |= S->getGeneralMask();
|
||||
GprMask |= S->Reginfo->ri_gprmask;
|
||||
}
|
||||
|
||||
namespace lld {
|
||||
|
@ -429,7 +429,7 @@ public:
|
||||
void addSection(InputSectionBase<ELFT> *S) override;
|
||||
|
||||
private:
|
||||
uint32_t GeneralMask = 0;
|
||||
uint32_t GprMask = 0;
|
||||
};
|
||||
|
||||
// All output sections that are hadnled by the linker specially are
|
||||
|
Loading…
Reference in New Issue
Block a user