@ -62,7 +62,14 @@ ELF .eabi_attribute 25, \val
.endm
.macro function name, e x p o r t =0
.set .Lpic_idx , 0
.set .Lpic_gp , 0
.macro endfunc
.if .Lpic_idx
.altmacro
put_ p i c % ( . L p i c _ i d x - 1 )
.noaltmacro
.endif
ELF . s i z e \ n a m e , . - \ n a m e
.endfunc
.purgem endfunc
@ -106,8 +113,44 @@ ELF .size \name, . - \name
# endif
.endm
.macro put_pic num
put_ p i c _ \ n u m
.endm
.macro do_def_pic num, v a l , l a b e l
.macro put_ p i c _ \ n u m
.if \ num
.altmacro
put_ p i c % ( \ n u m - 1 )
.noaltmacro
.endif
\ label : .word \ v a l
.purgem put_ p i c _ \ n u m
.endm
.endm
.macro def_pic val, l a b e l
.altmacro
do_ d e f _ p i c % . L p i c _ i d x , \ v a l , \ l a b e l
.noaltmacro
.set .Lpic_idx , .Lpic_idx + 1
.endm
.macro ldpic rd, v a l , i n d i r =0
ldr \ r d , . L p i c o f f \ @
.Lpic \ @:
.if \ indir
ldr \ r d , [ p c , \ r d ]
.else
add \ r d , p c , \ r d
.endif
def_ p i c \ v a l - ( . L p i c \ @ + (8 >> CONFIG_THUMB)), .Lpicoff\@
.endm
.macro movrel rd, v a l
# if H A V E _ A R M V 6 T 2 & & ! C O N F I G _ P I C & & ! d e f i n e d ( _ _ A P P L E _ _ )
# if C O N F I G _ P I C
ldpic \ r d , \ v a l
# elif H A V E _ A R M V 6 T 2 & & ! d e f i n e d ( _ _ A P P L E _ _ )
movw \ r d , #: l o w e r 16 : \ v a l
movt \ r d , #: u p p e r 16 : \ v a l
# else
@ -115,6 +158,34 @@ ELF .size \name, . - \name
# endif
.endm
.macro movrelx rd, v a l , g p
# if C O N F I G _ P I C & & d e f i n e d ( _ _ E L F _ _ )
.ifnb \ gp
.if .Lpic_gp
.unreq gp
.endif
gp . r e q \ g p
ldpic g p , _ G L O B A L _ O F F S E T _ T A B L E _
.elseif ! .Lpic_gp
gp . r e q r12
ldpic g p , _ G L O B A L _ O F F S E T _ T A B L E _
.endif
.set .Lpic_gp , 1
ldr \ r d , . L p i c o f f \ @
ldr \ r d , [ g p , \ r d ]
def_ p i c \ v a l ( G O T ) , . L p i c o f f \ @
# elif C O N F I G _ P I C & & d e f i n e d ( _ _ A P P L E _ _ )
ldpic \ r d , . L p i c \ @, indir=1
.non_lazy_symbol_pointer
.Lpic \ @:
.indirect_symbol \ val
.word 0
.text
# else
movrel \ r d , \ v a l
# endif
.endm
.macro ldr_pre rt, r n , r m : v a r a r g
A l d r \ r t , [ \ r n , \ r m ] !
T a d d \ r n , \ r n , \ r m