mirror of https://github.com/stella-emu/stella.git
Cleanup.
This commit is contained in:
parent
b38d9ad537
commit
436f9888a5
|
@ -17,6 +17,9 @@ void ElfParser::parse(const uInt8 *elfData, size_t size)
|
||||||
this->size = size;
|
this->size = size;
|
||||||
|
|
||||||
sections.resize(0);
|
sections.resize(0);
|
||||||
|
symbols.resize(0);
|
||||||
|
relocations.clear();
|
||||||
|
bigEndian = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (read32(0x00) != ELF_MAGIC) EInvalidElf::raise("bad magic");
|
if (read32(0x00) != ELF_MAGIC) EInvalidElf::raise("bad magic");
|
||||||
|
@ -68,9 +71,10 @@ void ElfParser::parse(const uInt8 *elfData, size_t size)
|
||||||
if (section.info >= sections.size()) EInvalidElf::raise("relocation table for invalid section");
|
if (section.info >= sections.size()) EInvalidElf::raise("relocation table for invalid section");
|
||||||
|
|
||||||
vector<Relocation> rels;
|
vector<Relocation> rels;
|
||||||
rels.reserve(section.size / (section.type == SHT_REL ? REL_ENTRY_SIZE : RELA_ENTRY_SIZE));
|
const size_t relocationCount = section.size / (section.type == SHT_REL ? REL_ENTRY_SIZE : RELA_ENTRY_SIZE);
|
||||||
|
rels.reserve(section.size / relocationCount);
|
||||||
|
|
||||||
for (size_t i = 0; i < rels.capacity(); i++) {
|
for (size_t i = 0; i < relocationCount; i++) {
|
||||||
Relocation rel = readRelocation(i, section);
|
Relocation rel = readRelocation(i, section);
|
||||||
|
|
||||||
if (rel.symbol >= symbols.size()) EInvalidElf::raise("invalid relocation symbol");
|
if (rel.symbol >= symbols.size()) EInvalidElf::raise("invalid relocation symbol");
|
||||||
|
|
|
@ -150,6 +150,12 @@ class ElfParser {
|
||||||
vector<Section> sections;
|
vector<Section> sections;
|
||||||
vector<Symbol> symbols;
|
vector<Symbol> symbols;
|
||||||
std::unordered_map<size_t, vector<Relocation>> relocations;
|
std::unordered_map<size_t, vector<Relocation>> relocations;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ElfParser(const ElfParser&) = delete;
|
||||||
|
ElfParser(ElfParser&&) = delete;
|
||||||
|
ElfParser& operator=(const ElfParser&) = delete;
|
||||||
|
ElfParser& operator=(ElfParser&&) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
ostream& operator<<(ostream& os, const ElfParser::Section& section);
|
ostream& operator<<(ostream& os, const ElfParser::Section& section);
|
||||||
|
|
Loading…
Reference in New Issue