aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dyngen-exec.h12
-rw-r--r--target-alpha/op_helper.c6
-rw-r--r--target-arm/op_helper.c5
-rw-r--r--target-cris/op_helper.c5
-rw-r--r--target-i386/helper.c5
-rw-r--r--target-m68k/op_helper.c5
-rw-r--r--target-mips/op_helper.c6
-rw-r--r--target-ppc/op_helper.c5
-rw-r--r--target-sh4/op_helper.c5
-rw-r--r--target-sparc/op_helper.c6
-rw-r--r--tcg/arm/tcg-target.c1
11 files changed, 12 insertions, 49 deletions
diff --git a/dyngen-exec.h b/dyngen-exec.h
index 52cb779de6..f51d363287 100644
--- a/dyngen-exec.h
+++ b/dyngen-exec.h
@@ -287,4 +287,16 @@ extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
#error unsupported CPU
#endif
+/* The return address may point to the start of the next instruction.
+ Subtracting one gets us the call instruction itself. */
+#if defined(__s390__)
+# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
+#elif defined(__arm__)
+/* Thumb return addresses have the low bit set, so we need to subtract two.
+ This is still safe in ARM mode because instructions are 4 bytes. */
+# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
+#else
+# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
+#endif
+
#endif /* !defined(__DYNGEN_EXEC_H__) */
diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c
index 072499e306..36b98b8862 100644
--- a/target-alpha/op_helper.c
+++ b/target-alpha/op_helper.c
@@ -1093,12 +1093,6 @@ void helper_reset_FT2 (void)
/* Softmmu support */
#if !defined (CONFIG_USER_ONLY)
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
-
/* XXX: the two following helpers are pure hacks.
* Hopefully, we emulate the PALcode, then we should never see
* HW_LD / HW_ST instructions.
diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
index 555b55c6bb..5d9fd84883 100644
--- a/target-arm/op_helper.c
+++ b/target-arm/op_helper.c
@@ -68,11 +68,6 @@ uint32_t HELPER(neon_tbl)(uint32_t ireg, uint32_t def,
#if !defined(CONFIG_USER_ONLY)
#define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
#define SHIFT 0
#include "softmmu_template.h"
diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c
index ea8016b43c..abcf9b47ff 100644
--- a/target-cris/op_helper.c
+++ b/target-cris/op_helper.c
@@ -24,11 +24,6 @@
#include "mmu.h"
#define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
#define SHIFT 0
#include "softmmu_template.h"
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 4562a16a83..cab085ad53 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -4663,11 +4663,6 @@ static float approx_rcp(float a)
#if !defined(CONFIG_USER_ONLY)
#define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
#define SHIFT 0
#include "softmmu_template.h"
diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c
index f45c4d97c8..f2e9f03599 100644
--- a/target-m68k/op_helper.c
+++ b/target-m68k/op_helper.c
@@ -32,11 +32,6 @@ void do_interrupt(int is_hw)
extern int semihosting_enabled;
#define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
#define SHIFT 0
#include "softmmu_template.h"
diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 017d12ad7c..2020e9efe3 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -22,12 +22,6 @@
#include "host-utils.h"
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
-
/*****************************************************************************/
/* Exceptions processing helpers */
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index 544d906664..1c08172807 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -2612,11 +2612,6 @@ DO_SPE_OP1(fsctuf);
#if !defined (CONFIG_USER_ONLY)
#define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
#define SHIFT 0
#include "softmmu_template.h"
diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c
index bbc3030266..8c8318f1e3 100644
--- a/target-sh4/op_helper.c
+++ b/target-sh4/op_helper.c
@@ -28,11 +28,6 @@ void do_raise_exception(void)
#ifndef CONFIG_USER_ONLY
#define MMUSUFFIX _mmu
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
#define SHIFT 0
#include "softmmu_template.h"
diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
index 2d855606d6..250f719623 100644
--- a/target-sparc/op_helper.c
+++ b/target-sparc/op_helper.c
@@ -2871,12 +2871,6 @@ static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
#define MMUSUFFIX _mmu
#define ALIGNED_ONLY
-#ifdef __s390__
-# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & \
- 0x7fffffffUL))
-#else
-# define GETPC() (__builtin_return_address(0))
-#endif
#define SHIFT 0
#include "softmmu_template.h"
diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c
index a3f4c6d43c..3ced47ef82 100644
--- a/tcg/arm/tcg-target.c
+++ b/tcg/arm/tcg-target.c
@@ -1180,7 +1180,6 @@ static inline void tcg_out_qemu_st(TCGContext *s, int cond,
tcg_out_bl(s, cond, (tcg_target_long) qemu_st_helpers[s_bits] -
(tcg_target_long) s->code_ptr);
-
# if TARGET_LONG_BITS == 64
if (opc == 3)
tcg_out_dat_imm(s, cond, ARITH_ADD, 13, 13, 0x10);