summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler/NFC/AE.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-19 17:33:26 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-19 17:33:26 +0200
commitbefde76cfa46c766e81f74eb5ac65d3dae2dde87 (patch)
tree45b2f9fd6b3f9605c2747485bd24483192f99e73 /dev/LibCompiler/NFC/AE.h
parent3afc481dc64a07fe7fcaff9ce7a12a492c3ec8e7 (diff)
dev, LibCompiler, tooling: refactor and separate components into modules
(cppdrv, cxxdrv) Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler/NFC/AE.h')
-rw-r--r--dev/LibCompiler/NFC/AE.h142
1 files changed, 0 insertions, 142 deletions
diff --git a/dev/LibCompiler/NFC/AE.h b/dev/LibCompiler/NFC/AE.h
deleted file mode 100644
index fdf42a5..0000000
--- a/dev/LibCompiler/NFC/AE.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * ========================================================
- *
- * LibCompiler
- * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
- *
- * ========================================================
- */
-
-#pragma once
-
-#include <LibCompiler/Defines.h>
-
-#define kAEMag0 'A'
-#define kAEMag1 'E'
-
-#define kAESymbolLen (255)
-#define kAEPad (8)
-#define kAEMagLen (2)
-#define kAENullType (0x00)
-
-// Advanced Executable File Format for ld64.
-// Reloctable by offset is the default strategy.
-// You can also relocate at runtime but that's up to the operating system loader.
-
-namespace LibCompiler
-{
- // @brief Advanced Executable Header
- // One thing to keep in mind.
- // This object format, is reloctable.
- typedef struct AEHeader final
- {
- CharType fMagic[kAEMagLen];
- CharType fArch;
- CharType fSubArch;
- SizeType fCount;
- CharType fSize;
- SizeType fStartCode;
- SizeType fCodeSize;
- CharType fPad[kAEPad];
- } PACKED AEHeader, *AEHeaderPtr;
-
- // @brief Advanced Executable Record.
- // Could be data, code or bss.
- // fKind must be filled with PEF fields.
-
- typedef struct AERecordHeader final
- {
- CharType fName[kAESymbolLen];
- SizeType fKind;
- SizeType fSize;
- SizeType fFlags;
- UIntPtr fOffset;
- CharType fPad[kAEPad];
- } PACKED AERecordHeader, *AERecordHeaderPtr;
-
- enum
- {
- kKindRelocationByOffset = 0x23f,
- kKindRelocationAtRuntime = 0x34f,
- };
-} // namespace LibCompiler
-
-// provide operator<< for AE
-
-inline std::ofstream& operator<<(std::ofstream& fp, LibCompiler::AEHeader& container)
-{
- fp.write((char*)&container, sizeof(LibCompiler::AEHeader));
-
- return fp;
-}
-
-inline std::ofstream& operator<<(std::ofstream& fp,
- LibCompiler::AERecordHeader& container)
-{
- fp.write((char*)&container, sizeof(LibCompiler::AERecordHeader));
-
- return fp;
-}
-
-inline std::ifstream& operator>>(std::ifstream& fp, LibCompiler::AEHeader& container)
-{
- fp.read((char*)&container, sizeof(LibCompiler::AEHeader));
- return fp;
-}
-
-inline std::ifstream& operator>>(std::ifstream& fp,
- LibCompiler::AERecordHeader& container)
-{
- fp.read((char*)&container, sizeof(LibCompiler::AERecordHeader));
- return fp;
-}
-
-namespace LibCompiler::Utils
-{
- /**
- * @brief AE Reader protocol
- *
- */
- class AEReadableProtocol final
- {
- public:
- std::ifstream FP;
-
- public:
- explicit AEReadableProtocol() = default;
- ~AEReadableProtocol() = default;
-
- LIBCOMPILER_COPY_DELETE(AEReadableProtocol);
-
- /**
- * @brief Read AE Record headers.
- *
- * @param raw the containing buffer
- * @param sz it's size (1 = one AERecordHeader, 2 two AERecordHeader(s))
- * @return AERecordHeaderPtr
- */
- AERecordHeaderPtr Read(char* raw, std::size_t sz)
- {
- if (!raw)
- return nullptr;
-
- return this->_Read<AERecordHeader>(raw, sz * sizeof(AERecordHeader));
- }
-
- private:
- /**
- * @brief Implementation of Read for raw classes.
- *
- * @tparam TypeClass The class to read.
- * @param raw the buffer
- * @param sz the size
- * @return TypeClass* the returning class.
- */
- template <typename TypeClass>
- TypeClass* _Read(char* raw, std::size_t sz)
- {
- FP.read(raw, std::streamsize(sz));
- return reinterpret_cast<TypeClass*>(raw);
- }
- };
-} // namespace LibCompiler::Utils