Sorry for my poor English. I want to clearly understand the linking processes,especially detail string loading process. <br>In fact, I use objcopy to convert the u-boot.bin to u-boot.elf, then using objdump to process elf.<br>
(In my real enviroment, I only had the MIPS arch binary format, need to convert it first. )<br>"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 ?<br>
there need some address convert from the binary file,<br>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.<br>
What's the relationship among them ?<br><br>I update the dump info, please see it.<br><br>--------------------------------------------------------------------------------------------------------------<br>u-boot.map<br>
<br>.reloc 0xfff34000 0x1578<br> *(.got)<br> 0xfff34000 _GOT2_TABLE_ = .<br> *(.got2)<br> .got2 0xfff34000 0x24 cpu/mpc8260/start.o<br> .got2 0xfff34024 0x4c cpu/mpc8260/libmpc8260.a(traps.o)<br>
------------------------------------------------------------------------------------------------------------------<br>fff03564 <print_backtrace><br>fff03564: 94 21 ff d8 stwu r1,-40(r1)<br>fff03568: 7c 08 02 a6 mflr r0<br>
fff0356c: 42 9f 00 05 bcl- 20,4*cr7+so,fff03570 <print_backtrace+0xc> <br>fff03570: bf 61 00 14 stmw r27,20(r1)<br>fff03574: 7f c8 02 a6 mflr r30<br>fff03578: 90 01 00 2c stw r0,44(r1)<br>
fff0357c: 80 1e ff f0 lwz r0,-16(r30)<br>fff03580: 7c 7c 1b 78 mr r28,r3<br>fff03584: 3b e0 00 00 li r31,0<br>fff03588: 7f c0 f2 14 add r30,r0,r30<br>fff0358c: 80 7e 80 00 lwz r3,-32768(r30)<br>
fff03590: 48 01 1b ad bl fff1513c <puts><br>fff03594: 2c 1c 00 00 cmpwi r28,0<br>fff03598: 41 82 00 70 beq- fff03608 <print_backtrace+0xa4> <br>fff0359c: 3c 00 02 00 lis r0,512<br>
fff035a0: 7c 1c 00 40 cmplw r28,r0<br>fff035a4: 3d 20 92 49 lis r9,-28087<br>fff035a8: 61 29 24 93 ori r9,r9,9363<br>fff035ac: 7f eb fe 70 srawi r11,r31,31<br>fff035b0: 38 60 00 0a li r3,10<br>
fff035b4: 41 81 00 54 bgt- fff03608 <print_backtrace+0xa4> <br>fff035b8: 7c 1f 48 96 mulhw r0,r31,r9<br>fff035bc: 83 7c 00 04 lwz r27,4(r28)<br>fff035c0: 7c 00 fa 14 add r0,r0,r31<br>
fff035c4: 7c 00 16 70 srawi r0,r0,2<br>fff035c8: 7c 0b 00 50 subf r0,r11,r0<br>fff035cc: 1c 00 00 07 mulli r0,r0,7<br>fff035d0: 7c 00 f8 50 subf r0,r0,r31<br>fff035d4: 2c 00 00 00 cmpwi r0,0<br>
fff035d8: 3b ff 00 01 addi r31,r31,1<br>fff035dc: 40 a2 00 08 bne+ fff035e4 <print_backtrace+0x80> <br>fff035e0: 48 01 1b 21 bl fff15100 <putc><br>fff035e4: 80 7e 80 04 lwz r3,-32764(r30)<br>
fff035e8: 7f 64 db 78 mr r4,r27<br>fff035ec: 4c c6 31 82 crclr 4*cr1+eq<br>fff035f0: 48 01 1b 89 bl fff15178 <printf><br>fff035f4: 2c 1f 00 20 cmpwi r31,32<br>fff035f8: 41 81 00 10 bgt- fff03608 <print_backtrace+0xa4> <br>
fff035fc: 83 9c 00 00 lwz r28,0(r28)<br>fff03600: 2c 1c 00 00 cmpwi r28,0<br>fff03604: 40 82 ff 98 bne+ fff0359c <print_backtrace+0x38> <br>fff03608: 38 60 00 0a li r3,10<br>
fff0360c: 48 01 1a f5 bl fff15100 <putc><br>fff03610: bb 61 00 14 lmw r27,20(r1)<br>fff03614: 80 01 00 2c lwz r0,44(r1)<br>fff03618: 38 21 00 28 addi r1,r1,40<br>fff0361c: 7c 08 03 a6 mtlr r0<br>
fff03620: 4e 80 00 20 blr<br>fff03624: 00 03 89 f0 .long 0x389f0<br>-------------------------------------------------------------------------------------------------------------------<br>u-boot.bin<br>0002b280h: 43 61 6C 6C 20 62 61 63 6B 74 72 61 63 65 3A 20 ; Call backtrace: <br>
<br>print_backtrace()<br>00003584h: 94 21 FF D8 7C 08 02 A6 42 9F 00 05 BF 61 00 14 ; ?貄..?.縜..<br>00003594h: 7F C8 02 A6 90 01 00 2C 80 1E FF F0 7C 7C 1B 78 ; ?..,€.饇|.x<br>000035a4h: 3B E0 00 00 7F C0 F2 14 80 7E 80 00 48 01 1B AD ; ;?.莉.€~€.H..?<br>
000035b4h: 2C 1C 00 00 41 82 00 70 3C 00 02 00 7C 1C 00 40 ; ,...A?p<...|..@<br>000035c4h: 3D 20 92 49 61 29 24 93 7F EB FE 70 38 60 00 0A ; = 扞a)$?膻p8`..<br>000035d4h: 41 81 00 54 7C 1F 48 96 83 7C 00 04 7C 00 FA 14 ; A?T|.H杻|..|.?<br>
000035e4h: 7C 00 16 70 7C 0B 00 50 1C 00 00 07 7C 00 F8 50 ; |..p|..P....|.鳳<br>000035f4h: 2C 00 00 00 3B FF 00 01 40 A2 00 08 48 01 1B 21 ; ,...;..@?.H..!<br>00003604h: 80 7E 80 04 7F 64 DB 78 4C C6 31 82 48 01 1B 89 ; €~€.d踴L?侶..?<br>
00003614h: 2C 1F 00 20 41 81 00 10 83 9C 00 00 2C 1C 00 00 ; ,.. A?.儨..,...<br>00003624h: 40 82 FF 98 38 60 00 0A 48 01 1A F5 BB 61 00 14 ; @??`..H..趸a..<br>00003634h: 80 01 00 2C 38 21 00 28 7C 08 03 A6 4E 80 00 20 ; €..,8!.(|..€. <br>
00003644h: 00 03 89 F0 ; ..夝<br><br>---------------------------------------------------------------------------------------------------------------------<br>cpu\mpc8260\traps.c<br>void print_backtrace(unsigned long *sp)<br>
{<br> int cnt = 0;<br> unsigned long i;<br><br> puts ("Call backtrace: ");<br> while (sp) {<br> if ((uint)sp > END_OF_MEM)<br> break;<br><br> i = sp[1];<br> if (cnt++ % 7 == 0)<br>
putc ('\n');<br> printf("%08lX ", i);<br> if (cnt > 32) break;<br> sp = (unsigned long *)*sp;<br> }<br> putc ('\n');<br>}<br><br><br><br><br><br><br>On Wed, Jun 4, 2008 at 8:49 PM, Jerry Van Baren <<a href="mailto:gerald.vanbaren@ge.com">gerald.vanbaren@ge.com</a>> wrote:<br>
> wang baohua wrote:<br>>><br>>> Dear all,<br>>> I study the U-boot.bin file using the objdump command, I don't know how<br>>> the CPU can find the right string address when puts() string.<br>
>> For example, In my binary file, the string "Call backtrace: " in func<br>>> "print_backtrace()" address is :0x0002b280, the func address is<br>>> 0xfff03564, How the CPU can find the 0x0002b280 when call puts ("Call<br>
>> backtrace: "); ? I find the SMC serial driver<br>>> "serial_putc()" but cannot know how to find the char address in binary<br>>> file.<br>>> Below is the objdump result, can anyone explain to me ? thanks!<br>
><br>> Please don't post HTML, use plain text.<br>><br>> I don't understand your question, why are you asking it? Are you trying to<br>> figure out a problem or are you just trying to understand the linking<br>
> processes?<br>><br>> Using objdump on u-boot.bin is not valid. U-boot.bin is a binary file,<br>> objdump works on ELF (linker formatted) files.<br>><br>> <<a href="http://en.wikipedia.org/wiki/Executable_and_Linkable_Format">http://en.wikipedia.org/wiki/Executable_and_Linkable_Format</a>><br>
><br>> When you link the ELF files, the linker fixes up all the addresses so the<br>> linker sets the proper address in the instruction that the CPU ultimately<br>> executes. The u-boot.bin file is a raw binary dump of the result.<br>
><br>> Was that your question???<br>><br>> Best regards,<br>> gvb<br>><br><br>