]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
sim: ppc: switch register read/writes to union to avoid aliasing issues
authorMike Frysinger <vapier@gentoo.org>
Thu, 11 Jan 2024 04:35:49 +0000 (23:35 -0500)
committerMike Frysinger <vapier@gentoo.org>
Thu, 18 Jan 2024 06:46:27 +0000 (01:46 -0500)
commitdcc6c863ed4e0198f9df590ea86554f550c42237
tree12b08000dc208274976adcb0188b9ef110d70e4d
parent9be58d07909ea72b3351e71121b00b63e3e0d7e7
sim: ppc: switch register read/writes to union to avoid aliasing issues

This code creates a small buffer on the stack w/alloca, then proceeds to
write to it with a cast to a pointer type based on the register type, then
reads from it with a cast to a pointer type based on the register size.
gcc will flags only one of these lines as "maybe used uninitialized", but
it seems to track back to this memory abuse.

Create a large union with all the possible types that this code will read
or write as, and then use those.  It's a bit ugly, but is probably better
than using raw memcpy's everywhere.
sim/ppc/psim.c