mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 00:59:44 -06:00
ElfReader: Clean up elf loader code.
* Don't claim to support any features we don't, like relocation * Actually zero-out BSS sections, as memory might not be already zeroed. * Deleted commented out code. * Removed GetPointer, updated to more modern interface methods. * Updated pointer types style from "u32 *x" to "u32* x"
This commit is contained in:
@ -19,19 +19,19 @@ typedef int SectionID;
|
||||
class ElfReader
|
||||
{
|
||||
private:
|
||||
char *base;
|
||||
u32 *base32;
|
||||
char* base;
|
||||
u32* base32;
|
||||
|
||||
Elf32_Ehdr *header;
|
||||
Elf32_Phdr *segments;
|
||||
Elf32_Shdr *sections;
|
||||
Elf32_Ehdr* header;
|
||||
Elf32_Phdr* segments;
|
||||
Elf32_Shdr* sections;
|
||||
|
||||
u32 *sectionAddrs;
|
||||
bool bRelocate;
|
||||
u32 entryPoint;
|
||||
|
||||
public:
|
||||
ElfReader(void *ptr);
|
||||
ElfReader(void* ptr);
|
||||
~ElfReader() { }
|
||||
|
||||
u32 Read32(int off) const { return base32[off>>2]; }
|
||||
@ -41,13 +41,13 @@ public:
|
||||
ElfMachine GetMachine() const { return (ElfMachine)(header->e_machine); }
|
||||
u32 GetEntryPoint() const { return entryPoint; }
|
||||
u32 GetFlags() const { return (u32)(header->e_flags); }
|
||||
bool LoadInto(u32 vaddr);
|
||||
bool LoadIntoMemory();
|
||||
bool LoadSymbols();
|
||||
|
||||
int GetNumSegments() const { return (int)(header->e_phnum); }
|
||||
int GetNumSections() const { return (int)(header->e_shnum); }
|
||||
const u8 *GetPtr(int offset) const { return (u8*)base + offset; }
|
||||
const char *GetSectionName(int section) const;
|
||||
const u8* GetPtr(int offset) const { return (u8*)base + offset; }
|
||||
const char* GetSectionName(int section) const;
|
||||
const u8 *GetSectionDataPtr(int section) const
|
||||
{
|
||||
if (section < 0 || section >= header->e_shnum)
|
||||
@ -61,13 +61,13 @@ public:
|
||||
{
|
||||
return sections[section].sh_type == SHT_PROGBITS;
|
||||
}
|
||||
const u8 *GetSegmentPtr(int segment)
|
||||
const u8* GetSegmentPtr(int segment)
|
||||
{
|
||||
return GetPtr(segments[segment].p_offset);
|
||||
}
|
||||
u32 GetSectionAddr(SectionID section) const { return sectionAddrs[section]; }
|
||||
int GetSectionSize(SectionID section) const { return sections[section].sh_size; }
|
||||
SectionID GetSectionByName(const char *name, int firstSection = 0) const; //-1 for not found
|
||||
SectionID GetSectionByName(const char* name, int firstSection = 0) const; //-1 for not found
|
||||
|
||||
bool DidRelocate()
|
||||
{
|
||||
|
Reference in New Issue
Block a user