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

Kenneth Johansson kenneth at southpole.se
Wed Jun 4 16:51:16 CEST 2008


On Wed, 2008-06-04 at 12:04 +0800, 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.

it's not exactly clear what you ask but lets start from the beginning. 

r3 is the register used by a function call that takes one argument. 
so puts() will print the string that is in this register when it is
called. 

for the caller to get the correct address into r3 is a bit more work.
u-boot is for powerpc compiled to be relocatable so the actual address
of the string will be put into one entry in the  GOT table (.got2
section). The compiler will then generate code that reads out the
address from this table and put it into r3. 

In the code below you can se that at address fff0358c r3 is set to what
is in entry 0 in the .got table. hint r30 points in the middle of the
table and quite possible outside any memory you have this is since the
register offset is singed value and we want to maximize the numbers of
entries.


> assemble code
> fff03564 <print_backtrace>: ---> length: C0,  u-boot.bin  address
> 0x00003584,offset address: 0xFFEFFFE0
> 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>







More information about the U-Boot mailing list