Skip to content

Commit 67d9756

Browse files
lhsazevedokabeor
andauthored
[next] SH: Use bitwise OR with mask for sign extension (#2389)
* Use bitwise OR with mask for sign extension Sign extend using bitwise OR with mask, instead of unary minus. Fixes error when building for UWP with Security Development Lifecycle (SDL). See https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 * Remove unused store Remove unused store caught by clang-tidy. * Suppress clang-tidy false positive Ignore an unitialized va_list false positive emitted by clang-tidy --------- Co-authored-by: Wu ChenXu <[email protected]>
1 parent 3a2cd3c commit 67d9756

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/SH/SHDisassembler.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1459,13 +1459,13 @@ static bool decode_long(uint32_t code, uint64_t address, MCInst *MI,
14591459
if (code & 0x00010000) {
14601460
// movi20s #imm,
14611461
imm <<= 8;
1462-
if (imm >= 1 << 27)
1463-
imm = -((1 << 28) - imm);
1462+
if (imm & (1 << (28 - 1)))
1463+
imm |= ~((1 << 28) - 1);
14641464
insn = SH_INS_MOVI20S;
14651465
} else {
14661466
// MOVI20
1467-
if (imm >= 1 << 19)
1468-
imm = -((1 << 20) - imm);
1467+
if (imm & (1 << (28 - 1)))
1468+
imm |= ~((1 << 20) - 1);
14691469
insn = SH_INS_MOVI20;
14701470
}
14711471
set_imm(info, 0, imm);

0 commit comments

Comments
 (0)