diff --git a/CMakeLists.txt b/CMakeLists.txt index 665b155..8949a28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,24 +26,31 @@ endif () set(CMAKE_CXX_STANDARD 20) -add_executable(Arctyx - include/arctyx/ELF_Architecture.h - src/ELF_Sym.cpp include/arctyx/ELF_Sym.h - src/ELF_Section.cpp include/arctyx/ELF_Section.h - src/ELF_Program.cpp include/arctyx/ELF_Program.h - src/ELF.cpp include/arctyx/ELF.h - src/Linker.cpp include/arctyx/Linker.h - src/Compiler.cpp include/arctyx/Compiler.h +add_library(Arctyx SHARED + include/arctyx/linker/formats/ELF_Architecture.h + src/linker/formats/ELF_Sym.cpp include/arctyx/linker/formats/ELF_Sym.h + src/linker/formats/ELF_Section.cpp include/arctyx/linker/formats/ELF_Section.h + src/linker/formats/ELF_Program.cpp include/arctyx/linker/formats/ELF_Program.h + src/linker/formats/ELF.cpp include/arctyx/linker/formats/ELF.h + src/linker/Linker.cpp include/arctyx/linker/Linker.h + src/compiler/Compiler.cpp include/arctyx/compiler/Compiler.h + src/compiler/Architecture.cpp include/arctyx/compiler/Architecture.h + src/compiler/Instruction.cpp include/arctyx/compiler/Instruction.h +) + +add_executable(Tools src/main.cpp ) -target_include_directories(Arctyx PRIVATE "${PROJECT_SOURCE_DIR}/include") +target_include_directories(Arctyx PUBLIC "${PROJECT_SOURCE_DIR}/include") if (IS_OS_LINUX) add_compile_definitions(LWE_WS_XCB) endif() -target_link_directories(Arctyx PRIVATE "${USER_HOME_DIRECTORY}/.local/lib") -target_include_directories(Arctyx PRIVATE "${USER_HOME_DIRECTORY}/.local/include") +target_link_directories(Arctyx PUBLIC "${USER_HOME_DIRECTORY}/.local/lib") +target_link_directories(Arctyx PUBLIC "${USER_HOME_DIRECTORY}/.local/bin") +target_include_directories(Arctyx PUBLIC "${USER_HOME_DIRECTORY}/.local/include") -target_link_libraries(Arctyx PRIVATE xcb xcb-cursor xcb-xfixes xcb-xinput z asound EHS) \ No newline at end of file +target_link_libraries(Arctyx PUBLIC xcb xcb-cursor xcb-xfixes xcb-xinput z asound EHS_Dyn) +target_link_libraries(Tools PRIVATE Arctyx) \ No newline at end of file diff --git a/include/arctyx/compiler/Architecture.h b/include/arctyx/compiler/Architecture.h new file mode 100644 index 0000000..3513629 --- /dev/null +++ b/include/arctyx/compiler/Architecture.h @@ -0,0 +1,40 @@ +#pragma once + +#include + +#include "Instruction.h" + +class Architecture +{ +private: + ehs::UInt_64 id; + ehs::Str_8 name; + ehs::Array instructions; + +public: + Architecture(); + + Architecture(ehs::Str_8 name); + + Architecture(Architecture &&arch) noexcept; + + Architecture(const Architecture &arc); + + Architecture &operator=(Architecture &&arc) noexcept; + + Architecture &operator=(const Architecture &arc); + + ehs::UInt_64 Id() const; + + ehs::Str_8 GetName() const; + + bool HasInstruction(const ehs::UInt_64 &id) const; + + bool HasInstruction(const ehs::Str_8 &name) const; + + const Instruction *GetInstruction(const ehs::UInt_64 &id) const; + + const Instruction *GetInstruction(const ehs::Str_8 &name) const; + + bool AddInstruction(Instruction ins); +}; \ No newline at end of file diff --git a/include/arctyx/Compiler.h b/include/arctyx/compiler/Compiler.h similarity index 100% rename from include/arctyx/Compiler.h rename to include/arctyx/compiler/Compiler.h diff --git a/include/arctyx/compiler/Instruction.h b/include/arctyx/compiler/Instruction.h new file mode 100644 index 0000000..9f442c7 --- /dev/null +++ b/include/arctyx/compiler/Instruction.h @@ -0,0 +1,43 @@ +#pragma once +#include +#include + +class Instruction +{ +private: + ehs::UInt_64 id; + ehs::Str_8 name; + ehs::UInt_8 size; + ehs::Byte *code; + +public: + ~Instruction(); + + Instruction(); + + Instruction(ehs::Str_8 name, const ehs::UInt_8 &size, ehs::Byte *code); + + Instruction(ehs::Str_8 name, const ehs::UInt_64 &code); + + Instruction(ehs::Str_8 name, const ehs::UInt_32 &code); + + Instruction(ehs::Str_8 name, const ehs::UInt_16 &code); + + Instruction(ehs::Str_8 name, const ehs::UInt_8 &code); + + Instruction(Instruction &&ins) noexcept; + + Instruction(const Instruction &ins); + + Instruction &operator=(Instruction &&ins) noexcept; + + Instruction &operator=(const Instruction &ins); + + ehs::UInt_64 GetId() const; + + ehs::Str_8 GetName() const; + + ehs::UInt_8 GetSize() const; + + ehs::Byte *GetCode() const; +}; diff --git a/include/arctyx/Linker.h b/include/arctyx/linker/Linker.h similarity index 100% rename from include/arctyx/Linker.h rename to include/arctyx/linker/Linker.h diff --git a/include/arctyx/ELF.h b/include/arctyx/linker/formats/ELF.h similarity index 90% rename from include/arctyx/ELF.h rename to include/arctyx/linker/formats/ELF.h index 7cce62f..3108f4a 100644 --- a/include/arctyx/ELF.h +++ b/include/arctyx/linker/formats/ELF.h @@ -14,7 +14,8 @@ #define ELFH_TYPE_DYN 0x03 /// True header sizes. -#define ELFH_SIZE 64 +#define ELF_64_BIT_HEADER_SIZE 64 +#define ELF_32_BIT_HEADER_SIZE 52 class ELF { @@ -78,6 +79,10 @@ public: ehs::Serializer Serialize() const; private: + void Serialize_64(ehs::Serializer &data) const; + + void Serialize_32(ehs::Serializer &data) const; + void InitializeSections(); ehs::UInt_64 RetrieveSectionsOffset() const; diff --git a/include/arctyx/ELF_Architecture.h b/include/arctyx/linker/formats/ELF_Architecture.h similarity index 100% rename from include/arctyx/ELF_Architecture.h rename to include/arctyx/linker/formats/ELF_Architecture.h diff --git a/include/arctyx/ELF_Program.h b/include/arctyx/linker/formats/ELF_Program.h similarity index 81% rename from include/arctyx/ELF_Program.h rename to include/arctyx/linker/formats/ELF_Program.h index 480674f..8216ee1 100644 --- a/include/arctyx/ELF_Program.h +++ b/include/arctyx/linker/formats/ELF_Program.h @@ -49,5 +49,10 @@ public: ehs::UInt_64 GetAlign() const; - void Serialize(ehs::Serializer& inData) const; + void Serialize(const ehs::UInt_8 &bitDepth, ehs::Serializer& inData) const; + +private: + void Serialize_64(ehs::Serializer &data) const; + + void Serialize_32(ehs::Serializer &data) const; }; \ No newline at end of file diff --git a/include/arctyx/ELF_Section.h b/include/arctyx/linker/formats/ELF_Section.h similarity index 86% rename from include/arctyx/ELF_Section.h rename to include/arctyx/linker/formats/ELF_Section.h index 076d7c5..11ca686 100644 --- a/include/arctyx/ELF_Section.h +++ b/include/arctyx/linker/formats/ELF_Section.h @@ -71,5 +71,10 @@ public: ehs::Serializer& GetData(); - void Serialize(ehs::Serializer& inData) const; + void Serialize(const ehs::UInt_8 &bitDepth, ehs::Serializer& inData) const; + +private: + void Serialize_64(ehs::Serializer &data) const; + + void Serialize_32(ehs::Serializer &data) const; }; \ No newline at end of file diff --git a/include/arctyx/ELF_Sym.h b/include/arctyx/linker/formats/ELF_Sym.h similarity index 100% rename from include/arctyx/ELF_Sym.h rename to include/arctyx/linker/formats/ELF_Sym.h diff --git a/src/Compiler.cpp b/src/Compiler.cpp deleted file mode 100644 index c09f83e..0000000 --- a/src/Compiler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "arctyx/Compiler.h" \ No newline at end of file diff --git a/src/Linker.cpp b/src/Linker.cpp deleted file mode 100644 index 56fabb2..0000000 --- a/src/Linker.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "arctyx/Linker.h" \ No newline at end of file diff --git a/src/compiler/Architecture.cpp b/src/compiler/Architecture.cpp new file mode 100644 index 0000000..1126a97 --- /dev/null +++ b/src/compiler/Architecture.cpp @@ -0,0 +1,93 @@ +#include "arctyx/compiler/Architecture.h" + +Architecture::Architecture() + : id(0) +{ +} + +Architecture::Architecture(ehs::Str_8 name) + : id(name.Hash_64()), name((ehs::Str_8 &&)name) +{ +} + +Architecture::Architecture(Architecture &&arch) noexcept + : id(arch.id), name((ehs::Str_8 &&)arch.name) +{ +} + +Architecture::Architecture(const Architecture &arc) + : id(arc.id), name(arc.name) +{ +} + +Architecture & Architecture::operator=(Architecture &&arc) noexcept +{ + if (this == &arc) + return *this; + + id = arc.id; + name = (ehs::Str_8 &&)arc.name; + + arc.id = 0; + + return *this; +} + +Architecture & Architecture::operator=(const Architecture &arc) +{ + if (this == &arc) + return *this; + + id = arc.id; + name = arc.name; + + return *this; +} + +ehs::UInt_64 Architecture::Id() const +{ + return id; +} + +ehs::Str_8 Architecture::GetName() const +{ + return name; +} + +bool Architecture::HasInstruction(const ehs::UInt_64 &id) const +{ + for (ehs::UInt_64 i = 0; i < instructions.Size(); ++i) + if (instructions[i].GetId() == id) + return true; + + return false; +} + +bool Architecture::HasInstruction(const ehs::Str_8 &name) const +{ + return HasInstruction(name.Hash_64()); +} + +const Instruction *Architecture::GetInstruction(const ehs::UInt_64 &id) const +{ + for (ehs::UInt_64 i = 0; i < instructions.Size(); ++i) + if (instructions[i].GetId() == id) + return &instructions[i]; + + return nullptr; +} + +const Instruction *Architecture::GetInstruction(const ehs::Str_8 &name) const +{ + return GetInstruction(name.Hash_64()); +} + +bool Architecture::AddInstruction(Instruction ins) +{ + if (HasInstruction(ins.GetId())) + return false; + + instructions.Push((Instruction &&)ins); + + return true; +} diff --git a/src/compiler/Compiler.cpp b/src/compiler/Compiler.cpp new file mode 100644 index 0000000..85df818 --- /dev/null +++ b/src/compiler/Compiler.cpp @@ -0,0 +1 @@ +#include "arctyx/compiler/Compiler.h" diff --git a/src/compiler/Instruction.cpp b/src/compiler/Instruction.cpp new file mode 100644 index 0000000..562f0be --- /dev/null +++ b/src/compiler/Instruction.cpp @@ -0,0 +1,106 @@ +#include "arctyx/compiler/Instruction.h" + +Instruction::~Instruction() +{ + delete code; +} + +Instruction::Instruction() + : id(0), size(0), code(nullptr) +{ +} + +Instruction::Instruction(ehs::Str_8 name, const ehs::UInt_8 &size, ehs::Byte *code) + : id(name.Hash_64()), name((ehs::Str_8 &&)name), size(size), code(code) +{ +} + +Instruction::Instruction(ehs::Str_8 name, const ehs::UInt_64 &code) + : id(name.Hash_64()), name((ehs::Str_8 &&)name), size(sizeof(code)), code(new ehs::Byte[size]) +{ + *(ehs::UInt_64 *)this->code = code; +} + +Instruction::Instruction(ehs::Str_8 name, const ehs::UInt_32 &code) + : id(name.Hash_64()), name((ehs::Str_8 &&)name), size(sizeof(code)), code(new ehs::Byte[size]) +{ + *(ehs::UInt_32 *)this->code = code; +} + +Instruction::Instruction(ehs::Str_8 name, const ehs::UInt_16 &code) + : id(name.Hash_64()), name((ehs::Str_8 &&)name), size(sizeof(code)), code(new ehs::Byte[size]) +{ + *(ehs::UInt_16 *)this->code = code; +} + +Instruction::Instruction(ehs::Str_8 name, const ehs::UInt_8 &code) + : id(name.Hash_64()), name((ehs::Str_8 &&)name), size(sizeof(code)), code(new ehs::Byte[size]) +{ + *this->code = code; +} + +Instruction::Instruction(Instruction &&ins) noexcept + : id(ins.id), name((ehs::Str_8 &&)ins.name), size(ins.size), code(ins.code) +{ + ins.id = 0; + ins.size = 0; + ins.code = nullptr; +} + +Instruction::Instruction(const Instruction &ins) + : id(ins.id), name(ins.name), size(ins.size), code(new ehs::Byte[size]) +{ + ehs::Util::Copy(code, ins.code, size); +} + +Instruction &Instruction::operator=(Instruction &&ins) noexcept +{ + if (this == &ins) + return *this; + + id = ins.id; + name = (ehs::Str_8 &&)ins.name; + size = ins.size; + code = ins.code; + + ins.id = 0; + ins.size = 0; + ins.code = nullptr; + + return *this; +} + +Instruction &Instruction::operator=(const Instruction &ins) +{ + if (this == &ins) + return *this; + + id = ins.id; + name = ins.name; + size = ins.size; + code = new ehs::Byte[size]; + + ehs::Util::Copy(code, ins.code, size); + + return *this; +} + +ehs::UInt_64 Instruction::GetId() const +{ + return id; +} + +ehs::Str_8 Instruction::GetName() const +{ + return name; +} + +ehs::UInt_8 Instruction::GetSize() const +{ + return size; +} + +ehs::Byte *Instruction::GetCode() const +{ + return code; +} diff --git a/src/linker/Linker.cpp b/src/linker/Linker.cpp new file mode 100644 index 0000000..e2b7b3d --- /dev/null +++ b/src/linker/Linker.cpp @@ -0,0 +1 @@ +#include "arctyx/linker/Linker.h" diff --git a/src/ELF.cpp b/src/linker/formats/ELF.cpp similarity index 76% rename from src/ELF.cpp rename to src/linker/formats/ELF.cpp index 886f4e4..19d82ac 100644 --- a/src/ELF.cpp +++ b/src/linker/formats/ELF.cpp @@ -1,4 +1,4 @@ -#include "arctyx/ELF.h" +#include "arctyx/linker/formats/ELF.h" ELF::ELF() : bitDepth(ELF_BIT_DEPTH_64), endianness(ELF_END_LE), abi(ELFH_ABI_SYSTEMV), type(ELFH_TYPE_EXEC), @@ -199,7 +199,7 @@ ELF_Section* ELF::GetSection(const ehs::Str_8& sectionId) const ehs::UInt_64 ELF::GetLastSegmentOffset() const { - ehs::UInt_64 offset = ELFH_SIZE + PRGH_SIZE * programs.Size(); + ehs::UInt_64 offset = ELF_64_BIT_HEADER_SIZE + PRGH_SIZE * programs.Size(); for (ehs::UInt_16 i = 0; i < sections.Size(); i++) { @@ -214,7 +214,7 @@ ehs::UInt_64 ELF::GetLastSegmentOffset() const ehs::Vec2_u64 ELF::SegmentRange(ehs::UInt_64 sectionHashId) { - ehs::UInt_64 offset = ELFH_SIZE + PRGH_SIZE * programs.Size(); + ehs::UInt_64 offset = ELF_64_BIT_HEADER_SIZE + PRGH_SIZE * programs.Size(); if (sectionHashId) { for (ehs::UInt_16 i = 0; i < sections.Size(); i++) @@ -252,35 +252,13 @@ ehs::Serializer ELF::Serialize() const { ehs::Serializer result(ehs::Endianness::LE); - // ELF magic number. - result.Write(0x7F454C46); - - result.Write(ELF_BIT_DEPTH_64); - result.Write(endianness); - result.Write(1); - result.Write(abi); - result.Write(0); - - result.Resize(result.Size() + 7); - ehs::Util::Zero(&result[result.GetOffset()], 7); - result.SetOffset(result.GetOffset() + 7); - - result.Write(type); - result.Write(arch); - result.Write(1); - result.Write(programs[entryPoint].pAddr); - result.Write(ELFH_SIZE); - result.Write(RetrieveSectionsOffset()); - result.Write(0); - result.Write(ELFH_SIZE); - result.Write(PRGH_SIZE); - result.Write(programs.Size()); - result.Write(SECH_SIZE); - result.Write(sections.Size()); - result.Write(FindShStrTabIndex()); + if (bitDepth == ELF_BIT_DEPTH_64) + Serialize_64(result); + else if (bitDepth == ELF_BIT_DEPTH_32) + Serialize_32(result); for (ehs::UInt_16 i = 0; i < programs.Size(); i++) - programs[i].Serialize(result); + programs[i].Serialize(bitDepth, result); for (ehs::UInt_16 i = 1; i < sections.Size(); i++) { @@ -297,11 +275,83 @@ ehs::Serializer ELF::Serialize() const } for (ehs::UInt_16 i = 0; i < sections.Size(); i++) - sections[i].Serialize(result); + sections[i].Serialize(bitDepth, result); return result; } +void ELF::Serialize_64(ehs::Serializer &data) const +{ + data.Resize(ELF_64_BIT_HEADER_SIZE); + + // ELF magic number. + data.Write(0x464C457F); + + data.Write(bitDepth); + data.Write(endianness); + data.Write(1); + data.Write(abi); + data.Write(0); + + ehs::Util::Zero(&data[data.GetOffset()], 7); + data.SetOffset(data.GetOffset() + 7); + + data.Write(type); + data.Write(arch); + data.Write(1); + data.Write(programs[entryPoint].pAddr); + data.Write(ELF_64_BIT_HEADER_SIZE); + data.Write(RetrieveSectionsOffset()); + data.Write(0); + data.Write(ELF_64_BIT_HEADER_SIZE); + data.Write(PRGH_SIZE); + data.Write(programs.Size()); + data.Write(SECH_SIZE); + data.Write(sections.Size()); + data.Write(FindShStrTabIndex()); +} + +void ELF::Serialize_32(ehs::Serializer &data) const +{ + data.Resize(ELF_32_BIT_HEADER_SIZE); + + // ELF magic number. + data.Write(0x464C457F); + + data.Write(bitDepth); + data.Write(endianness); + data.Write(1); + data.Write(abi); + data.Write(0); + + ehs::Util::Zero(&data[data.GetOffset()], 7); + data.SetOffset(data.GetOffset() + 7); + + data.Write(type); + data.Write(arch); + data.Write(1); + data.Write(programs[entryPoint].pAddr); + + if (bitDepth == ELF_BIT_DEPTH_64) + data.Write(ELF_64_BIT_HEADER_SIZE); + else if (bitDepth == ELF_BIT_DEPTH_32) + data.Write(ELF_32_BIT_HEADER_SIZE); + + data.Write(RetrieveSectionsOffset()); + data.Write(0); + + if (bitDepth == ELF_BIT_DEPTH_64) + data.Write(ELF_64_BIT_HEADER_SIZE); + else if (bitDepth == ELF_BIT_DEPTH_32) + data.Write(ELF_32_BIT_HEADER_SIZE); + + data.Write(PRGH_SIZE); + data.Write(programs.Size()); + data.Write(SECH_SIZE); + data.Write(sections.Size()); + data.Write(FindShStrTabIndex()); +} + void ELF::InitializeSections() { ehs::Str_8 nullName = ".NULL"; @@ -332,7 +382,7 @@ void ELF::InitializeSections() ehs::UInt_64 ELF::RetrieveSectionsOffset() const { - ehs::UInt_64 result = ELFH_SIZE + PRGH_SIZE * programs.Size(); + ehs::UInt_64 result = ELF_64_BIT_HEADER_SIZE + PRGH_SIZE * programs.Size(); for (ehs::UInt_16 i = 0; i < sections.Size(); i++) { diff --git a/src/ELF_Program.cpp b/src/linker/formats/ELF_Program.cpp similarity index 73% rename from src/ELF_Program.cpp rename to src/linker/formats/ELF_Program.cpp index 1b1901e..4055d15 100644 --- a/src/ELF_Program.cpp +++ b/src/linker/formats/ELF_Program.cpp @@ -1,4 +1,5 @@ -#include "arctyx/ELF_Program.h" +#include "arctyx/linker/formats/ELF_Program.h" +#include "arctyx/linker/formats/ELF_Architecture.h" ELF_Program::ELF_Program() : type(PRGH_TYPE_LOAD), flags(PRGH_FLAG_EXEC | PRGH_FLAG_READ), offset(0), vAddr(0), pAddr(0), fileSize(0), @@ -96,14 +97,34 @@ ehs::UInt_64 ELF_Program::GetAlign() const return align; } -void ELF_Program::Serialize(ehs::Serializer& inData) const +void ELF_Program::Serialize(const ehs::UInt_8 &bitDepth, ehs::Serializer& inData) const { - inData.Write(type); - inData.Write(flags); - inData.Write(offset); - inData.Write(vAddr); - inData.Write(pAddr); - inData.Write(fileSize); - inData.Write(fileSize + adjustedMemSize); - inData.Write(align); + if (bitDepth == ELF_BIT_DEPTH_64) + Serialize_64(inData); + else if (bitDepth == ELF_BIT_DEPTH_32) + Serialize_32(inData); +} + +void ELF_Program::Serialize_64(ehs::Serializer &data) const +{ + data.Write(type); + data.Write(flags); + data.Write(offset); + data.Write(vAddr); + data.Write(pAddr); + data.Write(fileSize); + data.Write(fileSize + adjustedMemSize); + data.Write(align); +} + +void ELF_Program::Serialize_32(ehs::Serializer &data) const +{ + data.Write(type); + data.Write(offset); + data.Write(vAddr); + data.Write(pAddr); + data.Write(fileSize); + data.Write(fileSize + adjustedMemSize); + data.Write(flags); + data.Write(align); } diff --git a/src/ELF_Section.cpp b/src/linker/formats/ELF_Section.cpp similarity index 76% rename from src/ELF_Section.cpp rename to src/linker/formats/ELF_Section.cpp index 9bd6a21..7aa4a12 100644 --- a/src/ELF_Section.cpp +++ b/src/linker/formats/ELF_Section.cpp @@ -1,4 +1,5 @@ -#include "arctyx/ELF_Section.h" +#include "arctyx/linker/formats/ELF_Section.h" +#include "arctyx/linker/formats/ELF_Architecture.h" ELF_Section::ELF_Section() : hashId(0), nameOffset(0), fileOffset(0), type(0), flags(0), vAddr(0), segmentOffset(0), link(0), @@ -143,7 +144,7 @@ void ELF_Section::SetEntries(ehs::UInt_64 newEntries) void ELF_Section::SetData(ehs::Serializer newData) { - data = (ehs::Serializer&&)newData; + data = (ehs::Serializer &&)newData; } ehs::Serializer& ELF_Section::GetData() @@ -151,16 +152,38 @@ ehs::Serializer& ELF_Section::GetData() return data; } -void ELF_Section::Serialize(ehs::Serializer& inData) const +void ELF_Section::Serialize(const ehs::UInt_8 &bitDepth, ehs::Serializer& inData) const { - inData.Write(nameOffset); - inData.Write(type); - inData.Write(flags); - inData.Write(vAddr); - inData.Write(segmentOffset); - inData.Write(data.Size()); - inData.Write(link); - inData.Write(info); - inData.Write(align); - inData.Write(entries); + if (bitDepth == ELF_BIT_DEPTH_64) + Serialize_64(inData); + else if (bitDepth == ELF_BIT_DEPTH_32) + Serialize_32(inData); +} + +void ELF_Section::Serialize_64(ehs::Serializer &data) const +{ + data.Write(nameOffset); + data.Write(type); + data.Write(flags); + data.Write(vAddr); + data.Write(segmentOffset); + data.Write(data.Size()); + data.Write(link); + data.Write(info); + data.Write(align); + data.Write(entries); +} + +void ELF_Section::Serialize_32(ehs::Serializer &data) const +{ + data.Write(nameOffset); + data.Write(type); + data.Write(flags); + data.Write(vAddr); + data.Write(segmentOffset); + data.Write(data.Size()); + data.Write(link); + data.Write(info); + data.Write(align); + data.Write(entries); } diff --git a/src/ELF_Sym.cpp b/src/linker/formats/ELF_Sym.cpp similarity index 92% rename from src/ELF_Sym.cpp rename to src/linker/formats/ELF_Sym.cpp index 5dd90f0..7ec7918 100644 --- a/src/ELF_Sym.cpp +++ b/src/linker/formats/ELF_Sym.cpp @@ -1,4 +1,4 @@ -#include "arctyx/ELF_Sym.h" +#include "arctyx/linker/formats/ELF_Sym.h" ELF_Sym::ELF_Sym() : nameOffset(0), type(0), visibility(0), section(0), value(0), size(0) diff --git a/src/main.cpp b/src/main.cpp index 70d7407..879e39b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ -#include "arctyx/ELF.h" -#include "arctyx/ELF_Sym.h" +#include "arctyx/linker/formats/ELF.h" +#include "arctyx/linker/formats/ELF_Sym.h" #include #include @@ -8,6 +8,7 @@ int main() { ehs::Initialize("Arctyx", "Alpha", {1, 0, 0}); + ehs::Log::EnableImmediateMode(true); ehs::Vector args = ehs::Console::GetArgs_8(); if (args.Size() <= 1) @@ -28,7 +29,7 @@ int main() ELF_Section text(".text", 0x1000, SECH_TYPE_PROGBITS, SECH_FLAG_ALLOC | SECH_FLAG_EXEC, 0x401000, 16); text.SetData(code); - executable.AddSection((ELF_Section&&)text); + executable.AddSection(text); ELF_Section strTab(".strtab", 0, SECH_TYPE_STRTAB, 0, 0, 1); ehs::Serializer& strTabData = strTab.GetData();