mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-14 10:37:17 -07:00
git subrepo clone https://github.com/HarbourMasters/ZAPDTR.git
subrepo: subdir: "ZAPDTR" merged: "a53a53ea4" upstream: origin: "https://github.com/HarbourMasters/ZAPDTR.git" branch: "master" commit: "a53a53ea4" git-subrepo: version: "0.4.1" origin: "???" commit: "???"
This commit is contained in:
parent
f52a2a6406
commit
5dda5762ba
217 changed files with 47152 additions and 0 deletions
75
ZAPDTR/ZAPD/Overlays/ZOverlay.h
Normal file
75
ZAPDTR/ZAPD/Overlays/ZOverlay.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
#pragma once
|
||||
|
||||
#include "Utils/Directory.h"
|
||||
#include "ZResource.h"
|
||||
#include "elfio/elfio.hpp"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
enum class SectionType
|
||||
{
|
||||
Text = 1,
|
||||
Data = 2,
|
||||
RoData = 3,
|
||||
Bss = 4,
|
||||
ERROR = 255
|
||||
};
|
||||
|
||||
enum class RelocationType
|
||||
{
|
||||
R_MIPS_32 = 2,
|
||||
R_MIPS_26 = 4,
|
||||
R_MIPS_HI16 = 5,
|
||||
R_MIPS_LO16 = 6,
|
||||
};
|
||||
|
||||
class RelocationEntry
|
||||
{
|
||||
public:
|
||||
SectionType sectionType;
|
||||
RelocationType relocationType;
|
||||
int32_t offset;
|
||||
|
||||
RelocationEntry(SectionType nSecType, RelocationType nRelType, int32_t nOffset)
|
||||
{
|
||||
sectionType = nSecType;
|
||||
relocationType = nRelType;
|
||||
offset = nOffset;
|
||||
}
|
||||
|
||||
uint32_t CalcRelocationWord()
|
||||
{
|
||||
uint32_t relocationWord = 0;
|
||||
|
||||
relocationWord |= static_cast<uint32_t>(sectionType) << 30;
|
||||
relocationWord |= static_cast<uint32_t>(relocationType) << 24;
|
||||
relocationWord |= offset;
|
||||
|
||||
return relocationWord;
|
||||
}
|
||||
|
||||
const char* GetSectionName() const;
|
||||
const char* GetRelocTypeName() const;
|
||||
};
|
||||
|
||||
class ZOverlay
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
|
||||
ZOverlay(const std::string& nName);
|
||||
~ZOverlay();
|
||||
static ZOverlay* FromBuild(fs::path buildPath, fs::path cfgFolderPath);
|
||||
std::string GetSourceOutputCode(const std::string& prefix);
|
||||
|
||||
private:
|
||||
std::vector<RelocationEntry*> entries;
|
||||
std::vector<std::string> cfgLines;
|
||||
|
||||
ZOverlay();
|
||||
|
||||
static SectionType GetSectionTypeFromStr(const std::string& sectionName);
|
||||
// static std::string GetOverlayNameFromElf(ELFIO::elfio& reader);
|
||||
|
||||
ELFIO::Elf_Half FindSymbolInSection(const std::string& curSymName, ELFIO::section* sectionData,
|
||||
ELFIO::elfio& reader, size_t readerId);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue