feat(relinker): --to-intel lowers SSE4a sites to same-length jumps into an appended stub section

EXTRQ, INSERTQ, MOVNTSS and MOVNTSD are rewritten at relink time: same-length in-place forms
where they exist, otherwise a jmp rel32 into an appended executable section holding a
scratch-free SSE body and a jump back, so no code shifts and no RIP-relative or jump-table
operand needs adjusting. Decoder fixes for POPCNT and 0F BB (BTC), codegen and elfpatcher
tests, README and technical-debt notes. The runtime illegal-instruction trap stays as a
fallback.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
This commit is contained in:
devilismyfriendandClaude Fable 5.1 committed 2026-09-26 19:00:39 -07:00
1 parent af3c2024ed
commit 01c4e3edf7
28 files changed
+1515 -77

No files matched your search

@@ -1,7 +1,9 @@
#include <codegen/IInstructionScanner.hpp>
#include <codegen/CodegenException.hpp>
#include <codegen/x86/X64InstructionDecoder.hpp>
#include <algorithm>
#include <memory>
#include <string>
namespace Codegen {
@@ -29,7 +31,12 @@ std::vector<InstructionMatch> InstructionScanner::ScanCodeSection(
const std::uint8_t* cursor = codeSection.data() + i;
const std::size_t available = limit - i;
const std::size_t length = decoder.Decode(cursor, available);
std::size_t length = 0;
try {
length = decoder.Decode(cursor, available);
} catch (const CodegenException& e) {
throw CodegenException(std::string("Cannot decode instruction: ") + e.what(), codeSectionOffset + i);
}
matches.push_back({codeSectionOffset + i, length});