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

@ -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__ */