selfpatch-slr/finalize/accumulation.h

66 lines
1.2 KiB
C++

#pragma once
#include <string>
#include <cstddef>
#include <unordered_map>
#include <map>
#include <list>
#include <optional>
#include <cstdint>
struct IPIN {
struct HIT {
uint64_t vaddr;
uint32_t imm_offset;
uint32_t imm_size;
};
std::string symbol;
std::size_t local_target;
std::size_t field_offset;
std::optional<HIT> hit;
};
struct DPIN {
struct HIT {
uint64_t vaddr;
};
struct COMPONENT {
std::size_t offset;
std::size_t level;
std::size_t target; // local pin -> local target, global pin -> global target
};
std::string symbol;
std::list<COMPONENT> components;
std::optional<HIT> hit;
};
struct FIELD {
std::size_t offset;
std::size_t size;
std::size_t alignment;
std::size_t flags;
std::size_t idx;
};
struct TARGET {
std::string name;
std::size_t size;
std::map<std::size_t, FIELD> fields;
};
struct CU {
std::unordered_map<std::size_t, std::size_t> local_targets;
std::unordered_map<std::string, IPIN> ipins;
std::unordered_map<std::string, DPIN> dpins;
};
extern std::unordered_map<std::size_t, TARGET> targets;
extern std::unordered_map<std::string, DPIN> global_dpins;
extern std::unordered_map<std::string, CU> units;
bool accumulate(const std::string& spslr_dir);