1From 6d87fc890c3de81ee33baf25d7c3c86532f26060 Mon Sep 17 00:00:00 2001 2From: Joel Stanley <joel@jms.id.au> 3Date: Mon, 9 May 2022 20:27:58 +0930 4Subject: [PATCH] return: Fix PowerPC assembly 5 6The original assembly used suspicious syntax. However, due to the 7!defined(__OPTIMIZE__) guard this code was rarely built. 8 9There nothing to stop the compiler using r0 between the two asm blocks, 10which may have been the cause of the note mentioning it failed when 11build with optimisation enabled. 12 13Write a single asm statement that places the result in the given 14location. 15 16This builds for powerpc64le and passes tests. 17 18Signed-off-by: Joel Stanley <joel@jms.id.au> 19Upstream: https://github.com/j256/dmalloc/pull/113 20--- 21 return.h | 13 +++---------- 22 1 file changed, 3 insertions(+), 10 deletions(-) 23 24diff --git a/return.h b/return.h 25index 55b9369fe12d..fafbe3754f0f 100644 26--- a/return.h 27+++ b/return.h 28@@ -260,20 +260,13 @@ asm void ASM_GET_RET_ADDR(file) 29 /*************************************/ 30 31 /* 32- * For Powerpc 603 based system running LynxOS 2.3.1 using gcc/gas. 33- */ 34-#if defined(__powerpc__) && defined(__GNUC__) && !defined(__OPTIMIZE__) 35- 36-/* 37- * This won't compile if "-O2" is used, but it seems to work fine with 38- * "-O0". I'm no assembler expert; I was happy enough to come up with 39- * something that works at all... :-) 40+ * For PowerPC using gcc/gas. 41 */ 42+#if defined(__powerpc__) && defined(__GNUC__) 43 44 #define GET_RET_ADDR(file) \ 45 do { \ 46- asm("mflr 0"); \ 47- asm("stw 0,%0" : "=g" (file)); \ 48+ asm("mflr %0" : "=r" (file)); \ 49 } while(0) 50 51 #endif /* __powerpc__ && __GNUC__ && !__OPTIMIZE__ */ 52-- 532.35.1 54 55