@ -27,11 +27,24 @@ ENTRY(relocate_code)
/ *
/ *
* Copy u - b o o t f r o m f l a s h t o R A M
* Copy u - b o o t f r o m f l a s h t o R A M
* /
* /
ldr x1 , =__image_copy_star t / * x1 < - S R C & _ _ i m a g e _ c o p y _ s t a r t * /
adr x1 , _ _ i m a g e _ c o p y _ s t a r t / * x1 < - R u n & _ _ i m a g e _ c o p y _ s t a r t * /
subs x9 , x0 , x1 / * x9 < - r e l o c a t i o n o f f s e t * /
subs x9 , x0 , x1 / * x8 < - R u n t o c o p y o f f s e t * /
b. e q r e l o c a t e _ d o n e / * s k i p r e l o c a t i o n * /
b. e q r e l o c a t e _ d o n e / * s k i p r e l o c a t i o n * /
ldr x2 , =__image_copy_end / * x2 < - S R C & _ _ i m a g e _ c o p y _ e n d * /
/ *
* Don' t l d r x1 , _ _ i m a g e _ c o p y _ s t a r t h e r e , s i n c e i f t h e c o d e i s a l r e a d y
* running a t a n a d d r e s s o t h e r t h a n i t w a s l i n k e d t o , t h a t i n s t r u c t i o n
* will l o a d t h e r e l o c a t e d v a l u e o f _ _ i m a g e _ c o p y _ s t a r t . T o
* correctly a p p l y r e l o c a t i o n s , w e n e e d t o k n o w t h e l i n k e d v a l u e .
*
* Linked & _ _ i m a g e _ c o p y _ s t a r t , w h i c h w e k n o w w a s a t
* CONFIG_ S Y S _ T E X T _ B A S E , w h i c h i s s t o r e d i n _ T E X T _ B A S E , a s a n o n -
* relocated v a l u e , s i n c e i t i s n ' t a s y m b o l r e f e r e n c e .
* /
ldr x1 , _ T E X T _ B A S E / * x1 < - L i n k e d & _ _ i m a g e _ c o p y _ s t a r t * /
subs x9 , x0 , x1 / * x9 < - L i n k t o c o p y o f f s e t * /
adr x1 , _ _ i m a g e _ c o p y _ s t a r t / * x1 < - R u n & _ _ i m a g e _ c o p y _ s t a r t * /
adr x2 , _ _ i m a g e _ c o p y _ e n d / * x2 < - R u n & _ _ i m a g e _ c o p y _ e n d * /
copy_loop :
copy_loop :
ldp x10 , x11 , [ x1 ] , #16 / * c o p y f r o m s o u r c e a d d r e s s [ x1 ] * /
ldp x10 , x11 , [ x1 ] , #16 / * c o p y f r o m s o u r c e a d d r e s s [ x1 ] * /
stp x10 , x11 , [ x0 ] , #16 / * c o p y t o t a r g e t a d d r e s s [ x0 ] * /
stp x10 , x11 , [ x0 ] , #16 / * c o p y t o t a r g e t a d d r e s s [ x0 ] * /
@ -42,8 +55,8 @@ copy_loop:
/ *
/ *
* Fix . r e l a . d y n r e l o c a t i o n s
* Fix . r e l a . d y n r e l o c a t i o n s
* /
* /
ldr x2 , =__rel_dyn_star t / * x2 < - S R C & _ _ r e l _ d y n _ s t a r t * /
adr x2 , _ _ r e l _ d y n _ s t a r t / * x2 < - R u n & _ _ r e l _ d y n _ s t a r t * /
ldr x3 , =__rel_dyn_en d / * x3 < - S R C & _ _ r e l _ d y n _ e n d * /
adr x3 , _ _ r e l _ d y n _ e n d / * x3 < - R u n & _ _ r e l _ d y n _ e n d * /
fixloop :
fixloop :
ldp x0 , x1 , [ x2 ] , #16 / * ( x0 ,x1 ) < - ( S R C l o c a t i o n , f i x u p ) * /
ldp x0 , x1 , [ x2 ] , #16 / * ( x0 ,x1 ) < - ( S R C l o c a t i o n , f i x u p ) * /
ldr x4 , [ x2 ] , #8 / * x4 < - a d d e n d * /
ldr x4 , [ x2 ] , #8 / * x4 < - a d d e n d * /