[U-Boot-Users] fixup section problem.

Hi,
We are working in a MPC5200B based custom board and we are developping a tool to relocate a U-Boot (1.1.4 version) binary file to a different address in flash that it was linked. So, we have to change the GOT and FIXUP entries in the original file to point at the new address. Doing this work, we have found that, surprisingly, the FIXUP section in U-Boot is empty. When U-Boot is relocated from flash to sdram these lines in the file start.S have no effect: /* * Now adjust the fixups and the pointers to the fixups * in case we need to move ourselves again. */ 2: li r0,__fixup_entries@sectoff@l lwz r3,GOT(_FIXUP_TABLE_) cmpwi r0,0 mtctr r0 addi r3,r3,-4 beq 4f 3: lwzu r4,4(r3) lwzux r0,r4,r11 add r0,r0,r11 stw r10,0(r3) stw r0,0(r4) bdnz 3b 4: Looking into the sources we have found some places where the fixup elements seem to be relocated manually, i.e.: void malloc_bin_reloc (void) { DECLARE_GLOBAL_DATA_PTR;
unsigned long *p = (unsigned long *)(&av_[2]); int i;
for (i=2; i<(sizeof(av_)/sizeof(mbinptr)); ++i) { *p++ += gd->reloc_off; } } Is there any reason to leave the FIXUP section empty in U-Boot? Is it a bug?.
Checking the u-boot.lds file for the IceCube board we have found that fhe fixup section is included in the TEXT section and in the RELOC section, but the linker generate code only for the TEXT section. If we put it only in the RELOC section the FIXUP is not empty, the pointers adjustement in the start.S seems to work properly and the malloc_bin_reloc() function would be not necessary. Does anynone know if I'am missing something?
Any clue will be welcomed. Best regards,

Hello,
in message 4549B883.7050309@aotek.es you wrote:
Looking into the sources we have found some places where the fixup elements seem to be relocated manually, i.e.:
Yes, all statically initialized pointers need to be relocated manually.
Is there any reason to leave the FIXUP section empty in U-Boot? Is it a bug?.
This is probably a side-effect of my limited untestanding of the linker magic. Please feel free to call it a bug.
Checking the u-boot.lds file for the IceCube board we have found that fhe fixup section is included in the TEXT section and in the RELOC section, but the linker generate code only for the TEXT section. If we put it only in the RELOC section the FIXUP is not empty, the pointers adjustement in the start.S seems to work properly and the malloc_bin_reloc() function would be not necessary. Does anynone know if I'am missing something?
Most probably you know more about these things than me, so any fix to make relocation simpler and more reliable are welcome.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
Most probably you know more about these things than me, so any fix to make relocation simpler and more reliable are welcome.
Hi Wolfgang, OK, I will try to do it. But I only can check the changes in the Lite5200B and IceCube boards. My idea, to not disturb the rest of platforms, is to define a new configuration word, CFG_FIXUP_RELOCATION , and only define it for these boards. What do you thing? If you agree I can submit a patch for the 1.1.6 version.
Best regards,
Wolfgang Denk

Dear Txema,
in message 454AEC9E.9000808@aotek.es you wrote:
OK, I will try to do it. But I only can check the changes in the Lite5200B and IceCube boards. My idea, to not disturb the rest of platforms, is to define a new configuration word, CFG_FIXUP_RELOCATION , and only define it for these boards. What do you thing? If you agree I can submit a patch for the 1.1.6 version.
Relocation is not board dependent, so if it works onone board it should work for all. Please create your patch for all boards, i. e. without CFG_FIXUP_RELOCATION etc., and post it here. Me and others will help testing it.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
Dear Txema,
Relocation is not board dependent, so if it works onone board it should work for all. Please create your patch for all boards, i. e. without CFG_FIXUP_RELOCATION etc., and post it here. Me and others will help testing it.
Best regards,
Wolfgang Denk
Hi Wolfgang,
I'm not sure if this patch could work for not PowerPC based architectures. Taking a look in the U-Boot starting files for mips and bf533 cpu's, it seems that only the GOT section is relocated in ram, so the patch probably won't work. Furthermore, there is some fpga's relocations that I can't understand, and I don't know what is the effect of my patch for boards with a fpga. I mean I can't supply a patch valid for all architectures without doing some bugs.
I think the method I suggest you using a new define It's quite reasonable. I'll summit the patch for the Lite5200's and the rest of boards will be not affected. If someone want to use or test the fixup relocation for his board only has to do two changes: - cleanup the fixup section from the text section in the u-boot.lds file. - define CFG_FIXUP_RELOCATION in the board configuration file.
I believe this is the safest way to do it. What do you think?
Best regards,

On 11/3/06, Txema Lopez tlopez@aotek.es wrote:
I think the method I suggest you using a new define It's quite reasonable. I'll summit the patch for the Lite5200's and the rest of boards will be not affected. If someone want to use or test the fixup relocation for his board only has to do two changes: - cleanup the fixup section from the text section in the u-boot.lds file. - define CFG_FIXUP_RELOCATION in the board configuration file.
Txema,
How's your work on this patch coming along? I've got the same problem with new code that I've written for the Xilinx virtex boards. I don't want to do the manual relocation hack, so I'm very much looking forward to seeing your fix.
Cheers, g.
participants (3)
-
Grant Likely
-
Txema Lopez
-
Wolfgang Denk