mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
[obj2yaml/yaml2obj] Add SHT_MIPS_ABIFLAGS section support
This change adds support for the SHT_MIPS_ABIFLAGS section reading/writing to the obj2yaml and yaml2obj tools. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236738 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -133,6 +133,9 @@ class ELFState {
|
||||
ContiguousBlobAccumulator &CBA);
|
||||
bool writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::Group &Group,
|
||||
ContiguousBlobAccumulator &CBA);
|
||||
bool writeSectionContent(Elf_Shdr &SHeader,
|
||||
const ELFYAML::MipsABIFlags &Section,
|
||||
ContiguousBlobAccumulator &CBA);
|
||||
|
||||
// - SHT_NULL entry (placed first, i.e. 0'th entry)
|
||||
// - symbol table (.symtab) (placed third to last)
|
||||
@@ -235,6 +238,9 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
|
||||
SHeader.sh_info = SymIdx;
|
||||
if (!writeSectionContent(SHeader, *S, CBA))
|
||||
return false;
|
||||
} else if (auto S = dyn_cast<ELFYAML::MipsABIFlags>(Sec.get())) {
|
||||
if (!writeSectionContent(SHeader, *S, CBA))
|
||||
return false;
|
||||
} else
|
||||
llvm_unreachable("Unknown section type");
|
||||
|
||||
@@ -413,6 +419,37 @@ bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
|
||||
const ELFYAML::MipsABIFlags &Section,
|
||||
ContiguousBlobAccumulator &CBA) {
|
||||
if (Section.Type != llvm::ELF::SHT_MIPS_ABIFLAGS) {
|
||||
errs() << "error: Invalid section type.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
object::Elf_Mips_ABIFlags<ELFT> Flags;
|
||||
zero(Flags);
|
||||
SHeader.sh_entsize = sizeof(Flags);
|
||||
SHeader.sh_size = SHeader.sh_entsize;
|
||||
|
||||
auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset);
|
||||
Flags.version = Section.Version;
|
||||
Flags.isa_level = Section.ISALevel;
|
||||
Flags.isa_rev = Section.ISARevision;
|
||||
Flags.gpr_size = Section.GPRSize;
|
||||
Flags.cpr1_size = Section.CPR1Size;
|
||||
Flags.cpr2_size = Section.CPR2Size;
|
||||
Flags.fp_abi = Section.FpABI;
|
||||
Flags.isa_ext = Section.ISAExtension;
|
||||
Flags.ases = Section.ASEs;
|
||||
Flags.flags1 = Section.Flags1;
|
||||
Flags.flags2 = Section.Flags2;
|
||||
OS.write((const char *)&Flags, sizeof(Flags));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class ELFT> bool ELFState<ELFT>::buildSectionIndex() {
|
||||
SN2I.addName(".symtab", getDotSymTabSecNo());
|
||||
SN2I.addName(".strtab", getDotStrTabSecNo());
|
||||
|
||||
Reference in New Issue
Block a user