Skip to content
Advertisement

how to disassebled binary with source line and file name using gcc-linaro-arm-linux-gnueabihf-objdump?

I want to get the disassebled binary files with source line and file name. I have added option -g as a compilation option,following is the setting in cmake files.

SET(CMAKE_CXX_COMPILER "/home/desword/gcc-linaro-arm-linux-gnueabihf-4.8/bin/arm-linux-gnueabihf-g++")
SET(CMAKE_CXX_FLAGS "-std=c++11 -s -g")

And following is my objdump bash script:

objdump=/home/desword/gcc-linaro-arm-linux-gnueabihf-4.8/bin/arm-linux-gnueabihf-objdump
$objdump -dl bin/main > bin/asmmain2.txt

From the instructions, I should have a asm file with source line and file name just as https://manpages.debian.org/testing/binutils-arm-linux-gnueabihf/arm-linux-gnueabihf-objdump.1.en.html

it says:

–line-numbers Label the display (using debugging information) with the filename and source line numbers corresponding to the object code or relocs shown. Only useful with -d, -D, or -r.

However, I just got the file like the following:

0002092c <_ZN3PRU15gpioNumToPruMapEh>:
   2092c:   b580        push    {r7, lr}
   2092e:   b082        sub sp, #8
   20930:   af00        add r7, sp, #0
   20932:   6078        str r0, [r7, #4]
   20934:   460b        mov r3, r1
   20936:   70fb        strb    r3, [r7, #3]
   20938:   78fb        ldrb    r3, [r7, #3]
   2093a:   3b07        subs    r3, #7
   2093c:   2b6e        cmp r3, #110    ; 0x6e
   2093e:   f200 8119   bhi.w   20b74 <_ZN3PRU15gpioNumToPruMapEh+0x248>
   20942:   a201        add r2, pc, #4  ; (adr r2, 20948 <_ZN3PRU15gpioNumToPruMapEh+0x1c>)
   20944:   f852 f023   ldr.w   pc, [r2, r3, lsl #2]
   20948:   0b15        lsrs    r5, r2, #12
   2094a:   0002        movs    r2, r0
   2094c:   0b75        lsrs    r5, r6, #13
   2094e:   0002        movs    r2, r0
   20950:   0b75        lsrs    r5, r6, #13
   20952:   0002        movs    r2, r0

THere are no source line and file name. In expectation, I want get the file like this:

000003f6 <LedsP__Init__init>:
LedsP__Init__init():
/home/desword/tinyos-main-2_1_2/tos/system/LedsP.nc:56
     3f6:   cf 93           push    r28
     3f8:   df 93           push    r29
     3fa:   cd b7           in  r28, 0x3d   ; 61
     3fc:   de b7           in  r29, 0x3e   ; 62
/home/desword/tinyos-main-2_1_2/tos/system/LedsP.nc:59
     3fe:   0e 94 10 02     call    0x420   ; 0x420 <LedsP__Led0__makeOutput>
/home/desword/tinyos-main-2_1_2/tos/system/LedsP.nc:60
     402:   0e 94 27 02     call    0x44e   ; 0x44e <LedsP__Led1__makeOutput>
/home/desword/tinyos-main-2_1_2/tos/system/LedsP.nc:61
     406:   0e 94 3e 02     call    0x47c   ; 0x47c <LedsP__Led2__makeOutput>
/home/desword/tinyos-main-2_1_2/tos/system/LedsP.nc:62
     40a:   0e 94 55 02     call    0x4aa   ; 0x4aa <LedsP__Led0__set>
/home/desword/tinyos-main-2_1_2/tos/system/LedsP.nc:63

Anyone can help me! thanks!

Advertisement

Answer

SET(CMAKE_CXX_FLAGS "-std=c++11 -s -g")

Try remove the -s switch, which strip away information. It works for me.

Advertisement