Symbol table

This commit is contained in:
Sajid
2024-09-08 08:32:31 +06:00
parent 36fb31de3a
commit 6d79935928
8 changed files with 186 additions and 48 deletions

View File

@@ -1,16 +1,10 @@
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <set>
#include <expected>
struct Section;
enum SectionFlags : uint8_t
{
SectionFlags_None = 0,
SectionFlags_Data = 1,
SectionFlags_Code = 2
};
#include <section.h>
#include "symbol_table.h"
struct Image
{
@@ -19,7 +13,8 @@ struct Image
uint32_t size{};
size_t entry_point{};
std::vector<Section> sections{};
std::set<Section, SectionComparer> sections{};
SymbolTable symbols{};
/**
* \brief Map data to image by RVA
@@ -46,28 +41,4 @@ struct Image
static std::expected<Image, int> ParseImage(const uint8_t* data, size_t size);
};
struct Section
{
std::string name{};
size_t base{};
uint32_t size{};
SectionFlags flags{};
uint8_t* data{};
bool operator<(size_t address) const
{
return address < base;
}
bool operator>(size_t address) const
{
return address >= (base + size);
}
bool operator==(size_t address) const
{
return address >= base && address < base + size;
}
};
Image ElfLoadImage(const uint8_t* data, size_t size);