You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Theodosius/include/decomp/decomp.hpp

46 lines
1.4 KiB

#pragma once
#include <spdlog/spdlog.h>
#include <cstdint>
#include <linuxpe>
#include <optional>
#include <set>
#include <vector>
#include <decomp/routine.hpp>
#include <recomp/symbol_table.hpp>
#include <coff/archive.hpp>
#include <coff/image.hpp>
namespace theo::decomp {
using sym_data_t = std::tuple<coff::image_t*, coff::symbol_t*, std::uint32_t>;
class decomp_t {
public:
explicit decomp_t(std::vector<std::uint8_t>& lib,
recomp::symbol_table_t* syms);
std::vector<routine_t> rtns();
std::vector<std::uint8_t> lib();
std::vector<coff::image_t*> objs();
recomp::symbol_table_t* syms();
std::map<coff::section_header_t*, std::size_t>& scn_hash_tbl();
std::optional<recomp::symbol_table_t*> decompose(
const std::string&& entry_sym);
private:
std::uint32_t ext_used_syms(const std::string&& entry_sym);
std::optional<sym_data_t> get_symbol(const std::string_view& name);
std::uint32_t next_sym(coff::image_t* img,
coff::section_header_t* hdr,
coff::symbol_t* s);
const std::vector<std::uint8_t> m_lib;
std::vector<coff::image_t*> m_objs;
std::vector<routine_t> m_rtns;
std::set<sym_data_t> m_used_syms;
std::set<coff::image_t*> m_processed_objs;
std::map<coff::section_header_t*, std::size_t> m_scn_hash_tbl;
std::map<std::size_t, std::vector<sym_data_t>> m_lookup_tbl;
recomp::symbol_table_t* m_syms;
};
} // namespace theo::decomp