gpt4 book ai didi

c++ - 如何使用 gcc-linaro-arm-linux-gnueabihf-objdump 使用源代码行和文件名分解二进制文件?

转载 作者:太空宇宙 更新时间:2023-11-04 12:13:27 27 4
gpt4 key购买 nike

我想获取带有源代码行和文件名的反汇编二进制文件。我添加了选项-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

根据说明,我应该有一个 asm 文件,其源行和文件名与 https://manpages.debian.org/testing/binutils-arm-linux-gnueabihf/arm-linux-gnueabihf-objdump.1.en.html 一样

它说:

--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 开关,它会去除信息。它对我有用。

关于c++ - 如何使用 gcc-linaro-arm-linux-gnueabihf-objdump 使用源代码行和文件名分解二进制文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48163313/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com