diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-16 14:05:51 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-16 14:05:51 +0200 |
| commit | 013998a768a00618e344069c0ad2b0048c62e329 (patch) | |
| tree | bc77a2d2ad70d523348114d3b46a2a9887f65d40 /dev/LibCompiler | |
| parent | 81047fcda15a6b1c68fc4de30cb25971f39a209c (diff) | |
cc, LibCompiler: source code refactor and tweaks.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler')
| -rw-r--r-- | dev/LibCompiler/NFC/AE.h | 5 | ||||
| -rw-r--r-- | dev/LibCompiler/NFC/ErrorID.h | 1 | ||||
| -rw-r--r-- | dev/LibCompiler/NFC/PEF.h | 4 | ||||
| -rw-r--r-- | dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc | 6 | ||||
| -rw-r--r-- | dev/LibCompiler/src/DynamicLinkerPEF.cc | 16 |
5 files changed, 18 insertions, 14 deletions
diff --git a/dev/LibCompiler/NFC/AE.h b/dev/LibCompiler/NFC/AE.h index d674c6f..fdf42a5 100644 --- a/dev/LibCompiler/NFC/AE.h +++ b/dev/LibCompiler/NFC/AE.h @@ -19,10 +19,9 @@ #define kAEMagLen (2) #define kAENullType (0x00) -// Advanced Executable File Format for MetroLink. +// 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. +// You can also relocate at runtime but that's up to the operating system loader. namespace LibCompiler { diff --git a/dev/LibCompiler/NFC/ErrorID.h b/dev/LibCompiler/NFC/ErrorID.h index 04cedd2..e7f06e1 100644 --- a/dev/LibCompiler/NFC/ErrorID.h +++ b/dev/LibCompiler/NFC/ErrorID.h @@ -12,6 +12,7 @@ #include <LibCompiler/Defines.h> #include <LibCompiler/NFC/ErrorOr.h> +#define LIBCOMPILER_SUCCESSS 0 #define LIBCOMPILER_EXEC_ERROR -30 #define LIBCOMPILER_FILE_NOT_FOUND -31 #define LIBCOMPILER_DIR_NOT_FOUND -32 diff --git a/dev/LibCompiler/NFC/PEF.h b/dev/LibCompiler/NFC/PEF.h index 7fc5ef4..1148dea 100644 --- a/dev/LibCompiler/NFC/PEF.h +++ b/dev/LibCompiler/NFC/PEF.h @@ -86,7 +86,7 @@ namespace LibCompiler UIntPtr Start; /* Origin of code */ SizeType HdrSz; /* Size of header */ SizeType Count; /* container header count */ - } PACKED PEFContainer; + } PACKED PEFContainer, *PEFContainerPtr; /* First PEFCommandHeader starts after PEFContainer */ /* Last container is __exec_end */ @@ -102,7 +102,7 @@ namespace LibCompiler UInt16 Kind; /* container kind */ UIntPtr Offset; /* file offset */ SizeType Size; /* file size */ - } PACKED PEFCommandHeader; + } PACKED PEFCommandHeader, *PEFCommandHeaderPtr; enum { diff --git a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc index 1d309dd..96a2873 100644 --- a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc +++ b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc @@ -1,7 +1,7 @@ /* * ======================================================== * - * c++-drv + * cxxdrv * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. * * ======================================================== @@ -1126,7 +1126,7 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) std::string err = "Unknown option: "; err += argv[index]; - Detail::print_error(err, "c++-drv"); + Detail::print_error(err, "cxxdrv"); continue; } @@ -1151,7 +1151,7 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) { if (kState.fVerbose) { - Detail::print_error(argv_i + " is not a valid C++ source.\n", "c++-drv"); + Detail::print_error(argv_i + " is not a valid C++ source.\n", "cxxdrv"); } return 1; diff --git a/dev/LibCompiler/src/DynamicLinkerPEF.cc b/dev/LibCompiler/src/DynamicLinkerPEF.cc index 97f6d04..22f268c 100644 --- a/dev/LibCompiler/src/DynamicLinkerPEF.cc +++ b/dev/LibCompiler/src/DynamicLinkerPEF.cc @@ -36,8 +36,8 @@ #define MemoryCopy(DST, SRC, SZ) memcpy(DST, SRC, SZ) #define StringCompare(DST, SRC) strcmp(DST, SRC) -#define kPefNoCpu 0U -#define kPefNoSubCpu 0U +#define kPefNoCpu (0U) +#define kPefNoSubCpu (0U) #define kStdOut (std::cout << "\e[0;31m" \ << "ld64: " \ @@ -69,7 +69,7 @@ enum kABITypeInvalid = 0xFFFF, }; -static LibCompiler::String kOutput = ""; +static LibCompiler::String kOutput = "a.out"; static Int32 kAbi = kABITypeNE; static Int32 kSubArch = kPefNoSubCpu; static Int32 kArch = LibCompiler::kPefArchInvalid; @@ -79,8 +79,8 @@ static Bool kDuplicateSymbols = false; static Bool kVerbose = false; /* ld64 is to be found, mld is to be found at runtime. */ -static const char* kLdDefineSymbol = ":UndefinedSymbol:"; -static const char* kLdDynamicSym = ":RuntimeSymbol:"; +static const CharType* kLdDefineSymbol = ":UndefinedSymbol:"; +static const CharType* kLdDynamicSym = ":RuntimeSymbol:"; /* object code and list. */ static std::vector<LibCompiler::String> kObjectList; @@ -740,7 +740,9 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) } if (kVerbose) + { kStdOut << "wrote contents of: " << kOutput << "\n"; + } // step 3: check if we have those symbols @@ -770,13 +772,15 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) !unreferenced_symbols.empty()) { if (kVerbose) + { kStdOut << "file: " << kOutput << ", is corrupt, removing file...\n"; + } return LIBCOMPILER_EXEC_ERROR; } - return EXIT_SUCCESS; + return LIBCOMPILER_SUCCESSS; } // Last rev 13-1-24 |
