mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-02-23 13:21:43 +08:00
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. |
||
---|---|---|
.. | ||
callback.c | ||
cgen-accfp.c | ||
cgen-cpu.h | ||
cgen-defs.h | ||
cgen-engine.h | ||
cgen-fpu.c | ||
cgen-fpu.h | ||
cgen-mem.h | ||
cgen-ops.h | ||
cgen-par.c | ||
cgen-par.h | ||
cgen-run.c | ||
cgen-scache.c | ||
cgen-scache.h | ||
cgen-sim.h | ||
cgen-trace.c | ||
cgen-trace.h | ||
cgen-types.h | ||
cgen-utils.c | ||
cgen.sh | ||
ChangeLog-2021 | ||
create-version.sh | ||
defs.h | ||
dv-cfi.c | ||
dv-cfi.h | ||
dv-core.c | ||
dv-glue.c | ||
dv-pal.c | ||
dv-sockser.c | ||
dv-sockser.h | ||
gdbinit.in | ||
genmloop.sh | ||
gennltvals.py | ||
hw-alloc.c | ||
hw-alloc.h | ||
hw-base.c | ||
hw-base.h | ||
hw-device.c | ||
hw-device.h | ||
hw-events.c | ||
hw-events.h | ||
hw-handles.c | ||
hw-handles.h | ||
hw-instances.c | ||
hw-instances.h | ||
hw-main.h | ||
hw-ports.c | ||
hw-ports.h | ||
hw-properties.c | ||
hw-properties.h | ||
hw-tree.c | ||
hw-tree.h | ||
lineno.sh | ||
local.mk | ||
nrun.c | ||
portability.c | ||
portability.h | ||
run.1 | ||
sim-abort.c | ||
sim-alu.h | ||
sim-arange.c | ||
sim-arange.h | ||
sim-assert.h | ||
sim-base.h | ||
sim-basics.h | ||
sim-bits.c | ||
sim-bits.h | ||
sim-close.c | ||
sim-command.c | ||
sim-config.c | ||
sim-config.h | ||
sim-core.c | ||
sim-core.h | ||
sim-cpu.c | ||
sim-cpu.h | ||
sim-endian.c | ||
sim-endian.h | ||
sim-engine.c | ||
sim-engine.h | ||
sim-events.c | ||
sim-events.h | ||
sim-fpu.c | ||
sim-fpu.h | ||
sim-hload.c | ||
sim-hrw.c | ||
sim-hw.c | ||
sim-hw.h | ||
sim-info.c | ||
sim-inline.c | ||
sim-inline.h | ||
sim-io.c | ||
sim-io.h | ||
sim-load.c | ||
sim-memopt.c | ||
sim-memopt.h | ||
sim-model.c | ||
sim-model.h | ||
sim-module.c | ||
sim-module.h | ||
sim-n-bits.h | ||
sim-n-core.h | ||
sim-n-endian.h | ||
sim-options.c | ||
sim-options.h | ||
sim-profile.c | ||
sim-profile.h | ||
sim-reason.c | ||
sim-reg.c | ||
sim-resume.c | ||
sim-run.c | ||
sim-signal.c | ||
sim-signal.h | ||
sim-stop.c | ||
sim-syscall.c | ||
sim-syscall.h | ||
sim-trace.c | ||
sim-trace.h | ||
sim-types.h | ||
sim-utils.c | ||
sim-utils.h | ||
sim-watch.c | ||
sim-watch.h | ||
syscall.c | ||
target-newlib-errno.c | ||
target-newlib-open.c | ||
target-newlib-signal.c | ||
target-newlib-syscall.c | ||
target-newlib-syscall.h | ||
version.h |