#ifndef PS2RECOMP_ELF_PARSER_H #define PS2RECOMP_ELF_PARSER_H #include #include #include #include #include #include namespace ps2recomp { struct Relocation; struct Section; struct Function; struct Symbol; class RecompilerReporter; class ElfParser { public: explicit ElfParser(const std::string &filePath); ~ElfParser(); bool parse(); bool loadGhidraFunctionMap(const std::string &mapPath); std::vector extractFunctions() const; std::vector extractExtraFunctions() const; std::vector extractSymbols(); std::vector
getSections(); std::vector getRelocations(); // Helper methods bool isValidAddress(uint32_t address) const; uint32_t readWord(uint32_t address) const; uint8_t *getSectionData(const std::string §ionName) const; uint32_t getSectionAddress(const std::string §ionName) const; uint32_t getSectionSize(const std::string §ionName) const; uint32_t getEntryPoint() const; void setReporter(RecompilerReporter *reporter); void debugAddress(uint32_t address) const; private: std::string m_filePath; std::unique_ptr m_elf; std::vector
m_sections; std::vector m_symbols; std::vector m_relocations; std::vector m_extraFunctions; bool m_hasLoadedGhidraMap = false; RecompilerReporter *m_reporter = nullptr; std::unordered_set m_ghidraMapStarts; void loadSections(); void loadSymbols(); void loadRelocations(); void loadDebugFunctions(); bool isExecutableSection(const ELFIO::section *section) const; bool isDataSection(const ELFIO::section *section) const; }; } // namespace ps2recomp #endif // PS2RECOMP_ELF_PARSER_H