[U-Boot-Users] Question About how the CPU find the right string address in U-boot binary file ?

wang baohua wbh7602 at gmail.com
Thu Jun 5 04:07:42 CEST 2008


Sorry for my poor English. I want to clearly understand the linking
processes,especially detail string loading process.
In fact, I use objcopy to convert the u-boot.bin to u-boot.elf, then using
objdump to process elf.
(In my real enviroment, I only had the MIPS arch binary format, need to
convert it first. )
"u-boot.bin file is a raw binary dump of the result". Can you detail tell me
the how to find the right string address when call puts("") in a func ? Now
I know the string in the .got section, but how to calc the loading address ?
there need some address convert from the binary file,
you see the string "Call backtrace:" address is 0x0002b280, func
print_backtrace() address is 0x00003584(in objdump is 0xfff03564), module
traps.o .got2  address  is 0xfff34024.
What's the relationship among them ?

I update the dump info, please see it.

--------------------------------------------------------------------------------------------------------------
u-boot.map

.reloc          0xfff34000     0x1578
 *(.got)
                0xfff34000                _GOT2_TABLE_ = .
 *(.got2)
 .got2          0xfff34000       0x24 cpu/mpc8260/start.o
 .got2          0xfff34024       0x4c cpu/mpc8260/libmpc8260.a(traps.o)
 ------------------------------------------------------------------------------------------------------------------
fff03564 <print_backtrace>
fff03564:    94 21 ff d8       stwu    r1,-40(r1)
fff03568:    7c 08 02 a6     mflr    r0
fff0356c:    42 9f 00 05      bcl-    20,4*cr7+so,fff03570
<print_backtrace+0xc>
fff03570:    bf 61 00 14      stmw    r27,20(r1)
fff03574:    7f c8 02 a6      mflr    r30
fff03578:    90 01 00 2c     stw     r0,44(r1)
fff0357c:    80 1e ff f0        lwz     r0,-16(r30)
fff03580:    7c 7c 1b 78     mr      r28,r3
fff03584:    3b e0 00 00     li      r31,0
fff03588:    7f c0 f2 14       add     r30,r0,r30
fff0358c:    80 7e 80 00     lwz     r3,-32768(r30)
fff03590:    48 01 1b ad     bl      fff1513c <puts>
fff03594:    2c 1c 00 00     cmpwi   r28,0
fff03598:    41 82 00 70     beq-    fff03608
<print_backtrace+0xa4>
fff0359c:    3c 00 02 00     lis     r0,512
fff035a0:    7c 1c 00 40     cmplw   r28,r0
fff035a4:    3d 20 92 49     lis     r9,-28087
fff035a8:    61 29 24 93     ori     r9,r9,9363
fff035ac:    7f eb fe 70       srawi   r11,r31,31
fff035b0:    38 60 00 0a     li      r3,10
fff035b4:    41 81 00 54     bgt-    fff03608
<print_backtrace+0xa4>
fff035b8:    7c 1f 48 96      mulhw   r0,r31,r9
fff035bc:    83 7c 00 04     lwz     r27,4(r28)
fff035c0:    7c 00 fa 14      add     r0,r0,r31
fff035c4:    7c 00 16 70     srawi   r0,r0,2
fff035c8:    7c 0b 00 50     subf    r0,r11,r0
fff035cc:    1c 00 00 07     mulli   r0,r0,7
fff035d0:    7c 00 f8 50      subf    r0,r0,r31
fff035d4:    2c 00 00 00     cmpwi   r0,0
fff035d8:    3b ff 00 01       addi    r31,r31,1
fff035dc:    40 a2 00 08     bne+    fff035e4
<print_backtrace+0x80>
fff035e0:    48 01 1b 21     bl      fff15100 <putc>
fff035e4:    80 7e 80 04     lwz     r3,-32764(r30)
fff035e8:    7f 64 db 78      mr      r4,r27
fff035ec:    4c c6 31 82     crclr   4*cr1+eq
fff035f0:    48 01 1b 89      bl      fff15178 <printf>
fff035f4:    2c 1f 00 20       cmpwi   r31,32
fff035f8:    41 81 00 10      bgt-    fff03608
<print_backtrace+0xa4>
fff035fc:    83 9c 00 00      lwz     r28,0(r28)
fff03600:    2c 1c 00 00     cmpwi   r28,0
fff03604:    40 82 ff 98       bne+    fff0359c
<print_backtrace+0x38>
fff03608:    38 60 00 0a     li      r3,10
fff0360c:    48 01 1a f5      bl      fff15100 <putc>
fff03610:    bb 61 00 14     lmw     r27,20(r1)
fff03614:    80 01 00 2c     lwz     r0,44(r1)
fff03618:    38 21 00 28     addi    r1,r1,40
fff0361c:    7c 08 03 a6     mtlr    r0
fff03620:    4e 80 00 20     blr
fff03624:    00 03 89 f0     .long 0x389f0
-------------------------------------------------------------------------------------------------------------------
u-boot.bin
0002b280h: 43 61 6C 6C 20 62 61 63 6B 74 72 61 63 65 3A 20 ; Call backtrace:


