如何使用 gcc-linaro-arm-linux-gnueabihf-objdump 使用源行和文件名分解二进制文件?
how to disassebled binary with source line and file name using gcc-linaro-arm-linux-gnueabihf-objdump?
我想获取带有源行和文件名的反汇编二进制文件。
我添加了选项-g作为编译选项,以下是cmake文件中的设置。
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")
下面是我的 objdump bash 脚本:
objdump=/home/desword/gcc-linaro-arm-linux-gnueabihf-4.8/bin/arm-linux-gnueabihf-objdump
$objdump -dl bin/main > bin/asmmain2.txt
根据说明,我应该有一个源行和文件名与 https://manpages.debian.org/testing/binutils-arm-linux-gnueabihf/arm-linux-gnueabihf-objdump.1.en.html
相同的 asm 文件
它说:
--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.
但是,我得到的文件如下所示:
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
没有源行和文件名。在期望中,我希望得到这样的文件:
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
任何人都可以帮助我!谢谢!
SET(CMAKE_CXX_FLAGS "-std=c++11 -s -g")
尝试删除 -s
开关,它会删除信息。它对我有用。
我想获取带有源行和文件名的反汇编二进制文件。 我添加了选项-g作为编译选项,以下是cmake文件中的设置。
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")
下面是我的 objdump bash 脚本:
objdump=/home/desword/gcc-linaro-arm-linux-gnueabihf-4.8/bin/arm-linux-gnueabihf-objdump
$objdump -dl bin/main > bin/asmmain2.txt
根据说明,我应该有一个源行和文件名与 https://manpages.debian.org/testing/binutils-arm-linux-gnueabihf/arm-linux-gnueabihf-objdump.1.en.html
相同的 asm 文件它说:
--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.
但是,我得到的文件如下所示:
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
没有源行和文件名。在期望中,我希望得到这样的文件:
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
任何人都可以帮助我!谢谢!
SET(CMAKE_CXX_FLAGS "-std=c++11 -s -g")
尝试删除 -s
开关,它会删除信息。它对我有用。