remove textrels with -fPIC/-fPIE (for android/ios)

This commit is contained in:
kub 2019-12-03 23:52:13 +01:00
parent 4f992bf541
commit 9760505eaf
10 changed files with 298 additions and 261 deletions

View file

@ -7,6 +7,7 @@
@* See COPYING file in the top-level directory.
@*
#include "pico/arm_features.h"
#include "pico/pico_int_offs.h"
.extern Pico32x
@ -17,11 +18,12 @@
.text
.align 2
PIC_LDR_INIT()
.macro call_scan_prep cond est @ &Pico.est
.if \cond
ldr r4, =PicoScan32xBegin
ldr r5, =PicoScan32xEnd
PIC_LDR(r4, r6, PicoScan32xBegin)
PIC_LDR(r5, r6, PicoScan32xEnd)
ldr r6, [\est, #OFS_EST_DrawLineDest]
ldr r4, [r4]
ldr r5, [r5]
@ -66,8 +68,8 @@
\name:
stmfd sp!, {r4-r11,lr}
ldr lr,=Pico
ldr r10,=Pico32x
PIC_LDR(lr, r9, Pico)
PIC_LDR(r10,r9, Pico32x)
ldr r11, [lr, #OFS_Pico_est+OFS_EST_Draw2FB]
ldrh r10,[r10, #0x40] @ Pico32x.vdp_regs[0]
add r9, lr, #OFS_Pico_est+OFS_EST_HighPal @ palmd
@ -192,8 +194,8 @@
\name:
stmfd sp!, {r4-r11,lr}
ldr lr,=Pico
ldr r10,=Pico32xMem
PIC_LDR(lr, r9, Pico)
PIC_LDR(r10,r9, Pico32xMem)
ldr r9,=OFS_PMEM32x_pal_native
ldr r10, [r10]
ldr r11, [lr, #OFS_Pico_est+OFS_EST_Draw2FB]
@ -361,8 +363,8 @@
\name:
stmfd sp!, {r4-r11,lr}
ldr lr,=Pico
ldr r10,=Pico32xMem
PIC_LDR(lr, r9, Pico)
PIC_LDR(r10,r9, Pico32xMem)
ldr r9,=OFS_PMEM32x_pal_native
ldr r10, [r10]
ldr r11, [lr, #OFS_Pico_est+OFS_EST_Draw2FB]

View file

@ -49,4 +49,36 @@
#endif
// indexed branch (XB) via branch table (BT)
#ifdef __PIC__
#define PIC_XB(c,r,s) add##c pc, r, s
#define PIC_BT(a) b a
#else
#define PIC_XB(c,r,s) ldr##c pc, [pc, r, s]
#define PIC_BT(a) .word a
#endif
// load data address (LDR) either via literal pool or via GOT
#ifdef __PIC__
// can't use pool loads since ldr= only allows symbol or constants, not expr :-(
#define PIC_LDR_INIT() \
.ifndef PIC_LDR_DEF; PIC_LDR_DEF=1; \
.macro pic_ldr r t a; \
ldr \r, [pc, $.LD\@-.-8]; \
ldr \t, [pc, $.LD\@-.-4]; \
.LP\@:add \r, pc; \
ldr \r, [\r, \t]; \
add pc, $4; \
.LD\@:.word _GLOBAL_OFFSET_TABLE_-.LP\@-8; \
.word \a(GOT); \
.endm; \
.endif;
#define PIC_LDR(r,t,a) \
pic_ldr r, t, a
#else
#define PIC_LDR_INIT()
#define PIC_LDR(r,t,a) \
ldr r, =a
#endif
#endif /* __ARM_FEATURES_H__ */

View file

@ -6,6 +6,7 @@
@* See COPYING file in the top-level directory.
@*
#include "../arm_features.h"
#include "../pico_int_offs.h"
.equiv PCM_STEP_SHIFT, 11
@ -65,6 +66,7 @@
.extern PicoWrite16_io
.extern m68k_comm_check
PIC_LDR_INIT()
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -73,16 +75,16 @@
@ r0=addr[in,out], r1,r2=tmp
.macro cell_map
ands r1, r0, #0x01c000
ldrne pc, [pc, r1, lsr #12]
beq 0f @ most common?
.long 0f
.long 0f
.long 0f
.long 0f
.long 1f
.long 1f
.long 2f
.long 3f
PIC_XB(ne ,r1, lsr #12)
b 0f @ most common?
PIC_BT(0f)
PIC_BT(0f)
PIC_BT(0f)
PIC_BT(0f)
PIC_BT(1f)
PIC_BT(1f)
PIC_BT(2f)
PIC_BT(3f)
1: @ x16 cells
and r1, r0, #0x7e00 @ col
and r2, r0, #0x01fc @ row
@ -128,7 +130,7 @@ PicoReadM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged
mov r3, #0x0e0000
0:
cell_map
ldr r1, =Pico
PIC_LDR(r1, r2, Pico)
add r0, r0, r3
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd (used everywhere)
eor r0, r0, #1
@ -141,26 +143,26 @@ PicoRead8_mcd_io:
cmp r1, #0x2000 @ a120xx?
bne PicoRead8_io
ldr r1, =Pico
PIC_LDR(r1, r2, Pico)
and r0, r0, #0x3f
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
cmp r0, #0x0e
ldrlt pc, [pc, r0, lsl #2]
PIC_XB(lt ,r0, lsl #2)
b m_m68k_read8_hi
.long m_m68k_read8_r00
.long m_m68k_read8_r01
.long m_m68k_read8_r02
.long m_m68k_read8_r03
.long m_m68k_read8_r04
.long m_read_null @ unused bits
.long m_m68k_read8_r06
.long m_m68k_read8_r07
.long m_m68k_read8_r08
.long m_m68k_read8_r09
.long m_read_null @ reserved
.long m_read_null
.long m_m68k_read8_r0c
.long m_m68k_read8_r0d
PIC_BT(m_m68k_read8_r00)
PIC_BT(m_m68k_read8_r01)
PIC_BT(m_m68k_read8_r02)
PIC_BT(m_m68k_read8_r03)
PIC_BT(m_m68k_read8_r04)
PIC_BT(m_read_null) @ unused bits
PIC_BT(m_m68k_read8_r06)
PIC_BT(m_m68k_read8_r07)
PIC_BT(m_m68k_read8_r08)
PIC_BT(m_m68k_read8_r09)
PIC_BT(m_read_null) @ reserved
PIC_BT(m_read_null)
PIC_BT(m_m68k_read8_r0c)
PIC_BT(m_m68k_read8_r0d)
m_m68k_read8_r00:
add r1, r1, #0x110000
ldr r0, [r1, #0x30]
@ -238,7 +240,7 @@ PicoReadM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged
mov r3, #0x0e0000
0:
cell_map
ldr r1, =Pico
PIC_LDR(r1, r2, Pico)
add r0, r0, r3
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
bic r0, r0, #1
@ -252,19 +254,19 @@ PicoRead16_mcd_io:
bne PicoRead16_io
m_m68k_read16_m68k_regs:
ldr r1, =Pico
PIC_LDR(r1, r2, Pico)
and r0, r0, #0x3e
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
cmp r0, #0x0e
ldrlt pc, [pc, r0, lsl #1]
PIC_XB(lt ,r0, lsl #1)
b m_m68k_read16_hi
.long m_m68k_read16_r00
.long m_m68k_read16_r02
.long m_m68k_read16_r04
.long m_m68k_read16_r06
.long m_m68k_read16_r08
.long m_read_null @ reserved
.long m_m68k_read16_r0c
PIC_BT(m_m68k_read16_r00)
PIC_BT(m_m68k_read16_r02)
PIC_BT(m_m68k_read16_r04)
PIC_BT(m_m68k_read16_r06)
PIC_BT(m_m68k_read16_r08)
PIC_BT(m_read_null) @ reserved
PIC_BT(m_m68k_read16_r0c)
m_m68k_read16_r00:
add r1, r1, #0x110000
ldr r0, [r1, #0x30]
@ -329,7 +331,7 @@ PicoWriteM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged
0:
mov r3, r1
cell_map
ldr r2, =Pico
PIC_LDR(r2, r1, Pico)
add r0, r0, r12
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
ldr r2, [r2]
@ -357,7 +359,7 @@ PicoWriteM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged
0:
mov r3, r1
cell_map
ldr r1, =Pico
PIC_LDR(r1, r2, Pico)
add r0, r0, r12
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
bic r0, r0, #1
@ -399,7 +401,7 @@ PicoReadS68k8_dec0: @ 0x080000 - 0x0bffff
PicoReadS68k8_dec1:
mov r3, #0x0a0000 @ + ^ / 2
0:
ldr r2, =Pico
PIC_LDR(r2, r1, Pico)
eor r0, r0, #2
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
movs r0, r0, lsr #1 @ +4-6 <<16
@ -431,7 +433,7 @@ m_s68k_read8_regs:
bx lr
m_s68k_read8_comm:
ldr r1, =Pico
PIC_LDR(r1, r2, Pico)
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
add r1, r1, #0x110000
ldrb r1, [r1, r0]
@ -444,7 +446,7 @@ m_s68k_read8_pcm:
bne m_read_null
@ must not trash r3 and r12
ldr r1, =Pico
PIC_LDR(r1, r2, Pico)
bic r0, r0, #0xff0000
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
mov r2, #0x110000
@ -479,7 +481,7 @@ PicoReadS68k16_dec0: @ 0x080000 - 0x0bffff
PicoReadS68k16_dec1:
mov r3, #0x0a0000 @ + ^ / 2
0:
ldr r2, =Pico
PIC_LDR(r2, r1, Pico)
eor r0, r0, #2
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
mov r0, r0, lsr #1 @ +4-6 <<16
@ -505,12 +507,11 @@ m_s68k_read16_regs:
mov r0, #1
b cdc_host_r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
.macro m_s68k_write8_2M_decode
ldr r2, =Pico
PIC_LDR(r2, ip, Pico)
eor r0, r0, #2
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
movs r0, r0, lsr #1 @ +4-6 <<16
@ -594,7 +595,7 @@ m_s68k_write8_pcm:
bxlt lr
m_s68k_write8_pcm_ram:
ldr r3, =Pico
PIC_LDR(r3, r2, Pico)
bic r0, r0, #0x00e000
ldr r3, [r3, #OFS_Pico_rom] @ Pico.mcd
mov r0, r0, lsr #1
@ -608,12 +609,11 @@ m_s68k_write8_pcm_ram:
strb r1, [r3, r0]
bx lr
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
.macro m_s68k_write16_2M_decode
ldr r2, =Pico
PIC_LDR(r2, ip, Pico)
eor r0, r0, #2
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
mov r0, r0, lsr #1 @ +4-6 <<16
@ -694,7 +694,7 @@ m_s68k_write16_regs:
bne s68k_reg_write16
m_s68k_write16_regs_spec: @ special case
ldr r2, =Pico
PIC_LDR(r2, r0, Pico)
mov r0, #0x110000
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
add r0, r0, #0x00000f
@ -707,7 +707,7 @@ m_s68k_write16_regs_spec: @ special case
.global s68k_write16
s68k_read8:
ldr r3, =s68k_read8_map
PIC_LDR(r3, r2, s68k_read8_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -718,7 +718,7 @@ s68k_read8:
bx r3
s68k_read16:
ldr r3, =s68k_read16_map
PIC_LDR(r3, r2, s68k_read16_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -729,7 +729,7 @@ s68k_read16:
bx r3
s68k_read32:
ldr r3, =s68k_read16_map
PIC_LDR(r3, r2, s68k_read16_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -755,7 +755,7 @@ s68k_read32:
bx lr
s68k_write8:
ldr r3, =s68k_write8_map
PIC_LDR(r3, r2, s68k_write8_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -766,7 +766,7 @@ s68k_write8:
bx r3
s68k_write16:
ldr r3, =s68k_write16_map
PIC_LDR(r3, r2, s68k_write16_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -777,7 +777,7 @@ s68k_write16:
bx r3
s68k_write32:
ldr r3, =s68k_write16_map
PIC_LDR(r3, r2, s68k_write16_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]

View file

@ -7,6 +7,7 @@
* See COPYING file in the top-level directory.
*/
#include "arm_features.h"
#include "pico_int_offs.h"
.equ SRR_MAPPED, (1 << 0)
@ -24,8 +25,10 @@
.global PicoWrite8_io
.global PicoWrite16_io
PIC_LDR_INIT()
PicoRead8_sram: @ u32 a
ldr r3, =Pico
PIC_LDR(r3, r1, Pico)
ldr r1, [r3, #OFS_Pico_sv_end]
cmp r0, r1
bgt m_read8_nosram
@ -74,7 +77,7 @@ m_read8_not_io:
cmp r2, #0x1000
bne PicoRead8_32x
ldr r3, =Pico
PIC_LDR(r3, r1, Pico)
mov r1, r0
ldr r0, [r3, #OFS_Pico_m_rotate]
add r0, r0, #1
@ -97,7 +100,7 @@ m_read8_not_io:
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
PicoRead16_sram: @ u32 a, u32 d
ldr r3, =Pico
PIC_LDR(r3, r1, Pico)
ldr r1, [r3, #OFS_Pico_sv_end]
cmp r0, r1
bgt m_read16_nosram
@ -142,7 +145,7 @@ m_read16_not_io:
cmp r2, #0x1000
bne PicoRead16_32x
ldr r3, =Pico
PIC_LDR(r3, r2, Pico)
and r2, r0, #0xff00
ldr r0, [r3, #OFS_Pico_m_rotate]
add r0, r0, #1
@ -184,7 +187,7 @@ m_write8_not_z80ctl:
eor r2, r2, #0x003000
eors r2, r2, #0x0000f1
bne PicoWrite8_32x
ldr r3, =Pico
PIC_LDR(r3, r2, Pico)
ldrb r2, [r3, #OFS_Pico_m_sram_reg]
and r1, r1, #(SRR_MAPPED|SRR_READONLY)
bic r2, r2, #(SRR_MAPPED|SRR_READONLY)
@ -214,7 +217,7 @@ m_write16_not_z80ctl:
eor r2, r2, #0x003000
eors r2, r2, #0x0000f0
bne PicoWrite16_32x
ldr r3, =Pico
PIC_LDR(r3, r2, Pico)
ldrb r2, [r3, #OFS_Pico_m_sram_reg]
and r1, r1, #(SRR_MAPPED|SRR_READONLY)
bic r2, r2, #(SRR_MAPPED|SRR_READONLY)
@ -228,7 +231,7 @@ m_write16_not_z80ctl:
.global m68k_write16
m68k_read8:
ldr r3, =m68k_read8_map
PIC_LDR(r3, r2, m68k_read8_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -239,7 +242,7 @@ m68k_read8:
bx r3
m68k_read16:
ldr r3, =m68k_read16_map
PIC_LDR(r3, r2, m68k_read16_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -250,7 +253,7 @@ m68k_read16:
bx r3
m68k_read32:
ldr r3, =m68k_read16_map
PIC_LDR(r3, r2, m68k_read16_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -276,7 +279,7 @@ m68k_read32:
bx lr
m68k_write8:
ldr r3, =m68k_write8_map
PIC_LDR(r3, r2, m68k_write8_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -287,7 +290,7 @@ m68k_write8:
bx r3
m68k_write16:
ldr r3, =m68k_write16_map
PIC_LDR(r3, r2, m68k_write16_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]
@ -298,7 +301,7 @@ m68k_write16:
bx r3
m68k_write32:
ldr r3, =m68k_write16_map
PIC_LDR(r3, r2, m68k_write16_map)
bic r0, r0, #0xff000000
mov r2, r0, lsr #16
ldr r3, [r3, r2, lsl #2]

View file

@ -12,6 +12,8 @@
@ vim:filetype=armasm
#include "../arm_features.h"
.equiv SLOT1, 0
.equiv SLOT2, 2
.equiv SLOT3, 1
@ -34,6 +36,7 @@
.text
.align 2
PIC_LDR_INIT()
@ r5=slot, r1=eg_cnt, trashes: r0,r2,r3
@ writes output to routp, but only if vol_out changes
@ -556,8 +559,8 @@ upd_algo0:
stmfd sp!, {r4-r10,lr}
mov lr, r0
ldr r3, =ym_sin_tab
ldr r5, =ym_tl_tab
PIC_LDR(r3, ip, ym_sin_tab)
PIC_LDR(r5, ip, ym_tl_tab)
ldmia lr, {r6-r7}
ldr r10, [lr, #0x54]
ldr r12, [lr, #0x4c]
@ -573,8 +576,8 @@ upd_algo1:
stmfd sp!, {r4-r10,lr}
mov lr, r0
ldr r3, =ym_sin_tab
ldr r5, =ym_tl_tab
PIC_LDR(r3, ip, ym_sin_tab)
PIC_LDR(r5, ip, ym_tl_tab)
ldmia lr, {r6-r7}
ldr r10, [lr, #0x54]
ldr r12, [lr, #0x4c]
@ -590,8 +593,8 @@ upd_algo2:
stmfd sp!, {r4-r10,lr}
mov lr, r0
ldr r3, =ym_sin_tab
ldr r5, =ym_tl_tab
PIC_LDR(r3, ip, ym_sin_tab)
PIC_LDR(r5, ip, ym_tl_tab)
ldmia lr, {r6-r7}
ldr r10, [lr, #0x54]
ldr r12, [lr, #0x4c]
@ -607,8 +610,8 @@ upd_algo3:
stmfd sp!, {r4-r10,lr}
mov lr, r0
ldr r3, =ym_sin_tab
ldr r5, =ym_tl_tab
PIC_LDR(r3, ip, ym_sin_tab)
PIC_LDR(r5, ip, ym_tl_tab)
ldmia lr, {r6-r7}
ldr r10, [lr, #0x54]
ldr r12, [lr, #0x4c]
@ -624,8 +627,8 @@ upd_algo4:
stmfd sp!, {r4-r10,lr}
mov lr, r0
ldr r3, =ym_sin_tab
ldr r5, =ym_tl_tab
PIC_LDR(r3, ip, ym_sin_tab)
PIC_LDR(r5, ip, ym_tl_tab)
ldmia lr, {r6-r7}
ldr r10, [lr, #0x54]
ldr r12, [lr, #0x4c]
@ -641,8 +644,8 @@ upd_algo5:
stmfd sp!, {r4-r10,lr}
mov lr, r0
ldr r3, =ym_sin_tab
ldr r5, =ym_tl_tab
PIC_LDR(r3, ip, ym_sin_tab)
PIC_LDR(r5, ip, ym_tl_tab)
ldmia lr, {r6-r7}
ldr r10, [lr, #0x54]
ldr r12, [lr, #0x4c]
@ -658,8 +661,8 @@ upd_algo6:
stmfd sp!, {r4-r10,lr}
mov lr, r0
ldr r3, =ym_sin_tab
ldr r5, =ym_tl_tab
PIC_LDR(r3, ip, ym_sin_tab)
PIC_LDR(r5, ip, ym_tl_tab)
ldmia lr, {r6-r7}
ldr r10, [lr, #0x54]
ldr r12, [lr, #0x4c]
@ -675,8 +678,8 @@ upd_algo7:
stmfd sp!, {r4-r10,lr}
mov lr, r0
ldr r3, =ym_sin_tab
ldr r5, =ym_tl_tab
PIC_LDR(r3, ip, ym_sin_tab)
PIC_LDR(r5, ip, ym_tl_tab)
ldmia lr, {r6-r7}
ldr r10, [lr, #0x54]
ldr r12, [lr, #0x4c]
@ -692,8 +695,8 @@ upd_slot1:
stmfd sp!, {r4-r10,lr}
mov lr, r0
ldr r3, =ym_sin_tab
ldr r5, =ym_tl_tab
PIC_LDR(r3, ip, ym_sin_tab)
PIC_LDR(r5, ip, ym_tl_tab)
ldmia lr, {r6-r7}
ldr r10, [lr, #0x54]
ldr r12, [lr, #0x4c]
@ -781,7 +784,7 @@ eg_done:
beq crl_loop
@ -- SLOT1 --
ldr r3, =ym_tl_tab
PIC_LDR(r3, r2, ym_tl_tab)
@ lr=context, r12=pack (stereo, lastchan, disabled, lfo_enabled | pan_r, pan_l, ams[2] | AMmasks[4] | FB[4] | lfo_ampm[16])
@ r0-r2=scratch, r3=tl_tab, r5=scratch, r6-r7=vol_out[4], r10=op1_out
@ -789,16 +792,16 @@ eg_done:
@ -- SLOT2+ --
and r0, r4, #7
ldr pc, [pc, r0, lsl #2]
PIC_XB(,r0, lsl #2)
nop
.word crl_algo0
.word crl_algo1
.word crl_algo2
.word crl_algo3
.word crl_algo4
.word crl_algo5
.word crl_algo6
.word crl_algo7
PIC_BT(crl_algo0)
PIC_BT(crl_algo1)
PIC_BT(crl_algo2)
PIC_BT(crl_algo3)
PIC_BT(crl_algo4)
PIC_BT(crl_algo5)
PIC_BT(crl_algo6)
PIC_BT(crl_algo7)
.pool
crl_algo0: