From 0e4ad31902f206e2c6945632bb1f558eae941ff1 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 3 May 2017 02:52:15 +0300 Subject: [PATCH] use pc-relative offsets for PIC too --- include/arm_features.h | 4 ++++ libpcsxcore/new_dynarec/linkage_arm.S | 12 ++++++------ plugins/dfsound/arm_utils.S | 10 +++++----- plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S | 21 ++++++--------------- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/include/arm_features.h b/include/arm_features.h index f35e0b7f..7c82ff38 100644 --- a/include/arm_features.h +++ b/include/arm_features.h @@ -73,4 +73,8 @@ #endif +#if defined(__MACH__) || defined(__PIC__) +#define TEXRELS_FORBIDDEN +#endif + #endif /* __ARM_FEATURES_H__ */ diff --git a/libpcsxcore/new_dynarec/linkage_arm.S b/libpcsxcore/new_dynarec/linkage_arm.S index 147b0dfc..d32dc0bf 100644 --- a/libpcsxcore/new_dynarec/linkage_arm.S +++ b/libpcsxcore/new_dynarec/linkage_arm.S @@ -93,7 +93,7 @@ DRC_VAR(restore_candidate, 512) DRC_VAR(FCR0, 4) DRC_VAR(FCR31, 4) -#ifdef __MACH__ +#ifdef TEXRELS_FORBIDDEN .data .align 2 ptr_jump_in: @@ -117,21 +117,21 @@ ptr_hash_table: #endif .macro load_varadr reg var -#if defined(HAVE_ARMV7) && !defined(__PIC__) - movw \reg, #:lower16:\var - movt \reg, #:upper16:\var -#elif defined(HAVE_ARMV7) && defined(__MACH__) +#if defined(HAVE_ARMV7) && defined(TEXRELS_FORBIDDEN) movw \reg, #:lower16:(\var-(1678f+8)) movt \reg, #:upper16:(\var-(1678f+8)) 1678: add \reg, pc +#elif defined(HAVE_ARMV7) && !defined(__PIC__) + movw \reg, #:lower16:\var + movt \reg, #:upper16:\var #else ldr \reg, =\var #endif .endm .macro load_varadr_ext reg var -#if defined(HAVE_ARMV7) && defined(__MACH__) && defined(__PIC__) +#if defined(HAVE_ARMV7) && defined(TEXRELS_FORBIDDEN) movw \reg, #:lower16:(ptr_\var-(1678f+8)) movt \reg, #:upper16:(ptr_\var-(1678f+8)) 1678: diff --git a/plugins/dfsound/arm_utils.S b/plugins/dfsound/arm_utils.S index eaeca518..8ac7c30a 100644 --- a/plugins/dfsound/arm_utils.S +++ b/plugins/dfsound/arm_utils.S @@ -10,7 +10,7 @@ #include "arm_features.h" -#ifdef __MACH__ +#ifdef TEXRELS_FORBIDDEN .data .align 2 ptr_ChanBuf: .word ESYM(ChanBuf) @@ -20,14 +20,14 @@ ptr_ChanBuf: .word ESYM(ChanBuf) .align 2 .macro load_varadr reg var -#if defined(HAVE_ARMV7) && !defined(__PIC__) - movw \reg, #:lower16:ESYM(\var) - movt \reg, #:upper16:ESYM(\var) -#elif defined(HAVE_ARMV7) && defined(__MACH__) +#if defined(HAVE_ARMV7) && defined(TEXRELS_FORBIDDEN) movw \reg, #:lower16:(ptr_\var-(1678f+8)) movt \reg, #:upper16:(ptr_\var-(1678f+8)) 1678: ldr \reg, [pc, \reg] +#elif defined(HAVE_ARMV7) && !defined(__PIC__) + movw \reg, #:lower16:ESYM(\var) + movt \reg, #:upper16:ESYM(\var) #else ldr \reg, =ESYM(\var) #endif diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S b/plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S index 110c868a..7c820d27 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S +++ b/plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S @@ -194,26 +194,18 @@ .align 4 -#ifndef __MACH__ +#include "arm_features.h" -#define function(name) \ - .global name; \ - .type name, %function; \ - name: \ +#define function(name) FUNCTION(name): + +#ifndef TEXRELS_FORBIDDEN #define JT_OP_REL(table_label, index_reg, temp) #define JT_OP(x...) x #define JTE(start, target) target -#define EXTRA_UNSAVED_REGS - #else -#define function(name) \ - .globl _##name; \ - name: \ - _##name: \ - #define JT_OP_REL(table_label, index_reg, temp) \ adr temp, table_label; \ ldr temp, [temp, index_reg, lsl #2]; \ @@ -222,13 +214,12 @@ #define JT_OP(x...) #define JTE(start, target) (target - start) -// r7 is preserved, but add it for EABI alignment.. -#define EXTRA_UNSAVED_REGS r7, r9, +#endif +#ifdef __MACH__ #define flush_render_block_buffer _flush_render_block_buffer #define setup_sprite_untextured_simple _setup_sprite_untextured_simple #define update_texture_8bpp_cache _update_texture_8bpp_cache - #endif @ r0: psx_gpu -- 2.39.5