From 112b49ab7d2af6edea6bad97f2eea98e96ed5428 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 16 Jan 2026 22:54:33 +0100 Subject: feat: implement Mach-O linker and massive improvements on Assembler and Linkers. Signed-off-by: Amlal El Mahrouss --- include/CompilerKit/Utilities/Assembler.h | 40 +++++++------------------------ 1 file changed, 8 insertions(+), 32 deletions(-) (limited to 'include/CompilerKit/Utilities') diff --git a/include/CompilerKit/Utilities/Assembler.h b/include/CompilerKit/Utilities/Assembler.h index 249d69d..9f81dcf 100644 --- a/include/CompilerKit/Utilities/Assembler.h +++ b/include/CompilerKit/Utilities/Assembler.h @@ -28,14 +28,8 @@ inline NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) { switch (lineBuffer[pos + 1]) { case 'x': { - if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 16); !res) { - if (errno != 0) { - Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit"); - throw std::runtime_error("invalid_hex"); - } - } - - NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 16)); + auto res = strtol(lineBuffer.substr(pos + 2).c_str(), nullptr, 16); + NumberCast32 numOffset(strtol(lineBuffer.substr(pos + 2).c_str(), nullptr, 16)); if (kVerbose) { kStdOut << "asm: found a base 16 number here: " << lineBuffer.substr(pos) << "\n"; @@ -44,14 +38,8 @@ inline NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) { return numOffset; } case 'b': { - if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 2); !res) { - if (errno != 0) { - Detail::print_error("invalid binary number:" + lineBuffer, "CompilerKit"); - throw std::runtime_error("invalid_bin"); - } - } - - NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 2)); + auto res = strtol(lineBuffer.substr(pos + 2).c_str(), nullptr, 2); + NumberCast32 numOffset(strtol(lineBuffer.substr(pos + 2).c_str(), nullptr, 2)); if (kVerbose) { kStdOut << "asm: found a base 2 number here:" << lineBuffer.substr(pos) << "\n"; @@ -60,14 +48,8 @@ inline NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) { return numOffset; } case 'o': { - if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 7); !res) { - if (errno != 0) { - Detail::print_error("invalid octal number: " + lineBuffer, "CompilerKit"); - throw std::runtime_error("invalid_octal"); - } - } - - NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 7)); + auto res = strtol(lineBuffer.substr(pos + 2).c_str(), nullptr, 8); + NumberCast32 numOffset(strtol(lineBuffer.substr(pos + 2).c_str(), nullptr, 8)); if (kVerbose) { kStdOut << "asm: found a base 8 number here:" << lineBuffer.substr(pos) << "\n"; @@ -76,14 +58,8 @@ inline NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) { return numOffset; } default: { - if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 10); !res) { - if (errno != 0) { - Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit"); - throw std::runtime_error("invalid_hex"); - } - } - - NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 10)); + auto res = strtol(lineBuffer.substr(pos + 2).c_str(), nullptr, 10); + NumberCast32 numOffset(strtol(lineBuffer.substr(pos + 2).c_str(), nullptr, 10)); if (kVerbose) { kStdOut << "asm: found a base 10 number here:" << lineBuffer.substr(pos) << kStdEndl; -- cgit v1.2.3