armv7: start.S: Fix relocation address caculation
PATCH 1/1 armv7: start.S: Fix relocation address caculation
There will have issue if the _start not equal TEXT_BASE when enable relocation. The reason is as the followings,
The _dynsym_start_ofs and _rel_dyn_start_ofs is the offset from _start, so, need use _start address instead of _TEXT_BASE to caculate the rel dyn start and sym table address. This patch also correct the board_init_r function address caculation in relocation area. The addr of board_init_r after relocation is: _board_init_r_offs + relocation start address.
This patch also make code cleanup by removing some useless code
--- arch/arm/cpu/armv7/start.S | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
arch/arm/cpu/armv7/start.S +2 -6
@@ -171,7 +171,6 @@ stack_setup: beq clear_bss /* skip relocation */ #endif mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r2, _TEXT_BASE ldr r3, _bss_start_ofs add r2, r0, r3 /* r2 <- source end address */
@@ -185,7 +184,7 @@ copy_loop: /* * fix .rel.dyn relocations */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ + adr r0, _start sub r9, r6, r0 /* r9 <- relocation offset */ ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ add r10, r10, r0 /* r10 <- sym table in FLASH */
@@ -224,7 +223,6 @@ fixnext: clear_bss: ldr r0, _bss_start_ofs ldr r1, _bss_end_ofs - ldr r3, _TEXT_BASE /* Text base */ mov r4, r6 /* reloc addr */ add r0, r0, r4 add r1, r1, r4
@@ -242,9 +240,7 @@ clbss_l:str r2, [r0] /* clear loop... */ */ jump_2_ram: ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 + add lr, r0, r4 /* setup parameters for board_init_r */ mov r0, r5 /* gd_t */ mov r1, r6 /* dest_addr */
Signature · 1 line
1.7.0.4
PATCH 1/1 armv7: start.S: Fix relocation address caculation
Hi Jason,
Le 15/12/2010 14:57, Jason Liu a ?crit :
Quoted 2 lines
There will have issue if the
_startnot equalTEXT_BASEwhen enable relocation.
In what case does this happen?
Amicalement,
Signature · 1 line
Albert.
PATCH 1/1 armv7: start.S: Fix relocation address caculation
Hi, Albert,
2010/12/16 Albert ARIBAUD <[email protected]>:
Quoted 7 lines
Hi Jason,
Le 15/12/2010 14:57, Jason Liu a ?crit :
Quoted 2 lines
There will have issue if the
_startnot equalTEXT_BASEwhen enable relocation.In what case does this happen?
Some ARM SOC ROM need run the plug-in code first in IRAM and the plugin-in code need appear at the beginning of the u-boot. ROM will check the plugin-in header to do security check and run the plug-in code to init the DDR etc. In this case the _start will be not the same as TEXT_BASE.
Thanks for your comments. Cheers,
Quoted 9 lines
Amicalement,
--
Albert.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 1/1 armv7: start.S: Fix relocation address caculation
Le 16/12/2010 04:04, Jason Liu a ?crit :
Quoted 9 lines
Hi, Albert,
2010/12/16 Albert ARIBAUD<[email protected]>:
Quoted 6 lines
Hi Jason,
Le 15/12/2010 14:57, Jason Liu a ?crit :
Quoted 2 lines
There will have issue if the
_startnot equalTEXT_BASEwhen enable relocation.
Quoted 7 lines
Quoted 1 line
In what case does this happen?
Some ARM SOC ROM need run the plug-in code first in IRAM and the plugin-in code need appear at the beginning of the u-boot. ROM will check the plugin-in header to do security check and run the plug-in code to init the DDR etc. In this case the
_startwill be not the same asTEXT_BASE.
I still don't see why u-boot would not end up where specified.
The fact that there is a "plug-in" (I assume it's what I would call an IPL) does not change the fact that its payload (u-boot) can and will be loaded where specified, i.e. at TEXT_BASE -- and if it is loaded elsewhere, it is at a fixed address, so TEXT_BASE can be adjusted) All IPLs that I know of put their payload where specified.
Quoted 1 line
Thanks for your comments. Cheers,
Amicalement,
Signature · 1 line
Albert.
PATCH 1/1 armv7: start.S: Fix relocation address caculation
Hi, Albert,
2010/12/16 Albert ARIBAUD <[email protected]>:
Quoted 21 lines
Le 16/12/2010 04:04, Jason Liu a ?crit :
Quoted 12 lines
Hi, Albert,
2010/12/16 Albert ARIBAUD<[email protected]>:
Quoted 8 lines
Hi Jason,
Le 15/12/2010 14:57, Jason Liu a ?crit :
Quoted 3 lines
There will have issue if the
_startnot equalTEXT_BASEwhen enable relocation.Quoted 7 lines
Quoted 1 line
In what case does this happen?
Some ARM SOC ROM need run the plug-in code first in IRAM and the plugin-in code need appear at the beginning of the u-boot. ROM will check the plugin-in header to do security check and run the plug-in code to init the DDR etc. In this case the
_startwill be not the same asTEXT_BASE.
Quoted 7 lines
I still don't see why u-boot would not end up where specified.
The fact that there is a "plug-in" (I assume it's what I would call an IPL) does not change the fact that its payload (u-boot) can and will be loaded where specified, i.e. at
TEXT_BASE-- and if it is loaded elsewhere, it is at a fixed address, soTEXT_BASEcan be adjusted) All IPLs that I know of put their payload where specified.
It's not an IPL. The layout is that as the following,
---- ----- TEXT_BASE
plug-in
---------- _start
---------- _end
No matter what you adjusted the TEXT_BASE, the _star is not equal to it.
The fix doe not affect the original functionality but just make it more flexible.
Quoted 7 lines
Quoted 2 lines
Thanks for your comments. Cheers,
Amicalement,
--
Albert.
PATCH 1/1 armv7: start.S: Fix relocation address caculation
Le 16/12/2010 10:18, Jason Liu a ?crit :
Quoted 38 lines
Hi, Albert,
2010/12/16 Albert ARIBAUD<[email protected]>:
Quoted 21 lines
Le 16/12/2010 04:04, Jason Liu a ?crit :
Quoted 12 lines
Hi, Albert,
2010/12/16 Albert ARIBAUD<[email protected]>:
Quoted 8 lines
Hi Jason,
Le 15/12/2010 14:57, Jason Liu a ?crit :
Quoted 3 lines
There will have issue if the
_startnot equalTEXT_BASEwhen enable relocation.Quoted 7 lines
Quoted 1 line
In what case does this happen?
Some ARM SOC ROM need run the plug-in code first in IRAM and the plugin-in code need appear at the beginning of the u-boot. ROM will check the plugin-in header to do security check and run the plug-in code to init the DDR etc. In this case the
_startwill be not the same asTEXT_BASE.Quoted 7 lines
I still don't see why u-boot would not end up where specified.
The fact that there is a "plug-in" (I assume it's what I would call an IPL) does not change the fact that its payload (u-boot) can and will be loaded where specified, i.e. at
TEXT_BASE-- and if it is loaded elsewhere, it is at a fixed address, soTEXT_BASEcan be adjusted) All IPLs that I know of put their payload where specified.It's not an IPL. The layout is that as the following,
---- -----
TEXT_BASE
plug-in
----------_start
Quoted 6 lines
----------
_endNo matter what you adjusted the
TEXT_BASE, the_staris not equal to it.The fix doe not affect the original functionality but just make it more flexible.
This layout is not that of u-boot for ARM; the fix thus corrects a fault not inherent to u-boot but introduced by inserting this "plug-in" where it should not be.
Why must you modify the original layout?
Also, what is this 'plug-in' if it is not an IPL?
Amicalement,
Signature · 1 line
Albert.
PATCH 1/1 armv7: start.S: Fix relocation address caculation
Dear Albert ARIBAUD,
Quoted 2 lines · In message <[email protected]> you wrote:
Why must you modify the original layout?
right!
Quoted 1 line
Also, what is this 'plug-in' if it is not an IPL?
Yes, and why must it be linked at TEXT_BASE?
Let's stop this here.
Let's wait until any code is submitted or proposed that actually needs such a feature. Then we can discuss the design and try to find a solution that makes sense.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
History is only a confused heap of facts.
-- Philip Earl of ChesterfieldPATCH 1/1 armv7: start.S: Fix relocation address caculation
Hi, Wolfgang,
2010/12/16 Wolfgang Denk <[email protected]>:
Quoted 10 lines
Dear Albert ARIBAUD,
Quoted 2 lines · In message <[email protected]> you wrote:
Why must you modify the original layout?
right!
Quoted 1 line
Also, what is this 'plug-in' if it is not an IPL?
Quoted 7 lines
Yes, and why must it be linked at
TEXT_BASE?Let's stop this here.
Let's wait until any code is submitted or proposed that actually needs such a feature. ?Then we can discuss the design and try to find a solution that makes sense.
In fact, this is indeed one bug in the code as I said in the comit log:
"the _dynsym_start_ofs and _rel_dyn_start_ofs is the offset from _start, so, need use _start address instead of _TEXT_BASE to caculate the rel dyn start and sym table address. This patch also correct the board_init_r function address caculation in relocation area. The addr of board_init_r after relocation is: _board_init_r_offs + relocation start address."
Is there any thing wrong with my patch?
The case I met just make the bug show up.
Quoted 12 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de History is only a confused heap of facts.
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -- Philip Earl of Chesterfield
PATCH 1/1 armv7: start.S: Fix relocation address caculation
Dear Jason Liu,
Quoted 9 lines · In message <[email protected]> you…
In fact, this is indeed one bug in the code as I said in the comit log:
"the
_dynsym_start_ofsand_rel_dyn_start_ofsis the offset from_start, so, need use_startaddress instead of_TEXT_BASEto caculate the rel dyn start and sym table address. This patch also correct theboard_init_rfunction address caculation in relocation area. The addr ofboard_init_rafter relocation is:_board_init_r_offs+ relocation start address."
If there are really two different bugs, then please split your patch into to separate commits, and explain the respective problem in the commit messages.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A modem is a baudy house.
PATCH 1/1 armv7: start.S: Fix relocation address caculation
In reply to Jason LiuDear Jason Liu,
Quoted 8 lines · In message <[email protected]> you…
Quoted 2 lines
In what case does this happen?
Some ARM SOC ROM need run the plug-in code first in IRAM and the plugin-in code need appear at the beginning of the u-boot. ROM will check the plugin-in header to do security check and run the plug-in code to init the DDR etc. In this case the
_startwill be not the same asTEXT_BASE.
So we are talking about aSoC that is not supported yet in U-Boot. Let's talk about this when such support gets added to U-Boot.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Mistakes are often the stepping stones to utter failure.