0002-return-Fix-PowerPC-assembly.patch 1.6 KB

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