summaryrefslogtreecommitdiffhomepage
path: root/Private/KernelKit/PEF.hpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-26 22:26:48 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-26 22:27:09 +0100
commiteba8b7ddd0a455d9e49f32dcae712c5612c0093c (patch)
tree749a3d34546d055507a920bce4ab10e8a9945719 /Private/KernelKit/PEF.hpp
parentdd192787a70a973f2474720aea49af3f6ddabb7a (diff)
Kernel: Major repository refactor.
Rework the repo into Private and Public modules. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/KernelKit/PEF.hpp')
-rw-r--r--Private/KernelKit/PEF.hpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/Private/KernelKit/PEF.hpp b/Private/KernelKit/PEF.hpp
new file mode 100644
index 00000000..a2f5c5b8
--- /dev/null
+++ b/Private/KernelKit/PEF.hpp
@@ -0,0 +1,94 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright 2024 Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#ifndef _INC_LOADER_PEF_HPP
+#define _INC_LOADER_PEF_HPP
+
+#include <NewKit/Defines.hpp>
+#include <KernelKit/Loader.hpp>
+#include <CompilerKit/Compiler.hpp>
+
+#define kPefMagic "PEF"
+#define kPefMagicFat "FEP"
+
+#define kPefMagicLen 3
+
+#define kPefVersion 1
+#define kPefNameLen 64
+
+// @brief Preferred Executable Format, a format designed for any computer.
+
+namespace hCore
+{
+ enum
+ {
+ kPefArchIntel86S,
+ kPefArchAMD64,
+ kPefArchRISCV,
+ kPefArch64x0, /* 64x000. */
+ kPefArch32x0,
+ kPefArchInvalid = 0xFF,
+ };
+
+ enum
+ {
+ kPefKindExec = 1, /* .exe */
+ kPefKindSharedObject = 2, /* .lib */
+ kPefKindObject = 4, /* .obj */
+ kPefKindDebug = 5, /* .debug */
+ };
+
+ typedef struct PEFContainer final
+ {
+ Char Magic[kPefMagicLen];
+ UInt32 Linker;
+ UInt32 Version;
+ UInt32 Kind;
+ UInt32 Abi;
+ UInt32 Cpu;
+ UInt32 SubCpu; /* Cpu specific information */
+ UIntPtr Start;
+ SizeT HdrSz; /* Size of header */
+ SizeT Count; /* container header count */
+ } __attribute__((packed)) PEFContainer;
+
+ /* First PEFCommandHeader starts after PEFContainer */
+ /* Last container is __exec_end */
+
+ /* PEF executable section and commands. */
+
+ typedef struct PEFCommandHeader final
+ {
+ Char Name[kPefNameLen]; /* container name */
+ UInt32 Flags; /* container flags */
+ UInt16 Kind; /* container kind */
+ UIntPtr Offset; /* content offset */
+ SizeT Size; /* content Size */
+ } __attribute__((packed)) PEFCommandHeader;
+
+ enum
+ {
+ kPefCode = 0xC,
+ kPefData = 0xD,
+ kPefZero = 0xE,
+ kPefLinkerID = 0x1,
+ };
+}
+
+#define kPefExt ".o"
+#define kPefDylibExt ".so"
+#define kPefObjectExt ".o"
+#define kPefDebugExt ".dbg"
+
+// hCore System Binary Interface.
+#define kPefAbi (0xDEAD2)
+
+#define kPefStart "__start"
+
+#endif /* ifndef _INC_LOADER_PEF_HPP */