@ -36,10 +36,79 @@
# define _ _ h a s _ f e a t u r e ( x ) 0
# endif
/ * Support m a c r o s f o r t h e A r m v8 . 5 - A B r a n c h T a r g e t I d e n t i f i c a t i o n f e a t u r e w h i c h
* requires e m i t t i n g a . n o t e . g n u . p r o p e r t y s e c t i o n w i t h t h e a p p r o p r i a t e
* architecture- d e p e n d e n t f e a t u r e b i t s s e t .
* Read m o r e : " E L F f o r t h e A r m ® 6 4 - b i t A r c h i t e c t u r e "
/ * Support m a c r o s f o r
* - Armv8 . 3 - A P o i n t e r A u t h e n t i c a t i o n a n d
* - Armv8 . 5 - A B r a n c h T a r g e t I d e n t i f i c a t i o n
* features w h i c h r e q u i r e e m i t t i n g a . n o t e . g n u . p r o p e r t y s e c t i o n w i t h t h e
* appropriate a r c h i t e c t u r e - d e p e n d e n t f e a t u r e b i t s s e t .
*
* | AARCH6 4 _ S I G N _ L I N K _ R E G I S T E R | a n d | A A R C H 6 4 _ V A L I D A T E _ L I N K _ R E G I S T E R | e x p a n d t o
* PACIxSP a n d A U T I x S P , r e s p e c t i v e l y . | A A R C H 6 4 _ S I G N _ L I N K _ R E G I S T E R | s h o u l d b e
* used i m m e d i a t e l y b e f o r e s a v i n g t h e L R r e g i s t e r ( x30 ) t o t h e s t a c k .
* | AARCH6 4 _ V A L I D A T E _ L I N K _ R E G I S T E R | s h o u l d b e u s e d i m m e d i a t e l y a f t e r r e s t o r i n g
* it. N o t e | A A R C H 6 4 _ S I G N _ L I N K _ R E G I S T E R | ' s m o d i f i c a t i o n s t o L R m u s t b e u n d o n e
* with | A A R C H 6 4 _ V A L I D A T E _ L I N K _ R E G I S T E R | b e f o r e R E T . T h e S P r e g i s t e r m u s t a l s o
* have t h e s a m e v a l u e a t t h e t w o p o i n t s . F o r e x a m p l e :
*
* .global f
* f :
* AARCH6 4 _ S I G N _ L I N K _ R E G I S T E R
* stp x29 , x30 , [ s p , #- 96 ] !
* mov x29 , s p
* . . .
* ldp x29 , x30 , [ s p ] , #96
* AARCH6 4 _ V A L I D A T E _ L I N K _ R E G I S T E R
* ret
*
* | AARCH6 4 _ V A L I D _ C A L L _ T A R G E T | e x p a n d s t o B T I ' c ' . E i t h e r i t , o r
* | AARCH6 4 _ S I G N _ L I N K _ R E G I S T E R | , m u s t b e u s e d a t e v e r y p o i n t t h a t m a y b e a n
* indirect c a l l t a r g e t . I n p a r t i c u l a r , a l l s y m b o l s e x p o r t e d f r o m a f i l e m u s t
* begin w i t h o n e o f t h e s e m a c r o s . F o r e x a m p l e , a l e a f f u n c t i o n t h a t d o e s n o t
* save L R c a n i n s t e a d u s e | A A R C H 6 4 _ V A L I D _ C A L L _ T A R G E T | :
*
* .globl return_zero
* return_zero :
* AARCH6 4 _ V A L I D _ C A L L _ T A R G E T
* mov x0 , #0
* ret
*
* A n o n - l e a f f u n c t i o n w h i c h d o e s n o t i m m e d i a t e l y s a v e L R m a y n e e d b o t h m a c r o s
* because | A A R C H 6 4 _ S I G N _ L I N K _ R E G I S T E R | a p p e a r s l a t e . F o r e x a m p l e , t h e f u n c t i o n
* may j u m p t o a n a l t e r n a t e i m p l e m e n t a t i o n b e f o r e s e t t i n g u p t h e s t a c k :
*
* .globl with_early_jump
* with_early_jump :
* AARCH6 4 _ V A L I D _ C A L L _ T A R G E T
* cmp x0 , #128
* b. l t . L w i t h _ e a r l y _ j u m p _ 1 2 8
* AARCH6 4 _ S I G N _ L I N K _ R E G I S T E R
* stp x29 , x30 , [ s p , #- 96 ] !
* mov x29 , s p
* . . .
* ldp x29 , x30 , [ s p ] , #96
* AARCH6 4 _ V A L I D A T E _ L I N K _ R E G I S T E R
* ret
*
* .Lwith_early_jump_128 :
* . . .
* ret
*
* These a n n o t a t i o n s a r e o n l y r e q u i r e d w i t h i n d i r e c t c a l l s . P r i v a t e s y m b o l s t h a t
* are o n l y t h e t a r g e t o f d i r e c t c a l l s d o n o t r e q u i r e a n n o t a t i o n s . A l s o n o t e
* that | A A R C H 6 4 _ V A L I D _ C A L L _ T A R G E T | i s o n l y v a l i d f o r i n d i r e c t c a l l s ( B L R ) , n o t
* indirect j u m p s ( B R ) . I n d i r e c t j u m p s i n a s s e m b l y a r e s u p p o r t e d t h r o u g h
* | AARCH6 4 _ V A L I D _ J U M P _ T A R G E T | . L a n d i n g P a d s w h i c h s h a l l s e r v e f o r j u m p s a n d
* calls c a n b e c r e a t e d u s i n g | A A R C H 6 4 _ V A L I D _ J U M P _ C A L L _ T A R G E T | .
*
* Although n o t n e c e s s a r y , i t i s s a f e t o u s e t h e s e m a c r o s i n 3 2 - b i t A R M
* assembly. T h i s m a y b e u s e d t o s i m p l i f y d u a l 3 2 - b i t a n d 6 4 - b i t f i l e s .
*
* References :
* - " ELF f o r t h e A r m ® 6 4 - b i t A r c h i t e c t u r e "
* https : * github. c o m / A R M - s o f t w a r e / a b i - a a / b l o b / m a s t e r / a a e l f64 / a a e l f64 . r s t
* - " Providing p r o t e c t i o n f o r c o m p l e x s o f t w a r e "
* https : / / developer. a r m . c o m / a r c h i t e c t u r e s / l e a r n - t h e - a r c h i t e c t u r e / p r o v i d i n g - p r o t e c t i o n - f o r - c o m p l e x - s o f t w a r e
* /
# if d e f i n e d ( _ _ A R M _ F E A T U R E _ B T I _ D E F A U L T ) & & ( _ _ A R M _ F E A T U R E _ B T I _ D E F A U L T = = 1 )
# define G N U _ P R O P E R T Y _ A A R C H 6 4 _ B T I ( 1 < < 0 ) / / H a s B T I
@ -51,7 +120,28 @@
# define A A R C H 6 4 _ V A L I D _ J U M P _ T A R G E T
# endif
# if ( G N U _ P R O P E R T Y _ A A R C H 6 4 _ B T I ! = 0 )
# if d e f i n e d ( _ _ A R M _ F E A T U R E _ P A C _ D E F A U L T )
# if ( ( _ _ A R M _ F E A T U R E _ P A C _ D E F A U L T & ( 1 < < 0 ) ) ! = 0 ) / / a u t h e n t i c a t i o n u s i n g k e y A
# define A A R C H 6 4 _ S I G N _ L I N K _ R E G I S T E R p a c i a s p
# define A A R C H 6 4 _ V A L I D A T E _ L I N K _ R E G I S T E R a u t i a s p
# elif ( ( _ _ A R M _ F E A T U R E _ P A C _ D E F A U L T & ( 1 < < 1 ) ) ! = 0 ) / / a u t h e n t i c a t i o n u s i n g k e y B
# define A A R C H 6 4 _ S I G N _ L I N K _ R E G I S T E R p a c i b s p
# define A A R C H 6 4 _ V A L I D A T E _ L I N K _ R E G I S T E R a u t i b s p
# else
# error P o i n t e r a u t h e n t i c a t i o n d e f i n e s n o v a l i d k e y !
# endif
# if ( ( _ _ A R M _ F E A T U R E _ P A C _ D E F A U L T & ( 1 < < 2 ) ) ! = 0 )
# error A u t h e n t i c a t i o n o f l e a f f u n c t i o n s i s e n a b l e d b u t n o t s u p p o r t e d i n F F m p e g !
# endif
# define G N U _ P R O P E R T Y _ A A R C H 6 4 _ P A C ( 1 < < 1 )
# else
# define G N U _ P R O P E R T Y _ A A R C H 6 4 _ P A C 0
# define A A R C H 6 4 _ S I G N _ L I N K _ R E G I S T E R
# define A A R C H 6 4 _ V A L I D A T E _ L I N K _ R E G I S T E R
# endif
# if ( G N U _ P R O P E R T Y _ A A R C H 6 4 _ B T I ! = 0 | | G N U _ P R O P E R T Y _ A A R C H 6 4 _ P A C ! = 0 )
.pushsection .note .gnu .property , " a"
.balign 8
.long 4
@ -60,7 +150,7 @@
.asciz " GNU"
.long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
.long 4
.long GNU_PROPERTY_AARCH64_BTI
.long ( GNU_ P R O P E R T Y _ A A R C H 6 4 _ B T I | G N U _ P R O P E R T Y _ A A R C H 6 4 _ P A C )
.long 0
.popsection
# endif