arm: provide a CONFIG flag for disabling relocation
GROYER
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Hello,
I came back on a discussion started on April 2011.
The use of the initial patches for the CONFIG_SYS_SKIP_ARM_RELOCATION features has revealed two issues.
First issue: the calculation of the relocation offset was done only if the relocation is actually done. So we could reach a point where r9 has a wrong value, since it has never been used before (in my case, this bug happens without JTAG). The first diff moves the relocation offset calculation before the test of a relocation need.
Second issue: board_init_r was thinking the memory area for the malloc is just below the code, whereas the board_init_f had allocated some space for the malloc at the end of the SDRAM. If the code is located at the base of the SDRAM with CONFIG_SYS_SKIP_ARM_RELOCATION defined, the malloc area does not point to a correct memory address. The 2 other diff store the calculated malloc start address in a global data member so that it can be used in board_init_r().
arm/cpu/arm926ejs/start.S +4 -2
@@ -196,6 +196,10 @@ mov r4, r0 /* save addr_sp */ mov r5, r1 /* save addr of gd */ mov r6, r2 /* save addr of destination */ + /* set relocation offset here for all cases: + relocation or not */ + ldr r0, _TEXT_BASE /* r0 <- Text base */ + sub r9, r6, r0 /* r9 <- relocation offset */ /* Set up the stack */ stack_setup:
@@ -218,8 +222,6 @@ /* * fix .rel.dyn relocations */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - 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 */ ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */
arm/include/asm/global_data.h +1 -0
@@ -69,6 +69,7 @@unsigned long mon_len;/* monitor len */ unsigned long irq_sp;/* irq stack pointer */ unsigned long start_addr_sp;/* start_addr_stackpointer */ +unsigned long start_addr_malloc;/* start_addr_malloc */ unsigned long reloc_off;#if !(defined(CONFIG_SYS_NO_ICACHE ) && defined(CONFIG_SYS_NO_DCACHE ))unsigned long tlb_addr;
arm/lib/board.c +2 -4
@@ -367,6 +367,7 @@* reserve memory for malloc() arena */ addr_sp = addr -TOTAL_MALLOC_LEN ; + gd->start_addr_malloc = addr_sp;debug ("Reserving %dk for malloc() at: %08lx\n" ,TOTAL_MALLOC_LEN >>10 , addr_sp);/*
@@ -445,7 +446,6 @@ {char *s;bd_t *bd; -ulong malloc_start;#if !defined(CONFIG_SYS_NO_FLASH )ulong flash_size;#endif
@@ -473,9 +473,7 @@post_output_backlog ();#endif -/* The Malloc area is immediately below the monitor copy in DRAM */ - malloc_start = dest_addr -TOTAL_MALLOC_LEN ; -mem_malloc_init (malloc_start,TOTAL_MALLOC_LEN ); +mem_malloc_init (gd->start_addr_malloc,TOTAL_MALLOC_LEN );#if !defined(CONFIG_SYS_NO_FLASH )puts ("Flash: " );
Regards,
Anthony Groyer
Quoted 91 lines · Aneesh V
Quoted 35 lines
Hi Simon, Wolfgang,
Quoted 25 lines · Simon Glass
Quoted 10 lines · Albert ARIBAUD
Le 25/03/2011 17:12, Aneesh V a ?crit :
Quoted 6 lines
Another problem I have with relocation is that it makes debugging with JTAG debugers more difficult. The addresses of symbols in the ELF target are no longer valid. Of course, you can load the symbols at an offset from the original location. But one has to first enable debug prints, find the relocation offset, use it while loading the symbols before you can do source level debugging.
Quoted 6 lines
Actually you don't need recompiling: simply set a breakpoint at the entry of
relocate_codeand once you hit the bp, look up r2: it contains the destination. If you want the offset rather than the absolute address, set the breakpoint right after the 'sub r9, r6, r0' round line 222: r9 will then give you the offset. Unload the current symbols, reload the symbols with the relevant offset, and there you go.I would like to revisit this thread. I'm not sure how other people do development in U-Boot but I like to use an ICE and a source-level debugger for any significant effort. I think it should be possible to use a JTAG debugging just by loading the u-boot ELF file and running.
Quoted 6 lines
With this patch (or something similar) this is possible. Without it, it is painful.
To be clear, we are not talking here about creating a platform that doesn't use relocation, just that for development purposes it is convenient to be able to disable it.
Quoted 5 lines
Actually, I am not even sure why relocation shouldn't be disabled in my platform for good. It may be useful to have things such as the frame buffer at the end of available memory. But, IMHO, that can still be done without relocating u-boot. That's what the patch does.Am I missing something?
Well relocation does remove a lot of this ad-hoc positioning of things at compile time. I think it is desirable. My point is that it is not engineer-friendly during development, and we should have an easy way to disable it for debugging / JTAG purposes.
Regards,
SimonQuoted 27 lines
Quoted 27 lines
Looking at the December thread
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/88067/focus=88262Aneesh:
Quoted 3 lines
Quoted 3 lines
Shouldn't we provide a CONFIG option by which users can disable Elf relocation?
Wolfgang:
Quoted 3 lines
Why should we? It would just make the code even more complicated, and require a lot of additional test cases.
From what I can see this is a new CONFIG option, two ifdefs in the
board.cfile, and optionally disabling the -pie position-independent executable option to reduce size. It is pretty trivial:arch/arm/config.mk | 2 ++ arch/arm/lib/board.c | 5 +++++ 2 files changed, 7 insertions(+), 0 deletions(-)Regards,
SimonQuoted 1 line
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Amicalement,
--
Albert.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Dear "GROYER, Anthony",
Quoted 3 lines · In message <BC0A2F434D4F39448D24A68EA6EFFB9F0194D534@EU-FR-EXBE07.eu.corp.airli…
The use of the initial patches for the
CONFIG_SYS_SKIP_ARM_RELOCATIONfeatu res has revealed two issues.
Could you please restict your line length to some 70 characters or so? Thanks.
Quoted 3 lines
First issue: the calculation of the relocation offset was done only if the relocation is actually done. So we could reach a point where r9 has a wrong
value, since it has never been used before (in my case, this bug happens w
This is a configuration error then, isn't it? The relocation offset should be either the intended value, or eventually zero, if no relocation is intended.
Quoted 5 lines
the test of a relocation need.
Second issue:
board_init_rwas thinking the memory area for the malloc is j ust below the code, whereas theboard_init_fhad allocated some space for t he malloc at the end of the SDRAM. If the code is located at the base of th
This is a broken memory layout then, i. e. another configuration error.
So actually both your "issues" are caused by configuration errors and should go away if you fix your system configuration.
BTW: your patch has a number ofd coduing style errors, and the
Signed-off-by: line is missing.
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
Any sufficiently advanced technology is indistinguishable from magic.
- Arthur C. ClarkeRFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Le 20/09/2011 20:09, Wolfgang Denk a ?crit :
Quoted 10 lines
Dear "GROYER, Anthony",
Quoted 3 lines · In message<BC0A2F434D4F39448D24A68EA6EFFB9F0194D534@EU-FR-EXBE07.eu.corp.airliq…
The use of the initial patches for the
CONFIG_SYS_SKIP_ARM_RELOCATIONfeatu res has revealed two issues.Could you please restict your line length to some 70 characters or so? Thanks.
Quoted 7 lines
Quoted 3 lines
First issue: the calculation of the relocation offset was done only if the relocation is actually done. So we could reach a point where r9 has a wrong
value, since it has never been used before (in my case, this bug happens wThis is a configuration error then, isn't it? The relocation offset should be either the intended value, or eventually zero, if no relocation is intended.
Actually, even though "revision 1083" and "revision 1113" are not git references (and thus I can't be sure Anthony is referring to up-to-date mainline code), there is a point to what Anthony says: in the case where relocation is unneeded (r0 equals r6) then r9 is not set, but is still used when branching to board_init_r().
for this bug to have any effect, relocation would have to be unneeded, which is a rare case, *and* r9 has to be nonzero, which may or may not happen depending on the code executed until relocate_code() is called, and thus makes the whole condition rarer yet; probably the rarity of these two conjunct conditions explains why it was not noticed until now.
However, since start.S has a code path to handle the non-relocating case, this path ought to be bug-free. But then, I want it to be
consistent: if the relocation offset is computed in r9, then testing whether relocation is needed would be done on r9 once computed, not before, by replacing
adr r0, _start cmp r0, r6 beq clear_bss /* skip relocation */
With
adr r0, _start sub r9, r6, r0 cmp r0, #0 beq clear_bss /* skip relocation */
Quoted 2 lines
BTW: your patch has a number ofd coduing style errors, and the
Signed-off-by: line is missing.
Plus it did not have the commit message separator either. I suspect it was not produced using git format-patch / git send-email.
Anthony, please submit a proper [PATCH], without [RFC], and with the setting of r9 done as shown above, and applied to all relevant start.S files in arch/arm/cpu/*/ -- in next merge window we should try and factorize those start.S files, BTW.
Quoted 3 lines
Best regards,
Wolfgang Denk
Amicalement,
Signature · 1 line
Albert.
GROYER
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Quoted 64 lines
-----Message d'origine-----
De?: u-boot-bounces at lists.denx.de [mailto:u-boot- bounces at lists.denx.de] De la part de Albert ARIBAUD Envoy??: mardi 20 septembre 2011 21:14
??: u-boot at lists.denx.de
Objet?: Re: [U-Boot] [RFC PATCH] arm: provide a CONFIG flag for disabling relocationLe 20/09/2011 20:09, Wolfgang Denk a ?crit :
Quoted 3 lines
Dear "GROYER, Anthony",
In message<BC0A2F434D4F39448D24A68EA6EFFB9F0194D534@EU-FR-
Quoted 2 lines · EXBE07.eu.corp.airliquide.com> you wrote:
Quoted 2 lines
The use of the initial patches for the
CONFIG_SYS_SKIP_ARM_RELOCATIONfeatuQuoted 3 lines
Quoted 1 line
res has revealed two issues.
Could you please restict your line length to some 70 characters or
so?
Quoted 3 lines
Thanks.
Quoted 1 line
First issue: the calculation of the relocation offset was done
only if the
Quoted 1 line
Quoted 1 line
relocation is actually done. So we could reach a point where r9
has a wrong
Quoted 1 line
Quoted 1 line
value, since it has never been used before (in my case, this
bug happens w
Quoted 2 lines
This is a configuration error then, isn't it? The relocation
offset
Quoted 2 lines
should be either the intended value, or eventually zero, if no relocation is intended.
Actually, even though "revision 1083" and "revision 1113" are not git
references (and thus I can't be sure Anthony is referring to up-to- date
mainline code), there is a point to what Anthony says: in the case where
relocation is unneeded (r0 equals r6) then r9 is not set, but is still
used when branching toboard_init_r().for this bug to have any effect, relocation would have to be unneeded,
which is a rare case, *and* r9 has to be nonzero, which may or may not
happen depending on the code executed untilrelocate_code()is called,
and thus makes the whole condition rarer yet; probably the rarity of these two conjunct conditions explains why it was not noticed until now.However, since
start.Shas a code path to handle the non-relocating case, this path ought to be bug-free. But then, I want it to be
consistent: if the relocation offset is computed in r9, then testing whether relocation is needed would be done on r9 once computed, not before, by replacingadr r0, _start cmp r0, r6 beq clear_bss /* skip relocation */
Quoted 6 lines
With
adr r0, _start sub r9, r6, r0 cmp r0, #0 beq clear_bss /* skip relocation */
I guess the code is this:
adr r0, _start
sub r9, r6, r0
cmp r9, #0
beq clear_bss /* skip relocation */
What is the difference between _start and _TEXT_BASE ? I do not see any differences and the former relocation offset calculation was using _TEXT_BASE. May I remove the following code in all arch/arm/cpu/*/start.S ?
ldr r0, _TEXT_BASE /* r0 <- Text base */
sub r9, r6, r0 /* r9 <- relocation offset */
and expect than the "adr r0, _start" is sufficient ?
Anthony
Quoted 25 lines
Quoted 3 lines
BTW: your patch has a number ofd coduing style errors, and the
Signed-off-by: line is missing.Plus it did not have the commit message separator either. I suspect it
was not produced using git format-patch / git send-email.Anthony, please submit a proper [PATCH], without [RFC], and with the setting of r9 done as shown above, and applied to all relevant
start.S
files inarch/arm/cpu/*/-- in next merge window we should try and factorize thosestart.Sfiles, BTW.Quoted 3 lines
Best regards,
Wolfgang Denk
Amicalement,
--
Albert.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Dear "GROYER, Anthony",
Quoted 3 lines · In message <BC0A2F434D4F39448D24A68EA6EFFB9F0194DA79@EU-FR-EXBE07.eu.corp.airli…
What is the difference between
_startand_TEXT_BASE? I do not see any differences and the former relocation offset calculation was using_TEXT_BASE.
The former is the entry point address, while the latter is the start of the text segment. These may be the same (and on many ARM systems they are), but they have actually no direct relation to each other (and some ARM systems do use an entry point that is not the same as the start of the code).
Please better not confuse these two...
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 A committee is a life form with six or more legs and no brain.
-- Lazarus Long, "Time Enough For Love"
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Le 21/09/2011 12:45, Wolfgang Denk a ?crit :
Quoted 4 lines
Dear "GROYER, Anthony",
Quoted 1 line · In message<BC0A2F434D4F39448D24A68EA6EFFB9F0194DA79@EU-FR-EXBE07.eu.corp.airliq…
Quoted 8 lines
Quoted 2 lines
What is the difference between
_startand_TEXT_BASE? I do not see any differences and the former relocation offset calculation was using_TEXT_BASE.The former is the entry point address, while the latter is the start of the text segment. These may be the same (and on many ARM systems they are), but they have actually no direct relation to each other (and some ARM systems do use an entry point that is not the same as the start of the code).
This would be boards
- where U-Boot boots from Flash without a SPL,
- which boot at FFFF0000,
- and which don't have a tiny piece of code at FFFF0000 which jumps to a fixed location at which _start resides.
Thus, typically boards with a very small FLASH that forces the maintainer to fill the last 64 KB with _start and some code, then put the rest of U-Boot below FFFF0000.
But my edminiv2, with only 512 KB flash, already provides enough space that such a complicated linker mapping is unneeded -- FFFF0000 just has a permanent jump instruction to FFF90000, and U-Boot is linked linearly, with _start at FFF9000.
I wonder which ARM boards we have that still require a complex mapping with _start in the middle of the code.
Amicalement,
Signature · 1 line
Albert.
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
In reply to GROYERLe 21/09/2011 11:29, GROYER, Anthony a ?crit :
Quoted 24 lines
Quoted 10 lines
However, since
start.Shas a code path to handle the non-relocating case, this path ought to be bug-free. But then, I want it to be
consistent: if the relocation offset is computed in r9, then testing whether relocation is needed would be done on r9 once computed, not before, by replacingadr r0, _start cmp r0, r6 beq clear_bss /* skip relocation */Quoted 6 lines
With
adr r0, _start sub r9, r6, r0 cmp r0, #0 beq clear_bss /* skip relocation */I guess the code is this:
adr r0,_start
sub r9, r6, r0
cmp r9, #0
beqclear_bss/* skip relocation */
Quoted 3 lines
What is the difference between
_startand_TEXT_BASE? I do not see any differences and the former relocation offset calculation was using_TEXT_BASE.
The diff?rence is that when using "ldr r0,_TEXT_BASE", you depend on U-Boot having been actually loaded at the address specified by CONFIG_SYS_TEXT_BASE -- that *should* be the case, but if it is not, the code won't work.
OTOH, using "adr r0,_start" is actually translated into "sub r0, pc, #nnn", thus always setting r0 to the actual base address of U-Boot -- it will work even when U-Boot is not run at CONFIG_SYS_TEXT_BASE.
Quoted 4 lines
May I remove the following code in all
arch/arm/cpu/*/start.S?
ldr r0,_TEXT_BASE/* r0<- Text base */
sub r9, r6, r0 /* r9<- relocation offset */
and expect than the "adr r0,_start" is sufficient ?
Upon *third* look, it is a bit more complicated.
Granted, you want r9 set even if you don't relocate.
But the current relocation code *trashes* r9 in the copy loop, before setting it right before the relocation loop.
And *then* it is used for jumping to board_init_r.
So the correct fix would be to
1) set r9 early, before checking if relocation is needed so that a direct jump to clear_bss has the correct r9 whichever way.
2) remove the late setting of r9 between the copy and relocation loop, as it was already set up in 1)
3) replace use of r9-r10 with e.g. r10-r11 in the copy loop, to preserve r9 during relocation.
4) Replace all "ldr rNN, _TEXT_BASE" with "adr rNN, _start".
Best is you submit a new RFC patch and when it is OK and you have validated through JTAG that it works, then re-submit it as a non-RFC patch to all start.S files in arch/arm/cpu/*.
Amicalement,
Signature · 1 line
Albert.
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Dear "GROYER, Anthony",
Dear Albert,
Am Mi 21 Sep 2011 12:51:33 CEST schrieb Albert ARIBAUD:
Quoted 2 lines
Le 21/09/2011 11:29, GROYER, Anthony a ?crit :
<snip>
Quoted 2 lines
3) replace use of r9-r10 with e.g. r10-r11 in the copy loop, to preserve r9 during relocation.
If one is changing this place I would like to discuss another point here. In my last changeset for relocation I found some implementation in a/a/c/pxa/start.S which do save the register to stack before copy_loop, use almost all registers (only r8 is not used which is gd_t for arm, but I think it could be used here too cause it is saved on the stack) and save the registers back later on.
I guess this could fasten the copy_loop a bit but needs to be proven. Anthony, if you change all start.S could you consider this also?
best regards
Andreas Bie?mann
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Le 21/09/2011 13:20, Andreas Bie?mann a ?crit :
Quoted 12 lines
Dear "GROYER, Anthony",
Dear Albert,Am Mi 21 Sep 2011 12:51:33 CEST schrieb Albert ARIBAUD:
Quoted 2 lines
Le 21/09/2011 11:29, GROYER, Anthony a ?crit :
<snip>
Quoted 2 lines
3) replace use of r9-r10 with e.g. r10-r11 in the copy loop, to preserve r9 during relocation.
Quoted 8 lines
If one is changing this place I would like to discuss another point here. In my last changeset for relocation I found some implementation in
a/a/c/pxa/start.Swhich do save the register to stack beforecopy_loop, use almost all registers (only r8 is not used which isgd_tfor arm, but I think it could be used here too cause it is saved on the stack) and save the registers back later on.
I guess this could fasten thecopy_loopa bit but needs to be proven. Anthony, if you change allstart.Scould you consider this also?
I am not 100% sure I get your point, but I assume that you are asking for *removal* of the saving and restoring, right? I would tend to agree that saving and restoring registers in relocate_code is moot, as this function does not return in the usual sense.
As for r8, it should be preserved as it points to gd, but that is ensured by the C code already IIRC.
Quoted 3 lines
best regards
Andreas Bie?mann
Amicalement,
Signature · 1 line
Albert.
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Dear Albert,
Am Mi 21 Sep 2011 14:03:09 CEST schrieb Albert ARIBAUD:
Quoted 24 lines
Le 21/09/2011 13:20, Andreas Bie?mann a ?crit :
Quoted 13 lines
Dear "GROYER, Anthony",
Dear Albert,Am Mi 21 Sep 2011 12:51:33 CEST schrieb Albert ARIBAUD:
Quoted 2 lines
Le 21/09/2011 11:29, GROYER, Anthony a ?crit :
<snip>
Quoted 3 lines
3) replace use of r9-r10 with e.g. r10-r11 in the copy loop, to preserve
r9 during relocation.Quoted 9 lines
If one is changing this place I would like to discuss another point here.
In my last changeset for relocation I found some implementation ina/a/c/pxa/start.Swhich do save the register to stack beforecopy_loop, use almost all registers (only r8 is not used which isgd_tfor arm, but I think it could be used here too cause it is saved on the stack) and save the registers back later on.
I guess this could fasten thecopy_loopa bit but needs to be proven. Anthony, if you change allstart.Scould you consider this also?
Quoted 2 lines
I am not 100% sure I get your point, but I assume that you are asking for *removal* of the saving and restoring, right?
No, that was not the point. I think the 'save registers before copy_loop to use more registers for ldmia/stmia instructions' is a good solution which could improve the copy_loop for all arm implementations.
Quoted 3 lines
I would tend to
agree that saving and restoring registers inrelocate_codeis moot, as this function does not return in the usual sense.
No the code does register save before copy_loop and restore them right afterwards. Therefore even r8 could be used in the copy_loop cause it is preserved on the (newly created) stack. Have a look at a/a/c/pxa/start.S from line 241 (relocate_code) to 263 (end of copy_loop).
But I guess the ldmia/stmia instructions could even use r3-r11, only r0-r2 needs to be preserved for loop counting.
I wonder if this could improve the copy_loop ... will try to test it these days, if no one else can do it (Anthony?).
Quoted 2 lines
As for r8, it should be preserved as it points to gd, but that is ensured by the C code already IIRC.
We use -ffixed-r8 therefore the compiler takes care for the C part, but we need to respect this in asm.
Well, if we preserve r8 for the copy_loop and restore it right afterwards we could use it in the copy_loop for copy purposes. Cause there is no dereferencing of r8 in copy_loop.
best regards
Andreas Bie?mann
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Le 21/09/2011 14:31, Andreas Bie?mann a ?crit :
Quoted 27 lines
Dear Albert,
Am Mi 21 Sep 2011 14:03:09 CEST schrieb Albert ARIBAUD:
Quoted 24 lines
Le 21/09/2011 13:20, Andreas Bie?mann a ?crit :
Quoted 22 lines
Dear "GROYER, Anthony",
Dear Albert,Am Mi 21 Sep 2011 12:51:33 CEST schrieb Albert ARIBAUD:
Quoted 2 lines
Le 21/09/2011 11:29, GROYER, Anthony a ?crit :
<snip>
Quoted 3 lines
3) replace use of r9-r10 with e.g. r10-r11 in the copy loop, to preserve
r9 during relocation.If one is changing this place I would like to discuss another point here.
In my last changeset for relocation I found some implementation ina/a/c/pxa/start.Swhich do save the register to stack beforecopy_loop, use almost all registers (only r8 is not used which isgd_tfor arm, but I think it could be used here too cause it is saved on the stack) and save the registers back later on.
I guess this could fasten thecopy_loopa bit but needs to be proven. Anthony, if you change allstart.Scould you consider this also?
Quoted 6 lines
Quoted 2 lines
I am not 100% sure I get your point, but I assume that you are asking for *removal* of the saving and restoring, right?
No, that was not the point. I think the 'save registers before
copy_loopto use more registers for ldmia/stmia instructions' is a good solution which could improve thecopy_loopfor all arm implementations.
I see -- you want to do a ldmia/stmia with a lot of regs.
Quoted 4 lines
Quoted 3 lines
I would tend to
agree that saving and restoring registers inrelocate_codeis moot, as this function does not return in the usual sense.
Quoted 8 lines
No the code does register save before
copy_loopand restore them right afterwards. Therefore even r8 could be used in thecopy_loopcause it is preserved on the (newly created) stack. Have a look ata/a/c/pxa/start.Sfrom line 241 (relocate_code) to 263 (end ofcopy_loop).
But I guess the ldmia/stmia instructions could even use r3-r11, only r0-r2 needs to be preserved for loop counting.
I wonder if this could improve thecopy_loop... will try to test it these days, if no one else can do it (Anthony?).
Apart from your question (how are the number of registers in ldmia and stmia speed related to the speed of the copy loop?) there is another
one: how do we handle the fact that the length to copy may not be a multiple of the ldmia/stmia 'width'? Even in arm926ejs/start.S, two registers are used, but the alignment for text+data is 4 bytes, not 8. This did not bite us so far, and should not, since we're going to copy into the space after .text, which *should* be .bss, which we'll zero right after. But Murphy's law could hit...
Quoted 5 lines
Quoted 2 lines
As for r8, it should be preserved as it points to gd, but that is ensured by the C code already IIRC.
We use -ffixed-r8 therefore the compiler takes care for the C part, but we need to respect this in asm.
in arm926ejs/start.S we do. If there are other start.S files where r8 is trashed, they should be fixed indeed.
Quoted 7 lines
Well, if we preserve r8 for the
copy_loopand restore it right afterwards we could use it in thecopy_loopfor copy purposes. Cause there is no dereferencing of r8 incopy_loop.best regards
Andreas Bie?mann
Amicalement,
Signature · 1 line
Albert.
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Dear Albert,
Am Mi 21 Sep 2011 16:23:56 CEST schrieb Albert ARIBAUD:
Quoted 10 lines
Le 21/09/2011 14:31, Andreas Bie?mann a ?crit :
Quoted 9 lines
Dear Albert,
Am Mi 21 Sep 2011 14:03:09 CEST schrieb Albert ARIBAUD:
Quoted 6 lines
Le 21/09/2011 13:20, Andreas Bie?mann a ?crit :
Quoted 5 lines
Dear "GROYER, Anthony",
Dear Albert,Am Mi 21 Sep 2011 12:51:33 CEST schrieb Albert ARIBAUD:
Quoted 1 line
Le 21/09/2011 11:29, GROYER, Anthony a ?crit :
<snip>
Quoted 5 lines
Apart from your question (how are the number of registers in ldmia and stmia speed related to the speed of the copy loop?) there is another
one: how do we handle the fact that the length to copy may not be a multiple of the ldmia/stmia 'width'? Even inarm926ejs/start.S, two registers are used, but the alignment for text+data is 4 bytes, not 8.
Good point. Well, we could implement some 'rewind' apart from .bss zeroing, if we care about it. I guess this could be done without any impact to copy time, if we really save time by using more regs for ldmia/stmia.
But how about reading beyond the _end symbol from flash crossing some border e.g. end of address space, end of flash space ... ?
Quoted 4 lines
This did not bite us so far, and should not, since we're going to copy into the space after .text, which *should* be .bss, which we'll zero right after. But Murphy's law could hit...
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
As for r8, it should be preserved as it points to gd, but that is ensured by the C code already IIRC.
We use -ffixed-r8 therefore the compiler takes care for the C part, but we need to respect this in asm.
in
arm926ejs/start.Swe do. If there are otherstart.Sfiles where r8 is trashed, they should be fixed indeed.
There should no one else left, my last changeset fixed it globally:
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/90010/focus=90013
best regards
Andreas Bie?mann
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
In reply to Andreas BießmannDear Albert,
Am 21.09.2011 um 14:31 schrieb Andreas Bie?mann:
Quoted 9 lines
Dear Albert,
Am Mi 21 Sep 2011 14:03:09 CEST schrieb Albert ARIBAUD:
Quoted 6 lines
Le 21/09/2011 13:20, Andreas Bie?mann a ?crit :
Quoted 5 lines
Dear "GROYER, Anthony",
Dear Albert,Am Mi 21 Sep 2011 12:51:33 CEST schrieb Albert ARIBAUD:
Quoted 1 line
Le 21/09/2011 11:29, GROYER, Anthony a ?crit :
<snip>
Quoted 8 lines
No the code does register save before
copy_loopand restore them right afterwards. Therefore even r8 could be used in thecopy_loopcause it is preserved on the (newly created) stack. Have a look ata/a/c/pxa/start.Sfrom line 241 (relocate_code) to 263 (end ofcopy_loop).
But I guess the ldmia/stmia instructions could even use r3-r11, only r0-r2 needs to be preserved for loop counting.
I wonder if this could improve thecopy_loop... will try to test it these days, if no one else can do it (Anthony?).
Simon, who has just finished his bachelor thesis did this test for me (thanks to this way ...). It seems using more register for ldmia/stmia does _not_ improve the copy
time that much. Simon measured 10.8 ms for r9-r10 and 10.65 ms for r3-r10 (unfortunately I do not know which system he tested, but I guess devkit8000).
best regards
Andreas Bie?mann
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
On 09/29/2011 06:14 PM, Andreas Bie?mann wrote:
[SNIP]
Quoted 10 lines
Simon, who has just finished his bachelor thesis did this test for me (thanks to this way ...). It seems using more register for ldmia/stmia does _not_ improve the copy
time that much. Simon measured 10.8 ms for r9-r10 and 10.65 ms for r3-r10 (unfortunately I do not know which system he tested, but I guess devkit8000).best regards
Andreas Bie?mann
Yes, devkit8000.
Regards
Simon
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Le 30/09/2011 09:21, Simon Schwarz a ?crit :
Quoted 11 lines · Andreas Bie?mann
[SNIP]
Quoted 9 lines
Simon, who has just finished his bachelor thesis did this test for me (thanks to this way ...).
It seems using more register for ldmia/stmia does _not_ improve the copy time that much. Simon measured 10.8 ms for r9-r10 and 10.65 ms for r3-r10 (unfortunately
I do not know which system he tested, but I guess devkit8000).best regards
Quoted 7 lines
Quoted 3 lines
Andreas Bie?mann
Yes, devkit8000.
Regards
Simon
Thanks to both of you. I'd somehow expected there not to be a great increase as the true limit is bus width.
So let us stick with two registers and avoid register pushes/pops.
Amicalement,
Signature · 1 line
Albert.
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
In reply to GROYERHi Anthony,
Quoted 11 lines · Anthony
Hello,
I came back on a discussion started on April 2011.
The use of the initial patches for the
CONFIG_SYS_SKIP_ARM_RELOCATIONfeatures has revealed two issues.First issue: the calculation of the relocation offset was done only if the relocation is actually done. So we could reach a point where r9 has a wrong value, since it has never been used before (in my case, this bug happens without JTAG). The first diff moves the relocation offset calculation before the test of a relocation need.
Second issue:
board_init_rwas thinking the memory area for the malloc is just below the code, whereas theboard_init_fhad allocated some space for the malloc at the end of the SDRAM. If the code is located at the base of the SDRAM withCONFIG_SYS_SKIP_ARM_RELOCATIONdefined, the malloc area does not point to a correct memory address. The 2 other diff store the calculated malloc start address in a global data member so that it can be used inboard_init_r().
Thanks for coming back to this. Hopefully you can do patches for the other CPU types also as Albert requests - and I can test armv7 when you do that. This feature is one that I use a lot with an ICE and I would like to see it in U-Boot.
Regards,
Simon
Quoted 168 lines
Index:
arch/arm/cpu/arm926ejs/start.S
===================================================================arm/cpu/arm926ejs/start.S ? ? ?(r?vision 1113) renamed from arm/cpu/arm926ejs/start.S ? ? ?(r?vision 1083) +0
-0@@ -196,6 +196,10 @@? ? ? ?mov ? ? r4, r0 ?/* save
addr_sp*/
? ? ? ?mov ? ? r5, r1 ?/* save addr of gd */
? ? ? ?mov ? ? r6, r2 ?/* save addr of destination */
+ ? ?/* set relocation offset here for all cases:
+ ? ? ? ?relocation or not */
+ ? ? ? ldr ? ? r0,_TEXT_BASE?/* r0 <- Text base */
+ ? ? ? sub ? ? r9, r6, r0 ? ? ? ? ? ? ?/* r9 <- relocation offset */? ? ? ?/* Set up the stack ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? */ ?stack_setup:
arm/cpu/arm926ejs/start.S ? ? ?(r?vision 1113) renamed from arm/cpu/arm926ejs/start.S ? ? ?(r?vision 1083) +0
-0@@ -218,8 +222,6 @@? ? ? ?/*
? ? ? ? * fix .rel.dyn relocations
? ? ? ? */
- ? ? ? ldr ? ? r0,_TEXT_BASE? ? ? ? ?/* r0 <- Text base */
- ? ? ? 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 */ ? ? ? ?ldr ? ? r2,_rel_dyn_start_ofs?/* r2 <- rel dyn start ofs */
Index:arch/arm/include/asm/global_data.h
===================================================================arm/include/asm/global_data.h ?(copie de travail) renamed from arm/include/asm/global_data.h ?(r?vision 1083) +0
-0@@ -69,6 +69,7 @@? ? ? ?unsigned long ?
mon_len; ? ? ? ?/* monitor len */
? ? ? ?unsigned long ?irq_sp; ? ? ? ? /* irq stack pointer */ ? ? ? ?unsigned long ?start_addr_sp; ?/*start_addr_stackpointer*/
+ ? ? ? unsigned long ?start_addr_malloc; ? ? ?/*start_addr_malloc*/ ? ? ? ?unsigned long ?reloc_off;
?#if !(defined(CONFIG_SYS_NO_ICACHE) &&defined(CONFIG_SYS_NO_DCACHE)) ? ? ? ?unsigned long ?tlb_addr;
Index:arch/arm/lib/board.c
===================================================================arm/lib/board.c ? ? ? ?(copie de travail) renamed from arm/lib/board.c ? ? ? ?(r?vision 1138) +0
-0@@ -367,6 +367,7 @@? ? ? ? * reserve memory for
malloc()arena
? ? ? ? */
? ? ? ?addr_sp = addr -TOTAL_MALLOC_LEN;
+ ? ?gd->start_addr_malloc =addr_sp;
? ? ? ?debug ("Reserving %dk formalloc()at: %08lx\n", ? ? ? ? ? ? ? ? ? ? ? ?TOTAL_MALLOC_LEN >> 10,addr_sp); ? ? ? ?/*arm/lib/board.c ? ? ? ?(copie de travail) renamed from arm/lib/board.c ? ? ? ?(r?vision 1138) +0
-1@@ -445,7 +446,6 @@ ?{ ? ? ? ?char *s; ? ? ? ?bd_t *bd; - ? ? ? ulong malloc_start; ?#if !defined(CONFIG_SYS_NO_FLASH) ? ? ? ?ulong flash_size;?#endif
arm/lib/board.c ? ? ? ?(copie de travail) renamed from arm/lib/board.c ? ? ? ?(r?vision 1138) +0
-0@@ -473,9 +473,7 @@ ? ? ? ?post_output_backlog ();?#endif
- ? ? ? /* The Malloc area is immediately below the monitor copy in DRAM */
- ? ? ?malloc_start=dest_addr-TOTAL_MALLOC_LEN;
- ? ? ?mem_malloc_init(malloc_start,TOTAL_MALLOC_LEN);
+ ? ? ?mem_malloc_init(gd->start_addr_malloc,TOTAL_MALLOC_LEN);?#if !defined(CONFIG_SYS_NO_FLASH)
? ? ? ?puts ("Flash: ");Regards,
Anthony GroyerQuoted 86 lines · Aneesh V
Quoted 35 lines
Hi Simon, Wolfgang,
Quoted 25 lines · Simon Glass
Quoted 10 lines · On Fri, Mar 25, 2011 at 11:35 AM, Albert ARIBAUD<[email protected]> ?wrote:
Le 25/03/2011 17:12, Aneesh V a ?crit :
Quoted 6 lines
Another problem I have with relocation is that it makes debugging with JTAG debugers more difficult. The addresses of symbols in the ELF target are no longer valid. Of course, you can load the symbols at an offset from the original location. But one has to first enable debug prints, find the relocation offset, use it while loading the symbols before you can do source level debugging.
Quoted 6 lines
Actually you don't need recompiling: simply set a breakpoint at the entry of
relocate_codeand once you hit the bp, look up r2: it contains the destination. If you want the offset rather than the absolute address, set the breakpoint right after the 'sub r9, r6, r0' round line 222: r9 will then give you the offset. Unload the current symbols, reload the symbols with the relevant offset, and there you go.I would like to revisit this thread. I'm not sure how other people do development in U-Boot but I like to use an ICE and a source-level debugger for any significant effort. I think it should be possible to use a JTAG debugging just by loading the u-boot ELF file and running.
Quoted 6 lines
With this patch (or something similar) this is possible. Without it, it is painful.
To be clear, we are not talking here about creating a platform that doesn't use relocation, just that for development purposes it is convenient to be able to disable it.
Quoted 5 lines
Actually, I am not even sure why relocation shouldn't be disabled in my platform for good. It may be useful to have things such as the frame buffer at the end of available memory. But, IMHO, that can still be done without relocating u-boot. That's what the patch does.Am I missing something?
Well relocation does remove a lot of this ad-hoc positioning of things at compile time. I think it is desirable. My point is that it is not engineer-friendly during development, and we should have an easy way to disable it for debugging / JTAG purposes.
Regards,
SimonQuoted 27 lines
Quoted 27 lines
Looking at the December thread
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/88067/focus=88262Aneesh:
Quoted 3 lines
Quoted 3 lines
Shouldn't we provide a CONFIG option by which users can disable Elf relocation?
Wolfgang:
Quoted 3 lines
Why should we? ?It would just make the code even more complicated, and require a lot of additional test cases.
?From what I can see this is a new CONFIG option, two ifdefs in the
board.cfile, and optionally disabling the -pie position-independent executable option to reduce size. It is pretty trivial:?arch/arm/config.mk ? | ? ?2 ++
?arch/arm/lib/board.c | ? ?5 +++++
?2 files changed, 7 insertions(+), 0 deletions(-)Regards,
SimonQuoted 1 line
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Amicalement,
--
Albert.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-bootQuoted 5 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Hi Simon,
Quoted 13 lines · Simon Glass
Hi Anthony,
Quoted 9 lines · Anthony
Hello,
I came back on a discussion started on April 2011.
The use of the initial patches for the
CONFIG_SYS_SKIP_ARM_RELOCATIONfeatures has revealed two issues.First issue: the calculation of the relocation offset was done only if the relocation is actually done. So we could reach a point where r9 has a wrong value, since it has never been used before (in my case, this bug happens without JTAG). The first diff moves the relocation offset calculation before the test of a relocation need.
Quoted 7 lines
Quoted 2 lines
Second issue:
board_init_rwas thinking the memory area for the malloc is just below the code, whereas theboard_init_fhad allocated some space for the malloc at the end of the SDRAM. If the code is located at the base of the SDRAM withCONFIG_SYS_SKIP_ARM_RELOCATIONdefined, the malloc area does not point to a correct memory address. The 2 other diff store the calculated malloc start address in a global data member so that it can be used inboard_init_r().Thanks for coming back to this. Hopefully you can do patches for the other CPU types also as Albert requests - and I can test armv7 when you do that. This feature is one that I use a lot with an ICE and I would like to see it in U-Boot.
Are you looking for CONFIG_SYS_SKIP_ARM_RELOCATION? I think Anthony is only fixing couple of issues uncovered by the original 'skip relocation' patch but I don't think CONFIG_SYS_SKIP_ARM_RELOCATION itself is getting accepted.
best regards,
Aneesh
Quoted 176 lines
Regards,
SimonQuoted 163 lines
Index:
arch/arm/cpu/arm926ejs/start.S
===================================================================arm/cpu/arm926ejs/start.S (r?vision 1113) renamed from arm/cpu/arm926ejs/start.S (r?vision 1083) +4
-2@@ -196,6 +196,10 @@ mov r4, r0 /* save addr_sp */ mov r5, r1 /* save addr of gd */ mov r6, r2 /* save addr of destination */ + /* set relocation offset here for all cases: + relocation or not */ + ldr r0, _TEXT_BASE /* r0 <- Text base */ + sub r9, r6, r0 /* r9 <- relocation offset */ /* Set up the stack */ stack_setup:@@ -218,8 +222,6 @@ /* * fix .rel.dyn relocations */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - 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 */ ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */Index:
arch/arm/include/asm/global_data.h
===================================================================arm/include/asm/global_data.h (copie de travail) renamed from arm/include/asm/global_data.h (r?vision 1083) +1
-0@@ -69,6 +69,7 @@ unsigned long mon_len; /* monitor len */ unsigned long irq_sp; /* irq stack pointer */ unsigned long start_addr_sp; /* start_addr_stackpointer */ + unsigned long start_addr_malloc; /* start_addr_malloc */ unsigned long reloc_off; #if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE)) unsigned long tlb_addr;Index:
arch/arm/lib/board.c
===================================================================arm/lib/board.c (copie de travail) renamed from arm/lib/board.c (r?vision 1138) +2
-4@@ -367,6 +367,7 @@ * reserve memory for malloc() arena */ addr_sp = addr - TOTAL_MALLOC_LEN; + gd->start_addr_malloc = addr_sp; debug ("Reserving %dk for malloc() at: %08lx\n", TOTAL_MALLOC_LEN >> 10, addr_sp); /*@@ -445,7 +446,6 @@ { char *s; bd_t *bd; - ulong malloc_start; #if !defined(CONFIG_SYS_NO_FLASH) ulong flash_size; #endif@@ -473,9 +473,7 @@ post_output_backlog (); #endif - /* The Malloc area is immediately below the monitor copy in DRAM */ - malloc_start = dest_addr - TOTAL_MALLOC_LEN; - mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN); + mem_malloc_init (gd->start_addr_malloc, TOTAL_MALLOC_LEN); #if !defined(CONFIG_SYS_NO_FLASH) puts ("Flash: ");Regards,
Anthony GroyerQuoted 86 lines · Aneesh V
Quoted 35 lines
Hi Simon, Wolfgang,
Quoted 25 lines · Simon Glass
Quoted 10 lines · Albert ARIBAUD
Le 25/03/2011 17:12, Aneesh V a ?crit :
Quoted 6 lines
Another problem I have with relocation is that it makes debugging with JTAG debugers more difficult. The addresses of symbols in the ELF target are no longer valid. Of course, you can load the symbols at an offset from the original location. But one has to first enable debug prints, find the relocation offset, use it while loading the symbols before you can do source level debugging.
Quoted 6 lines
Actually you don't need recompiling: simply set a breakpoint at the entry of
relocate_codeand once you hit the bp, look up r2: it contains the destination. If you want the offset rather than the absolute address, set the breakpoint right after the 'sub r9, r6, r0' round line 222: r9 will then give you the offset. Unload the current symbols, reload the symbols with the relevant offset, and there you go.I would like to revisit this thread. I'm not sure how other people do development in U-Boot but I like to use an ICE and a source-level debugger for any significant effort. I think it should be possible to use a JTAG debugging just by loading the u-boot ELF file and running.
Quoted 6 lines
With this patch (or something similar) this is possible. Without it, it is painful.
To be clear, we are not talking here about creating a platform that doesn't use relocation, just that for development purposes it is convenient to be able to disable it.
Quoted 5 lines
Actually, I am not even sure why relocation shouldn't be disabled in my platform for good. It may be useful to have things such as the frame buffer at the end of available memory. But, IMHO, that can still be done without relocating u-boot. That's what the patch does.Am I missing something?
Well relocation does remove a lot of this ad-hoc positioning of things at compile time. I think it is desirable. My point is that it is not engineer-friendly during development, and we should have an easy way to disable it for debugging / JTAG purposes.
Regards,
SimonQuoted 27 lines
Quoted 27 lines
Looking at the December thread
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/88067/focus=88262Aneesh:
Quoted 3 lines
Quoted 3 lines
Shouldn't we provide a CONFIG option by which users can disable Elf relocation?
Wolfgang:
Quoted 3 lines
Why should we? It would just make the code even more complicated, and require a lot of additional test cases.
From what I can see this is a new CONFIG option, two ifdefs in the
board.cfile, and optionally disabling the -pie position-independent executable option to reduce size. It is pretty trivial:arch/arm/config.mk | 2 ++ arch/arm/lib/board.c | 5 +++++ 2 files changed, 7 insertions(+), 0 deletions(-)Regards,
SimonQuoted 1 line
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Amicalement,
--
Albert.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-bootQuoted 5 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-bootQuoted 5 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Hi Aneesh,
Quoted 24 lines · Aneesh V
Hi Simon,
Quoted 13 lines · Simon Glass
Hi Anthony,
Quoted 9 lines · Anthony
Hello,
I came back on a discussion started on April 2011.
The use of the initial patches for the
CONFIG_SYS_SKIP_ARM_RELOCATIONfeatures has revealed two issues.First issue: the calculation of the relocation offset was done only if the relocation is actually done. So we could reach a point where r9 has a wrong value, since it has never been used before (in my case, this bug happens without JTAG). The first diff moves the relocation offset calculation before the test of a relocation need.
Quoted 7 lines
Quoted 2 lines
Second issue:
board_init_rwas thinking the memory area for the malloc is just below the code, whereas theboard_init_fhad allocated some space for the malloc at the end of the SDRAM. If the code is located at the base of the SDRAM withCONFIG_SYS_SKIP_ARM_RELOCATIONdefined, the malloc area does not point to a correct memory address. The 2 other diff store the calculated malloc start address in a global data member so that it can be used inboard_init_r().Thanks for coming back to this. Hopefully you can do patches for the other CPU types also as Albert requests - and I can test armv7 when you do that. This feature is one that I use a lot with an ICE and I would like to see it in U-Boot.
Quoted 4 lines
Are you looking for
CONFIG_SYS_SKIP_ARM_RELOCATION? I think Anthony is only fixing couple of issues uncovered by the original 'skip relocation' patch but I don't thinkCONFIG_SYS_SKIP_ARM_RELOCATIONitself is getting accepted.
I see. That is sad, because skipping relocation is very useful for development. Why do we make things harder for devs than they need to be?
Regards,
Simon
Quoted 181 lines
best regards,
AneeshQuoted 176 lines
Regards,
SimonQuoted 163 lines
Index:
arch/arm/cpu/arm926ejs/start.S
===================================================================arm/cpu/arm926ejs/start.S ? ? ?(r?vision 1113) renamed from arm/cpu/arm926ejs/start.S ? ? ?(r?vision 1083) +0
-0@@ -196,6 +196,10 @@? ? ? ?mov ? ? r4, r0 ?/* save
addr_sp*/
? ? ? ?mov ? ? r5, r1 ?/* save addr of gd */
? ? ? ?mov ? ? r6, r2 ?/* save addr of destination */
+ ? ?/* set relocation offset here for all cases:
+ ? ? ? ?relocation or not */
+ ? ? ? ldr ? ? r0,_TEXT_BASE?/* r0 <- Text base */
+ ? ? ? sub ? ? r9, r6, r0 ? ? ? ? ? ? ?/* r9 <- relocation offset */? ? ? ?/* Set up the stack ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? */ ?stack_setup:
arm/cpu/arm926ejs/start.S ? ? ?(r?vision 1113) renamed from arm/cpu/arm926ejs/start.S ? ? ?(r?vision 1083) +0
-0@@ -218,8 +222,6 @@? ? ? ?/*
? ? ? ? * fix .rel.dyn relocations
? ? ? ? */
- ? ? ? ldr ? ? r0,_TEXT_BASE? ? ? ? ?/* r0 <- Text base */
- ? ? ? 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 */ ? ? ? ?ldr ? ? r2,_rel_dyn_start_ofs?/* r2 <- rel dyn start ofs */
Index:arch/arm/include/asm/global_data.h
===================================================================arm/include/asm/global_data.h ?(copie de travail) renamed from arm/include/asm/global_data.h ?(r?vision 1083) +0
-0@@ -69,6 +69,7 @@? ? ? ?unsigned long ?
mon_len; ? ? ? ?/* monitor len */
? ? ? ?unsigned long ?irq_sp; ? ? ? ? /* irq stack pointer */ ? ? ? ?unsigned long ?start_addr_sp; ?/*start_addr_stackpointer*/
+ ? ? ? unsigned long ?start_addr_malloc; ? ? ?/*start_addr_malloc*/ ? ? ? ?unsigned long ?reloc_off;
?#if !(defined(CONFIG_SYS_NO_ICACHE) &&defined(CONFIG_SYS_NO_DCACHE)) ? ? ? ?unsigned long ?tlb_addr;
Index:arch/arm/lib/board.c
===================================================================arm/lib/board.c ? ? ? ?(copie de travail) renamed from arm/lib/board.c ? ? ? ?(r?vision 1138) +0
-0@@ -367,6 +367,7 @@? ? ? ? * reserve memory for
malloc()arena
? ? ? ? */
? ? ? ?addr_sp = addr -TOTAL_MALLOC_LEN;
+ ? ?gd->start_addr_malloc =addr_sp;
? ? ? ?debug ("Reserving %dk formalloc()at: %08lx\n", ? ? ? ? ? ? ? ? ? ? ? ?TOTAL_MALLOC_LEN >> 10,addr_sp); ? ? ? ?/*arm/lib/board.c ? ? ? ?(copie de travail) renamed from arm/lib/board.c ? ? ? ?(r?vision 1138) +0
-1@@ -445,7 +446,6 @@ ?{ ? ? ? ?char *s; ? ? ? ?bd_t *bd; - ? ? ? ulong malloc_start; ?#if !defined(CONFIG_SYS_NO_FLASH) ? ? ? ?ulong flash_size;?#endif
arm/lib/board.c ? ? ? ?(copie de travail) renamed from arm/lib/board.c ? ? ? ?(r?vision 1138) +0
-0@@ -473,9 +473,7 @@ ? ? ? ?post_output_backlog ();?#endif
- ? ? ? /* The Malloc area is immediately below the monitor copy in DRAM */
- ? ? ?malloc_start=dest_addr-TOTAL_MALLOC_LEN;
- ? ? ?mem_malloc_init(malloc_start,TOTAL_MALLOC_LEN);
+ ? ? ?mem_malloc_init(gd->start_addr_malloc,TOTAL_MALLOC_LEN);?#if !defined(CONFIG_SYS_NO_FLASH)
? ? ? ?puts ("Flash: ");Regards,
Anthony GroyerQuoted 86 lines · Aneesh V
Quoted 35 lines
Hi Simon, Wolfgang,
Quoted 25 lines · Simon Glass
Quoted 10 lines · On Fri, Mar 25, 2011 at 11:35 AM, Albert ARIBAUD<[email protected]> ?wrote:
Le 25/03/2011 17:12, Aneesh V a ?crit :
Quoted 6 lines
Another problem I have with relocation is that it makes debugging with JTAG debugers more difficult. The addresses of symbols in the ELF target are no longer valid. Of course, you can load the symbols at an offset from the original location. But one has to first enable debug prints, find the relocation offset, use it while loading the symbols before you can do source level debugging.
Quoted 6 lines
Actually you don't need recompiling: simply set a breakpoint at the entry of
relocate_codeand once you hit the bp, look up r2: it contains the destination. If you want the offset rather than the absolute address, set the breakpoint right after the 'sub r9, r6, r0' round line 222: r9 will then give you the offset. Unload the current symbols, reload the symbols with the relevant offset, and there you go.I would like to revisit this thread. I'm not sure how other people do development in U-Boot but I like to use an ICE and a source-level debugger for any significant effort. I think it should be possible to use a JTAG debugging just by loading the u-boot ELF file and running.
Quoted 6 lines
With this patch (or something similar) this is possible. Without it, it is painful.
To be clear, we are not talking here about creating a platform that doesn't use relocation, just that for development purposes it is convenient to be able to disable it.
Quoted 5 lines
Actually, I am not even sure why relocation shouldn't be disabled in my platform for good. It may be useful to have things such as the frame buffer at the end of available memory. But, IMHO, that can still be done without relocating u-boot. That's what the patch does.Am I missing something?
Well relocation does remove a lot of this ad-hoc positioning of things at compile time. I think it is desirable. My point is that it is not engineer-friendly during development, and we should have an easy way to disable it for debugging / JTAG purposes.
Regards,
SimonQuoted 27 lines
Quoted 27 lines
Looking at the December thread
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/88067/focus=88262Aneesh:
Quoted 3 lines
Quoted 3 lines
Shouldn't we provide a CONFIG option by which users can disable Elf relocation?
Wolfgang:
Quoted 3 lines
Why should we? ?It would just make the code even more complicated, and require a lot of additional test cases.
?From what I can see this is a new CONFIG option, two ifdefs in the
board.cfile, and optionally disabling the -pie position-independent executable option to reduce size. It is pretty trivial:?arch/arm/config.mk ? | ? ?2 ++
?arch/arm/lib/board.c | ? ?5 +++++
?2 files changed, 7 insertions(+), 0 deletions(-)Regards,
SimonQuoted 1 line
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Amicalement,
--
Albert.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-bootQuoted 5 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-bootQuoted 5 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Hi Simon,
Le 23/09/2011 18:04, Simon Glass a ?crit :
Quoted 8 lines
Quoted 4 lines
Are you looking for
CONFIG_SYS_SKIP_ARM_RELOCATION? I think Anthony is only fixing couple of issues uncovered by the original 'skip relocation' patch but I don't thinkCONFIG_SYS_SKIP_ARM_RELOCATIONitself is getting accepted.I see. That is sad, because skipping relocation is very useful for development. Why do we make things harder for devs than they need to be?
There is at least a possibility to avoid relocation without introducing the CONFIG_SYS_SKIP_ARM_RELOCATION flag; set CONFIG_SKIP_LOWLEVEL_INIT and adjust CONFIG_SYS_TEXT_BASE to be the base address where your code will be located. It is a two-round process (you need a first run with the 'wrong' CONFIG_SYS_TEXT_BASE in order to find its 'right' value) and will work only for a given board variant (same available RAM amount always) but might be enough to cover the use case(s) you are looking for?
Quoted 2 lines
Regards,
Simon
Amicalement,
Signature · 1 line
Albert.
RFC PATCH 1/1 arm: provide a CONFIG flag for disabling relocation
Hi Albert,
Quoted 13 lines · Albert ARIBAUD
Hi Simon,
Le 23/09/2011 18:04, Simon Glass a ?crit :
Quoted 8 lines
Quoted 4 lines
Are you looking for
CONFIG_SYS_SKIP_ARM_RELOCATION? I think Anthony is only fixing couple of issues uncovered by the original 'skip relocation' patch but I don't thinkCONFIG_SYS_SKIP_ARM_RELOCATIONitself is getting accepted.I see. That is sad, because skipping relocation is very useful for development. Why do we make things harder for devs than they need to be?
Quoted 7 lines
There is at least a possibility to avoid relocation without introducing the
CONFIG_SYS_SKIP_ARM_RELOCATIONflag; setCONFIG_SKIP_LOWLEVEL_INITand adjustCONFIG_SYS_TEXT_BASEto be the base address where your code will be located. It is a two-round process (you need a first run with the 'wrong'CONFIG_SYS_TEXT_BASEin order to find its 'right' value) and will work only for a given board variant (same available RAM amount always) but might be enough to cover the use case(s) you are looking for?
In other words, still relocation, but we 'know' where it will relocate to after it does its maths.
It works, but it's a little brittle, and I would prefer a simple option to disable relocation for devs. I keep such a patch around for when I am using an ICE. Is the concern that people might use it in their boards? Should be easy enough to refuse patches which do include it.
Regards,
Simon
Quoted 5 lines
Amicalement,
--
Albert.