print_backtrace()
00003584h: 94 21 FF D8 7C 08 02 A6 42 9F 00 05 BF 61 00 14 ; ?貄..?.縜..
00003594h: 7F C8 02 A6 90 01 00 2C 80 1E FF F0 7C 7C 1B 78 ; ?..,€.饇|.x
000035a4h: 3B E0 00 00 7F C0 F2 14 80 7E 80 00 48 01 1B AD ; ;?.莉.€~€.H..?
000035b4h: 2C 1C 00 00 41 82 00 70 3C 00 02 00 7C 1C 00 40 ; ,...A?p<...|..@
000035c4h: 3D 20 92 49 61 29 24 93 7F EB FE 70 38 60 00 0A ; = 扞a)$?膻p8`..
000035d4h: 41 81 00 54 7C 1F 48 96 83 7C 00 04 7C 00 FA 14 ; A?T|.H杻|..|.?
000035e4h: 7C 00 16 70 7C 0B 00 50 1C 00 00 07 7C 00 F8 50 ; |..p|..P....|.鳳
000035f4h: 2C 00 00 00 3B FF 00 01 40 A2 00 08 48 01 1B 21 ; ,...;..@?.H..!
00003604h: 80 7E 80 04 7F 64 DB 78 4C C6 31 82 48 01 1B 89 ; €~€.d踴L?侶..?
00003614h: 2C 1F 00 20 41 81 00 10 83 9C 00 00 2C 1C 00 00 ; ,.. A?.儨..,...
00003624h: 40 82 FF 98 38 60 00 0A 48 01 1A F5 BB 61 00 14 ; @??`..H..趸a..
00003634h: 80 01 00 2C 38 21 00 28 7C 08 03 A6 4E 80 00 20 ; €..,8!.(|..€.
00003644h: 00 03 89 F0                                     ; ..夝

---------------------------------------------------------------------------------------------------------------------
cpu\mpc8260\traps.c
void  print_backtrace(unsigned long *sp)
{
    int cnt = 0;
    unsigned long i;

    puts ("Call backtrace: ");
    while (sp) {
        if ((uint)sp > END_OF_MEM)
            break;

        i = sp[1];
        if (cnt++ % 7 == 0)
            putc ('\n');
        printf("%08lX ", i);
        if (cnt > 32) break;
        sp = (unsigned long *)*sp;
    }
    putc ('\n');
}






On Wed, Jun 4, 2008 at 8:49 PM, Jerry Van Baren <gerald.vanbaren at ge.com>
wrote:
> wang baohua wrote:
>>
>> Dear all,
>>  I study the U-boot.bin file using the objdump command, I don't know how
>> the CPU can find the right string address when puts() string.
>>  For example, In my binary file, the string "Call backtrace: " in func
>> "print_backtrace()" address is :0x0002b280, the func address is
>>  0xfff03564, How the CPU can find the 0x0002b280 when call  puts ("Call
>> backtrace: "); ?  I find the SMC serial driver
>>  "serial_putc()" but cannot know how to find the char address in binary
>> file.
>>  Below is the objdump result, can anyone explain to me ? thanks!
>
> Please don't post HTML, use plain text.
>
> I don't understand your question, why are you asking it?  Are you trying
to
> figure out a problem or are you just trying to understand the linking
> processes?
>
> Using objdump on u-boot.bin is not valid.  U-boot.bin is a binary file,
> objdump works on ELF (linker formatted) files.
>
> <http://en.wikipedia.org/wiki/Executable_and_Linkable_Format>
>
> When you link the ELF files, the linker fixes up all the addresses so the
> linker sets the proper address in the instruction that the CPU ultimately
> executes.  The u-boot.bin file is a raw binary dump of the result.
>
> Was that your question???
>
> Best regards,
> gvb
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20080605/d02edd10/attachment.htm 


More information about the U-Boot mailing list