PowerPC: Fix overflow in LOAD/STORE_64LE (fixes #1089)
Vicki Pfau vi@endrift.com
Sat, 26 May 2018 13:09:13 -0700
1 files changed,
5 insertions(+),
4 deletions(-)
jump to
M
include/mgba-util/common.h
→
include/mgba-util/common.h
@@ -136,12 +136,13 @@ uint32_t hi; \
uint32_t lo; \ }; \ uint64_t b64; \ - } *bswap = (void*) &DEST; \ + } bswap; \ const void* _ptr = (ARR); \ __asm__( \ "lwbrx %0, %2, %3 \n" \ "lwbrx %1, %2, %4 \n" \ - : "=&r"(bswap->lo), "=&r"(bswap->hi) : "b"(_ptr), "r"(_addr), "r"(_addr + 4)) ; \ + : "=&r"(bswap.lo), "=&r"(bswap.hi) : "b"(_ptr), "r"(_addr), "r"(_addr + 4)) ; \ + DEST = bswap.b64; \ } #define STORE_64LE(SRC, ADDR, ARR) { \@@ -152,12 +153,12 @@ uint32_t hi; \
uint32_t lo; \ }; \ uint64_t b64; \ - } *bswap = (void*) &SRC; \ + } bswap = { .b64 = SRC }; \ const void* _ptr = (ARR); \ __asm__( \ "stwbrx %0, %2, %3 \n" \ "stwbrx %1, %2, %4 \n" \ - : : "r"(bswap->hi), "r"(bswap->lo), "b"(_ptr), "r"(_addr), "r"(_addr + 4) : "memory"); \ + : : "r"(bswap.hi), "r"(bswap.lo), "b"(_ptr), "r"(_addr), "r"(_addr + 4) : "memory"); \ } #elif defined(__llvm__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)