mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 13:06:56 +00:00
[ARM] Fix abs overflow when encoding instructions like strb r1, [r0], #-0
Tested by llvm/test/MC/ARM/basic-thumb2-instructions.s. Caught by newer -fsanitize=signed-integer-overflow (D156821). (cherry picked from commit d8900f661a6e451be0ca253df3065254008dd93a)
This commit is contained in:
parent
3444abf2f3
commit
0c756c5906
@ -1672,9 +1672,9 @@ getT2AddrModeImm8OffsetOpValue(const MCInst &MI, unsigned OpNum,
|
||||
|
||||
// FIXME: Needs fixup support.
|
||||
unsigned Value = 0;
|
||||
int32_t tmp = (int32_t)MO1.getImm();
|
||||
if (tmp < 0)
|
||||
tmp = abs(tmp);
|
||||
auto tmp = static_cast<uint32_t>(MO1.getImm());
|
||||
if (static_cast<int32_t>(tmp) < 0)
|
||||
tmp = -tmp;
|
||||
else
|
||||
Value |= 256; // Set the ADD bit
|
||||
Value |= tmp & 255;
|
||||
|
Loading…
x
Reference in New Issue
Block a user