@ -116,44 +116,52 @@ _armboot_start:
/ *
* These a r e d e f i n e d i n t h e b o a r d - s p e c i f i c l i n k e r s c r i p t .
* Subtracting _ s t a r t f r o m t h e m l e t s t h e l i n k e r p u t t h e i r
* relative p o s i t i o n i n t h e e x e c u t a b l e i n s t e a d o f l e a v i n g
* them n u l l .
* /
.globl _bss_start
_bss_start :
.word __bss_start
.globl _bss_end
_bss_end :
.word _end
.globl _bss_start_ofs
_bss_start_ofs :
.word __bss_start - _ start
# if ! d e f i n e d ( C O N F I G _ S Y S _ A R M _ W I T H O U T _ R E L O C )
/* IRQ stack memory (calculated at run-time) + 8 bytes */
.globl IRQ_STACK_START_IN
IRQ_STACK_START_IN :
.word 0x0badc0de
.globl _bss_end_ofs
_bss_end_ofs :
.word _end - _ start
.globl _datarel_start
_datarel_start :
.word __datarel_start
.globl _datarel_start_ofs
_datarel_start_ofs :
.word __datarel_start - _ start
.globl _datarelrolocal_start
_datarelrolocal_start :
.word __datarelrolocal_start
.globl _datarelrolocal_start_ofs
_datarelrolocal_start_ofs :
.word __datarelrolocal_start - _ start
.globl _datarellocal_start
_datarellocal_start :
.word __datarellocal_start
.globl _datarellocal_start_ofs
_datarellocal_start_ofs :
.word __datarellocal_start - _ start
.globl _datarelro_start
_datarelro_start :
.word __datarelro_start
.globl _datarelro_start_ofs
_datarelro_start_ofs :
.word __datarelro_start - _ start
.globl _got_start
_got_start :
.word __got_start
.globl _rel_dyn_start_ofs
_rel_dyn_start_ofs :
.word __rel_dyn_start - _ start
.globl _got_end
_got_end :
.word __got_end
.globl _rel_dyn_end_ofs
_rel_dyn_end_ofs :
.word __rel_dyn_end - _ start
.globl _dynsym_start_ofs
_dynsym_start_ofs :
.word __dynsym_start - _ start
# if ! d e f i n e d ( C O N F I G _ S Y S _ A R M _ W I T H O U T _ R E L O C )
/* IRQ stack memory (calculated at run-time) + 8 bytes */
.globl IRQ_STACK_START_IN
IRQ_STACK_START_IN :
.word 0x0badc0de
/ *
* the a c t u a l r e s e t c o d e
@ -275,9 +283,8 @@ stack_setup:
adr r0 , _ s t a r t
ldr r2 , _ T E X T _ B A S E
ldr r3 , _ b s s _ s t a r t
sub r2 , r3 , r2 / * r2 < - s i z e o f a r m b o o t * /
add r2 , r0 , r2 / * r2 < - s o u r c e e n d a d d r e s s * /
ldr r3 , _ b s s _ s t a r t _ o f s
add r2 , r0 , r3 / * r2 < - s o u r c e e n d a d d r e s s * /
cmp r0 , r6
beq c l e a r _ b s s
@ -289,24 +296,44 @@ copy_loop:
blo c o p y _ l o o p
# ifndef C O N F I G _ P R E L O A D E R
/* fix got entries */
ldr r1 , _ T E X T _ B A S E / * T e x t b a s e * /
mov r0 , r7 / * r e l o c a d d r * /
ldr r2 , _ g o t _ s t a r t / * a d d r i n F l a s h * /
ldr r3 , _ g o t _ e n d / * a d d r i n F l a s h * /
sub r3 , r3 , r1
add r3 , r3 , r0
sub r2 , r2 , r1
add r2 , r2 , r0
/ *
* fix . r e l . d y n r e l o c a t i o n s
* /
ldr r0 , _ T E X T _ B A S E / * r0 < - T e x t b a s e * /
sub r9 , r7 , r0 / * r9 < - r e l o c a t i o n o f f s e t * /
ldr r10 , _ d y n s y m _ s t a r t _ o f s / * r10 < - s y m t a b l e o f s * /
add r10 , r10 , r0 / * r10 < - s y m t a b l e i n F L A S H * /
ldr r2 , _ r e l _ d y n _ s t a r t _ o f s / * r2 < - r e l d y n s t a r t o f s * /
add r2 , r2 , r0 / * r2 < - r e l d y n s t a r t i n F L A S H * /
ldr r3 , _ r e l _ d y n _ e n d _ o f s / * r3 < - r e l d y n e n d o f s * /
add r3 , r3 , r0 / * r3 < - r e l d y n e n d i n F L A S H * /
fixloop :
ldr r4 , [ r2 ]
sub r4 , r4 , r1
add r4 , r4 , r0
str r4 , [ r2 ]
add r2 , r2 , #4
ldr r0 , [ r2 ] / * r0 < - l o c a t i o n t o f i x u p , I N F L A S H ! * /
add r0 , r0 , r9 / * r0 < - l o c a t i o n t o f i x u p i n R A M * /
ldr r1 , [ r2 , #4 ]
and r8 , r1 , #0xff
cmp r8 , #23 / * r e l a t i v e f i x u p ? * /
beq f i x r e l
cmp r8 , #2 / * a b s o l u t e f i x u p ? * /
beq f i x a b s
/* ignore unknown type of fixup */
b f i x n e x t
fixabs :
/* absolute fix: set location to (offset) symbol value */
mov r1 , r1 , L S R #4 / * r1 < - s y m b o l i n d e x i n . d y n s y m * /
add r1 , r10 , r1 / * r1 < - a d d r e s s o f s y m b o l i n t a b l e * /
ldr r1 , [ r1 , #4 ] / * r1 < - s y m b o l v a l u e * /
add r1 , r1 , r9 / * r1 < - r e l o c a t e d s y m a d d r * /
b f i x n e x t
fixrel :
/* relative fix: increase location by offset */
ldr r1 , [ r0 ]
add r1 , r1 , r9
fixnext :
str r1 , [ r0 ]
add r2 , r2 , #8 / * e a c h r e l . d y n e n t r y i s 8 b y t e s * /
cmp r2 , r3
bne f i x l o o p
blo f i x l o o p
# endif
# endif / * #i f n d e f C O N F I G _ S K I P _ R E L O C A T E _ U B O O T * /
@ -350,13 +377,11 @@ skip_hw_init:
clear_bss :
# ifndef C O N F I G _ P R E L O A D E R
ldr r0 , _ b s s _ s t a r t
ldr r1 , _ b s s _ e n d
ldr r0 , _ b s s _ s t a r t _ o f s
ldr r1 , _ b s s _ e n d _ o f s
ldr r3 , _ T E X T _ B A S E / * T e x t b a s e * /
mov r4 , r7 / * r e l o c a d d r * /
sub r0 , r0 , r3
add r0 , r0 , r4
sub r1 , r1 , r3
add r1 , r1 , r4
mov r2 , #0x00000000 / * c l e a r * /
@ -378,18 +403,20 @@ clbss_l:str r2, [r0] /* clear loop... */
_nand_boot : .word n a n d _ b o o t
# else
ldr r0 , _ T E X T _ B A S E
ldr r2 , _ b o a r d _ i n i t _ r
sub r2 , r2 , r0
add r2 , r2 , r7 / * p o s i t i o n f r o m b o a r d _ i n i t _ r i n R A M * /
ldr r0 , _ b o a r d _ i n i t _ r _ o f s
adr r1 , _ s t a r t
add l r , r0 , r1
# ifndef C O N F I G _ S K I P _ R E L O C A T E _ U B O O T
add l r , l r , r9
# endif
/* setup parameters for board_init_r */
mov r0 , r5 / * g d _ t * /
mov r1 , r7 / * d e s t _ a d d r * /
/* jump to it ... */
mov l r , r2
mov p c , l r
_board_init_r : .word b o a r d _ i n i t _ r
_board_init_r_ofs :
.word board_init_r - _ start
# endif
# else / * #i f ! d e f i n e d ( C O N F I G _ S Y S _ A R M _ W I T H O U T _ R E L O C ) * /