mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-18 12:24:38 +08:00
b2ea48df92
The cgen code uses DI as int64_t and UDI as uint64_t. The DI macros are used to construct 64-bit values from 32-bit values (for the low and high parts). The MAKEDI macro casts the high 32-bit value to a signed 32-bit value before shifting. If this created a negative value, this would be undefined behavior according to the C standard. All we care about is shifting the 32-bits as they are to the high 32-bits, not caring about sign extension (since there's nothing left to shift into), and the low 32-bits being empty. This is what we get from shifting an unsigned value, so cast it to unsigned 32-bit to avoid undefined behavior. While we're here, change the SETLODI macro to truncate the lower value to 32-bits before we set it. If it was passing in a 64-bit value, those high bits would get included too, and that's not what we want. Similarly, tweak the SETHIDI macro to cast the value to an unsigned 64-bit instead of a signed 64-bit. If the value was only 32-bits, the behavior would be the same. If it happened to be signed 64-bit, it would trigger the undefined behavior too. |
||
---|---|---|
.. | ||
aarch64 | ||
arm | ||
avr | ||
bfin | ||
bpf | ||
common | ||
cr16 | ||
cris | ||
d10v | ||
erc32 | ||
example-synacor | ||
frv | ||
ft32 | ||
h8300 | ||
igen | ||
iq2000 | ||
lm32 | ||
m4 | ||
m32c | ||
m32r | ||
m68hc11 | ||
mcore | ||
microblaze | ||
mips | ||
mn10300 | ||
moxie | ||
msp430 | ||
or1k | ||
ppc | ||
pru | ||
riscv | ||
rl78 | ||
rx | ||
sh | ||
testsuite | ||
v850 | ||
.gitignore | ||
aclocal.m4 | ||
ChangeLog-2021 | ||
config.h.in | ||
configure | ||
configure.ac | ||
COPYING | ||
gdbinit.in | ||
MAINTAINERS | ||
Makefile.am | ||
Makefile.in | ||
README-HACKING |