Style, paranoia.

This commit is contained in:
Christian Speckner 2024-07-05 22:55:02 +02:00
parent 21921584ed
commit 9cc43a80e5
2 changed files with 12 additions and 4 deletions

View File

@ -175,10 +175,19 @@ const ElfParser::Section* ElfParser::getSymtab() const
const ElfParser::Section* ElfParser::getStrtab() const const ElfParser::Section* ElfParser::getStrtab() const
{ {
for (size_t i = 0; i < sections.size(); i++) const Section* strtab = nullptr;
if (sections[i].type == SHT_STRTAB && i != header.shstrIndex) return &sections[i]; size_t count = 0;
return nullptr; for (size_t i = 0; i < sections.size(); i++) {
if (sections[i].type != SHT_STRTAB || i == header.shstrIndex) continue;
strtab = &sections[i];
count++;
}
if (count > 1) EInvalidElf::raise("more than one symbol table");
return strtab;
} }
ostream& operator<<(ostream& os, const ElfParser::Section& section) ostream& operator<<(ostream& os, const ElfParser::Section& section)

View File

@ -135,7 +135,6 @@ class ElfParser {
}; };
ostream& operator<<(ostream& os, const ElfParser::Section& section); ostream& operator<<(ostream& os, const ElfParser::Section& section);
ostream& operator<<(ostream& os, const ElfParser::Symbol symbol); ostream& operator<<(ostream& os, const ElfParser::Symbol symbol);
#endif // ELF_PARSER #endif // ELF_PARSER