This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can objdump show friendly symbolic function name?


On Thu, 15 Jul 2010, Pan ruochen wrote:

> I am developing with mips-linux toolchain. I always need to do some
> analysis on the disassembly code.
> But objdump displays as following:
> ----------------------------------------------------------------------------------------
> 0001c370 <semget>:
>    1c370:   3c1c0005    lui gp,0x5
>    1c374:   279ce080    addiu   gp,gp,-8064
>    1c378:   0399e021    addu    gp,gp,t9
>    1c37c:   27bdffd8    addiu   sp,sp,-40
>    1c380:   afbf0024    sw  ra,36(sp)
>    1c384:   afbc0018    sw  gp,24(sp)
>    1c388:   00a01021    move    v0,a1
>    1c38c:   00c03821    move    a3,a2
>    1c390:   00403021    move    a2,v0
>    1c394:   8f828880    lw  v0,-30592(gp)
>    1c398:   8f998204    lw  t9,-32252(gp)
>    1c39c:   2403ffff    li  v1,-1
>    1c3a0:   ac430000    sw  v1,0(v0)
>    1c3a4:   00802821    move    a1,a0
>    1c3a8:   afa00010    sw  zero,16(sp)
>    1c3ac:   afa00014    sw  zero,20(sp)
>    1c3b0:   0320f809    jalr    t9
>    1c3b4:   24040002    li  a0,2
>    1c3b8:   8fbf0024    lw  ra,36(sp)
>    1c3bc:   8fbc0018    lw  gp,24(sp)
>    1c3c0:   03e00008    jr  ra
>    1c3c4:   27bd0028    addiu   sp,sp,40
> ----------------------------------------------------------------------------------------
> 
> It is really hard to read disassembly code like that since I can't see which
> function is called from `jalr t9'.

 Fair enough.

 You *might* be able to get some more information about the symbol the PIC 
call instruction refers to if you use "-r" to intersperse relocations with 
the disassembly -- there may be a call hint relocation associated with 
"jalr $t9".  Then again, maybe not.  It's only an optimisation hint.

 Failing that you can only track down manually what "lw t9,-32252(gp)" 
refers to.  Try `readelf -A' as an aid.

 Teaching `objdump' what symbol this instruction's memory operand refers 
to would be a nice, but I fear that quite a non-trivial enhancement.  And 
you can't do that for actual call instructions that use the register mode 
as static analysis is certainly beyond the scope of `objdump'.

> Is there some way to inform objdump to display more friendly symbolic name
> as following?
> 
> bfc020f8 <try_nand_flash_boot>:
> bfc020f8:	27bdffe0 	addiu	sp,sp,-32
> bfc020fc:	3c02b404 	lui	v0,0xb404
> bfc02100:	afbf001c 	sw	ra,28(sp)
> bfc02104:	afb20018 	sw	s2,24(sp)
> bfc02108:	afb10014 	sw	s1,20(sp)
> bfc0210c:	afb00010 	sw	s0,16(sp)
> bfc02110:	00809021 	move	s2,a0
> bfc02114:	0ff007a0 	jal	bfc01e80 <reset_gpio>
> bfc02118:	24501000 	addiu	s0,v0,4096
> bfc0211c:	0ff007f9 	jal	bfc01fe4 <nand_flash_init>
> ...

 There's no such problem with non-PIC objects like this one because 
addresses used by call instructions are immediates (or the instructions 
have relocations associated) that can be cross-referred to the symbol 
table.

  Maciej


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]