First commit.
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "ELF64_Section.h"
|
||||
#include "ELF64_Program.h"
|
||||
|
||||
#include <ehs/Serializer.h>
|
||||
|
||||
/// Architecture's memory bit-depth.
|
||||
#define ELFH_ARCH_32 0x01
|
||||
#define ELFH_ARCH_64 0x02
|
||||
|
||||
/// Architecture's endianness.
|
||||
#define ELFH_END_LE 0x01
|
||||
#define ELFH_END_BE 0x02
|
||||
|
||||
/// OS' ABI Types.
|
||||
#define ELFH_ABI_SYSTEMV 0x00
|
||||
|
||||
/// ELF Binary Types.
|
||||
#define ELFH_TYPE_EXEC 0x02
|
||||
#define ELFH_TYPE_DYN 0x03
|
||||
|
||||
/// Machine architectures.
|
||||
#define ELFH_MARCH_AMD_X86_64 0x003E
|
||||
|
||||
/// True header sizes.
|
||||
#define ELFH_SIZE 64
|
||||
|
||||
class ELF64
|
||||
{
|
||||
private:
|
||||
ehs::UInt_8 endianness;
|
||||
ehs::UInt_8 abi;
|
||||
ehs::UInt_16 type;
|
||||
ehs::UInt_16 arch;
|
||||
ehs::UInt_16 entryPoint;
|
||||
ehs::Vector<ELF64_Program, ehs::UInt_16> programs;
|
||||
ehs::Vector<ELF64_Section, ehs::UInt_16> sections;
|
||||
|
||||
public:
|
||||
ELF64();
|
||||
|
||||
ELF64(ehs::UInt_8 end, ehs::UInt_8 abi, ehs::UInt_16 type, ehs::UInt_16 arch);
|
||||
|
||||
ELF64(ehs::Serializer<ehs::UInt_64>& data);
|
||||
|
||||
ELF64(ELF64&& header) noexcept;
|
||||
|
||||
ELF64(const ELF64& header);
|
||||
|
||||
ELF64& operator=(ELF64&& header) noexcept;
|
||||
|
||||
ELF64& operator=(const ELF64& header);
|
||||
|
||||
ehs::UInt_8 GetEndianness() const;
|
||||
|
||||
ehs::UInt_8 GetABI() const;
|
||||
|
||||
ehs::UInt_16 GetType() const;
|
||||
|
||||
ehs::UInt_16 GetArchitecture() const;
|
||||
|
||||
void SetEntryPoint(ehs::UInt_16 programIndex);
|
||||
|
||||
ELF64_Program* GetEntryPoint() const;
|
||||
|
||||
void AddProgram(ELF64_Program newProgram);
|
||||
|
||||
bool HasSection(ehs::UInt_64 hashId);
|
||||
|
||||
bool HasSection(ehs::Str_8& id);
|
||||
|
||||
void AddSection(ELF64_Section newSection);
|
||||
|
||||
ELF64_Section* GetSection(ehs::UInt_64 sectionHashId) const;
|
||||
|
||||
ELF64_Section* GetSection(const ehs::Str_8& sectionId) const;
|
||||
|
||||
ehs::UInt_64 GetLastSegmentOffset() const;
|
||||
|
||||
ehs::Vec2_u64 SegmentRange(ehs::UInt_64 sectionHashId);
|
||||
|
||||
ehs::Vec2_u64 SegmentRange(const ehs::Str_8& sectionId);
|
||||
|
||||
ehs::Serializer<ehs::UInt_64> Serialize() const;
|
||||
|
||||
private:
|
||||
void InitializeSections();
|
||||
|
||||
ehs::UInt_64 RetrieveSectionsOffset() const;
|
||||
|
||||
ehs::UInt_16 FindShStrTabIndex() const;
|
||||
|
||||
ELF64_Section* FindShStrTab() const;
|
||||
};
|
1
include/arctyx/Compiler.h
Normal file
1
include/arctyx/Compiler.h
Normal file
@@ -0,0 +1 @@
|
||||
#pragma once
|
88
include/arctyx/ELF.h
Normal file
88
include/arctyx/ELF.h
Normal file
@@ -0,0 +1,88 @@
|
||||
#pragma once
|
||||
|
||||
#include "ELF_Architecture.h"
|
||||
#include "ELF_Section.h"
|
||||
#include "ELF_Program.h"
|
||||
|
||||
#include <ehs/Serializer.h>
|
||||
|
||||
/// OS' ABI Types.
|
||||
#define ELFH_ABI_SYSTEMV 0x00
|
||||
|
||||
/// ELF Binary Types.
|
||||
#define ELFH_TYPE_EXEC 0x02
|
||||
#define ELFH_TYPE_DYN 0x03
|
||||
|
||||
/// True header sizes.
|
||||
#define ELFH_SIZE 64
|
||||
|
||||
class ELF
|
||||
{
|
||||
private:
|
||||
ehs::UInt_8 bitDepth;
|
||||
ehs::UInt_8 endianness;
|
||||
ehs::UInt_8 abi;
|
||||
ehs::UInt_16 type;
|
||||
ehs::UInt_16 arch;
|
||||
ehs::UInt_16 entryPoint;
|
||||
ehs::Vector<ELF_Program, ehs::UInt_16> programs;
|
||||
ehs::Vector<ELF_Section, ehs::UInt_16> sections;
|
||||
|
||||
public:
|
||||
ELF();
|
||||
|
||||
ELF(const ehs::UInt_8 &bitDepth, const ehs::UInt_8 &end, const ehs::UInt_8 &abi, const ehs::UInt_16 &type, const ehs::UInt_16 &arch);
|
||||
|
||||
ELF(ehs::Serializer<ehs::UInt_64>& data);
|
||||
|
||||
ELF(ELF&& header) noexcept;
|
||||
|
||||
ELF(const ELF& header);
|
||||
|
||||
ELF& operator=(ELF&& header) noexcept;
|
||||
|
||||
ELF& operator=(const ELF& header);
|
||||
|
||||
ehs::UInt_8 GetBitDepth() const;
|
||||
|
||||
ehs::UInt_8 GetEndianness() const;
|
||||
|
||||
ehs::UInt_8 GetABI() const;
|
||||
|
||||
ehs::UInt_16 GetType() const;
|
||||
|
||||
ehs::UInt_16 GetArchitecture() const;
|
||||
|
||||
void SetEntryPoint(ehs::UInt_16 programIndex);
|
||||
|
||||
ELF_Program* GetEntryPoint() const;
|
||||
|
||||
void AddProgram(ELF_Program newProgram);
|
||||
|
||||
bool HasSection(ehs::UInt_64 hashId);
|
||||
|
||||
bool HasSection(ehs::Str_8& id);
|
||||
|
||||
void AddSection(ELF_Section newSection);
|
||||
|
||||
ELF_Section* GetSection(ehs::UInt_64 sectionHashId) const;
|
||||
|
||||
ELF_Section* GetSection(const ehs::Str_8& sectionId) const;
|
||||
|
||||
ehs::UInt_64 GetLastSegmentOffset() const;
|
||||
|
||||
ehs::Vec2_u64 SegmentRange(ehs::UInt_64 sectionHashId);
|
||||
|
||||
ehs::Vec2_u64 SegmentRange(const ehs::Str_8& sectionId);
|
||||
|
||||
ehs::Serializer<ehs::UInt_64> Serialize() const;
|
||||
|
||||
private:
|
||||
void InitializeSections();
|
||||
|
||||
ehs::UInt_64 RetrieveSectionsOffset() const;
|
||||
|
||||
ehs::UInt_16 FindShStrTabIndex() const;
|
||||
|
||||
ELF_Section* FindShStrTab() const;
|
||||
};
|
16
include/arctyx/ELF_Architecture.h
Normal file
16
include/arctyx/ELF_Architecture.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
// Machine architecture's.
|
||||
#define ELF_ARCH_X86 0x0003
|
||||
#define ELF_ARCH_AARCH 0x0028
|
||||
#define ELF_ARCH_X86_64 0x003E
|
||||
#define ELF_ARCH_AARCH64 0x00B7
|
||||
#define ELF_ARCH_RISCV 0x00F3
|
||||
|
||||
/// Architecture's memory bit-depth.
|
||||
#define ELF_BIT_DEPTH_32 0x01
|
||||
#define ELF_BIT_DEPTH_64 0x02
|
||||
|
||||
/// Architecture's endianness.
|
||||
#define ELF_END_LE 0x01
|
||||
#define ELF_END_BE 0x02
|
@@ -12,12 +12,12 @@
|
||||
|
||||
#define PRGH_SIZE 56
|
||||
|
||||
class ELF64;
|
||||
class ELF;
|
||||
|
||||
class ELF64_Program
|
||||
class ELF_Program
|
||||
{
|
||||
private:
|
||||
friend class ELF64;
|
||||
friend class ELF;
|
||||
|
||||
ehs::UInt_32 type;
|
||||
ehs::UInt_32 flags;
|
||||
@@ -29,19 +29,19 @@ private:
|
||||
ehs::UInt_64 align;
|
||||
|
||||
public:
|
||||
ELF64_Program();
|
||||
ELF_Program();
|
||||
|
||||
ELF64_Program(ehs::UInt_32 type, ehs::UInt_32 flags, ehs::UInt_64 offset, ehs::UInt_64 address, ehs::UInt_64 size, ehs::UInt_64 adjustedMemSize, ehs::UInt_64 align);
|
||||
ELF_Program(ehs::UInt_32 type, ehs::UInt_32 flags, ehs::UInt_64 offset, ehs::UInt_64 address, ehs::UInt_64 size, ehs::UInt_64 adjustedMemSize, ehs::UInt_64 align);
|
||||
|
||||
ELF64_Program(ehs::Serializer<ehs::UInt_64>& data);
|
||||
ELF_Program(ehs::Serializer<ehs::UInt_64>& data);
|
||||
|
||||
ELF64_Program(ELF64_Program&& program) noexcept;
|
||||
ELF_Program(ELF_Program&& program) noexcept;
|
||||
|
||||
ELF64_Program(const ELF64_Program& program);
|
||||
ELF_Program(const ELF_Program& program);
|
||||
|
||||
ELF64_Program& operator=(ELF64_Program&& program) noexcept;
|
||||
ELF_Program& operator=(ELF_Program&& program) noexcept;
|
||||
|
||||
ELF64_Program& operator=(const ELF64_Program& program);
|
||||
ELF_Program& operator=(const ELF_Program& program);
|
||||
|
||||
ehs::UInt_32 GetType() const;
|
||||
|
@@ -17,10 +17,10 @@
|
||||
|
||||
#define SECH_SIZE 64
|
||||
|
||||
class ELF64_Section
|
||||
class ELF_Section
|
||||
{
|
||||
private:
|
||||
friend class ELF64;
|
||||
friend class ELF;
|
||||
|
||||
ehs::UInt_64 hashId;
|
||||
ehs::Str_8 id;
|
||||
@@ -37,17 +37,17 @@ private:
|
||||
ehs::Serializer<ehs::UInt_64> data;
|
||||
|
||||
public:
|
||||
ELF64_Section();
|
||||
ELF_Section();
|
||||
|
||||
ELF64_Section(ehs::Str_8 id, ehs::UInt_64 fileOffset, ehs::UInt_32 type, ehs::UInt_64 flags, ehs::UInt_64 vAddr, ehs::UInt_64 align);
|
||||
ELF_Section(ehs::Str_8 id, ehs::UInt_64 fileOffset, ehs::UInt_32 type, ehs::UInt_64 flags, ehs::UInt_64 vAddr, ehs::UInt_64 align);
|
||||
|
||||
ELF64_Section(ELF64_Section&& sect) noexcept;
|
||||
ELF_Section(ELF_Section&& sect) noexcept;
|
||||
|
||||
ELF64_Section(const ELF64_Section& sect);
|
||||
ELF_Section(const ELF_Section& sect);
|
||||
|
||||
ELF64_Section& operator=(ELF64_Section&& sect) noexcept;
|
||||
ELF_Section& operator=(ELF_Section&& sect) noexcept;
|
||||
|
||||
ELF64_Section& operator=(const ELF64_Section& sect);
|
||||
ELF_Section& operator=(const ELF_Section& sect);
|
||||
|
||||
ehs::UInt_64 GetHashId() const;
|
||||
|
@@ -74,7 +74,7 @@
|
||||
|
||||
#define SYMH_SIZE 24
|
||||
|
||||
class ELF64_Sym
|
||||
class ELF_Sym
|
||||
{
|
||||
private:
|
||||
ehs::UInt_32 nameOffset;
|
||||
@@ -85,9 +85,9 @@ private:
|
||||
ehs::UInt_64 size;
|
||||
|
||||
public:
|
||||
ELF64_Sym();
|
||||
ELF_Sym();
|
||||
|
||||
ELF64_Sym(ehs::UInt_32 nameOffset, ehs::UInt_8 type, ehs::UInt_8 visibility, ehs::UInt_16 section, ehs::UInt_64 value, ehs::UInt_64 size);
|
||||
ELF_Sym(ehs::UInt_32 nameOffset, ehs::UInt_8 type, ehs::UInt_8 visibility, ehs::UInt_16 section, ehs::UInt_64 value, ehs::UInt_64 size);
|
||||
|
||||
void Serialize(ehs::Serializer<ehs::UInt_64>& inData) const;
|
||||
};
|
1
include/arctyx/Linker.h
Normal file
1
include/arctyx/Linker.h
Normal file
@@ -0,0 +1 @@
|
||||
#pragma once
|
Reference in New Issue
Block a user