From 43d2e8b4dc41d3bfcf7b5934e11c1ef21704b0b0 Mon Sep 17 00:00:00 2001 From: boykopovar Date: Sun, 27 Sep 2026 12:49:46 +0300 Subject: [PATCH] fix(codegen): decode xadd byte and popcnt instruction lengths fix --- .../codegen/include/codegen/x86/X64OpcodeConstants.hpp | 2 ++ core/relinker/codegen/src/x86/X64InstructionDecoder.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/relinker/codegen/include/codegen/x86/X64OpcodeConstants.hpp b/core/relinker/codegen/include/codegen/x86/X64OpcodeConstants.hpp index 237fb8bb7..7448093df 100644 --- a/core/relinker/codegen/include/codegen/x86/X64OpcodeConstants.hpp +++ b/core/relinker/codegen/include/codegen/x86/X64OpcodeConstants.hpp @@ -153,6 +153,8 @@ inline constexpr std::uint8_t TwoByteShldCl = 0xA5; inline constexpr std::uint8_t TwoByteShrdImm8 = 0xAC; inline constexpr std::uint8_t TwoByteShrdCl = 0xAD; inline constexpr std::uint8_t TwoByteGrp15 = 0xAE; +inline constexpr std::uint8_t TwoBytePopcnt = 0xB8; +inline constexpr std::uint8_t TwoByteXaddRm8 = 0xC0; inline constexpr std::uint8_t TwoByteXadd = 0xC1; inline constexpr std::uint8_t TwoBytePextrw = 0xC5; inline constexpr std::uint8_t TwoByteShufpsImm8 = 0xC2; diff --git a/core/relinker/codegen/src/x86/X64InstructionDecoder.cpp b/core/relinker/codegen/src/x86/X64InstructionDecoder.cpp index d574fef6c..665cf6fd2 100644 --- a/core/relinker/codegen/src/x86/X64InstructionDecoder.cpp +++ b/core/relinker/codegen/src/x86/X64InstructionDecoder.cpp @@ -246,7 +246,8 @@ std::size_t X64InstructionDecoder::Decode(const std::uint8_t* data, std::size_t opcode == TwoByteImulRmModRm || opcode == TwoByteGrp7 || opcode == TwoByteGrp15 || - opcode == TwoByteXadd || + opcode == TwoBytePopcnt || + opcode == TwoByteXaddRm8 || opcode == TwoByteXadd || opcode == TwoByteGrp9 || opcode == TwoByteNopModRm || opcode == TwoByteEndbr) { hasModRm = true; @@ -497,7 +498,8 @@ DecodedInstructionInfo X64InstructionDecoder::DecodeInstruction( (op >= TwoBytePrefetchGrpMin && op <= TwoBytePrefetchGrpMax) || (op >= TwoByteSetccMin && op <= TwoByteSetccMax) || op == TwoByteImulRmModRm || op == TwoByteGrp7 || - op == TwoByteGrp15 || op == TwoByteXadd || + op == TwoBytePopcnt || + op == TwoByteGrp15 || op == TwoByteXaddRm8 || op == TwoByteXadd || op == TwoByteGrp9 || op == TwoByteNopModRm || op == TwoByteEndbr || op == TwoByteMovImm8ModRm || (op >= TwoByteShiftImm8Min && op <= TwoByteShiftImm8Max) ||