diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-01-05 11:10:54 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-01-05 11:14:57 +0100 |
| commit | c3b10ee1e28737375d65c3811f390d77a84fc165 (patch) | |
| tree | 898acd05db58943e7b9203232c00445c17ce4836 /dev/LibCompiler/src/CPlusPlusLinkerELF.cc | |
| parent | b6f625090109568d4bfd9f5fc6bc5c88682795b8 (diff) | |
WIP: ARM64 support is coming soon.
WIP: Prototyping ELF linker for ZkaOS.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/LibCompiler/src/CPlusPlusLinkerELF.cc')
| -rw-r--r-- | dev/LibCompiler/src/CPlusPlusLinkerELF.cc | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/dev/LibCompiler/src/CPlusPlusLinkerELF.cc b/dev/LibCompiler/src/CPlusPlusLinkerELF.cc new file mode 100644 index 0000000..5b85afc --- /dev/null +++ b/dev/LibCompiler/src/CPlusPlusLinkerELF.cc @@ -0,0 +1,92 @@ +/* ------------------------------------------- + + Copyright (C) 2024 Theater Quality Corp, all rights reserved + + @file DynamicLinker64PEF.cc + @brief: C++ 64-Bit PEF Linker. + +------------------------------------------- */ + +/// @author EL Mahrouss Amlal (amlel) +/// @brief TQ 64-bit PEF Linker. +/// Last Rev: Sat Feb 24 CET 2024 +/// @note Do not look up for anything with .code64/.data64/.zero64! +/// It will be loaded when the program loader will start the image. + +//! Toolchain Kit. +#include <LibCompiler/Defines.h> + +#include <LibCompiler/NFC/ErrorID.h> + +//! Assembler Kit +#include <LibCompiler/AAL/AssemblyInterface.h> + +//! Preferred Executable Format +#include <LibCompiler/NFC/XCOFF.h> +#include <LibCompiler/UUID.h> + +//! Release macros. +#include <LibCompiler/Version.h> + +//! Advanced Executable Object Format. +#include <LibCompiler/NFC/AE.h> +#include <cstdint> + +#define kLinkerVersionStr "TQ 64-Bit Linker (ELF) %s, (c) Theater Quality Corp. 2024, all rights reserved.\n" + +#define MemoryCopy(DST, SRC, SZ) memcpy(DST, SRC, SZ) +#define StringCompare(DST, SRC) strcmp(DST, SRC) + +#define kPefNoCpu 0U +#define kPefNoSubCpu 0U + +#define kWhite "\e[0;97m" + +#define kStdOut (std::cout << kWhite << "ld64: ") + +#define kLinkerDefaultOrigin kPefBaseOrigin +#define kLinkerId (0x5046FF) +#define kLinkerAbiContainer "Container:ABI:" + +/// @brief PEF stack size symbol. +#define kLinkerStackSizeSymbol "SizeOfReserveStack" + +namespace Details +{ +struct DynamicLinkerBlob final +{ + std::vector<CharType> fPefBlob; // PEF code/bss/data blob. + std::uintptr_t fAEOffset; // the offset of the PEF container header.. +}; +} + +enum +{ + kABITypeStart = 0x1010, /* Invalid ABI start of ABI list. */ + kABITypeZKA = 0x5046, /* PF (ZKA PEF ABI) */ + kABITypeInvalid = 0xFFFF, +}; + +static Bool kFatBinaryEnable = false; +static Bool kStartFound = false; +static Bool kDuplicateSymbols = false; +static Bool kVerbose = false; + +/* object code and list. */ +static std::vector<LibCompiler::String> kObjectList; +static std::vector<Details::DynamicLinkerBlob> kObjectBytes; + +static uintptr_t kMIBCount = 8; +static uintptr_t kByteCount = 1024; + +#define kPrintF printf +#define kLinkerSplash() kPrintF(kWhite kLinkerVersionStr, kDistVersion) + +/// @brief ZKA 64-bit Linker. +/// @note This linker is made for XCOFF executable, thus ZKA based OSes. +TOOLCHAINKIT_MODULE(DynamicLinker64XCOFF) +{ + return EXIT_SUCCESS; +} + +// Last rev 13-1-24 |
