GCC不能包括CRT*.O的调试信息吗?
我正在使用Ghidra进行一些二进制分析,但它不支持矮人5:
ghidra.app.util.bin.format.dwarf4.dwarfexception:当前仅支持矮版2、3或4个信息。
好的,我会用-gdwarf-4 -gstrict-dwarf
...重建所有内容...
ghidra.app.util.bin.format.dwarf4.dwarfexception:当前仅支持矮版2、3或4个信息。
嗯,这是怎么回事?
$ cat foo.c int main(){ 返回0; } $ gcc -gdwarf -4 -gstrict -dwarf foo.c -o foo $ readelf -w foo ... 汇编单元 @ offset 0x0: 长度:0x24(32位) 版本:5 单元类型:DW_UT_COMPILE(1) Abbrev偏移:0x0 指针尺寸:8 < 0>< c>:abbrev编号:1(dw_tag_compile_unit) < d> dw_at_stmt_list:0x0 < 11> DW_AT_LOW_PC:0x1020 < 19> DW_AT_HIGH_PC:38 < 1a> dw_at_name :(间接字符串,偏移:0x0):../ sysdeps/x86_64/start.s < 1e> dw_at_comp_dir :(间接字符串,偏移:0x1a):/build/build/glibc/src/glibc/csu < 22> dw_at_producer :(间接字符串,偏移:0x35):gnu as 2.38 ...
啊,来自crti.o
和朋友有一堆矮人5调试信息。我可以告诉GCC或LD在保留自己的调试信息的同时从二进制中省略它们吗?
I am using Ghidra for some binary analysis, but it doesn't support DWARF 5:
ghidra.app.util.bin.format.dwarf4.DWARFException: Only DWARF version 2, 3, or 4 information is currently supported.
Okay fine, I'll rebuild everything with -gdwarf-4 -gstrict-dwarf
...
ghidra.app.util.bin.format.dwarf4.DWARFException: Only DWARF version 2, 3, or 4 information is currently supported.
Hmm, what's going on?
$ cat foo.c int main() { return 0; } $ gcc -gdwarf-4 -gstrict-dwarf foo.c -o foo $ readelf -w foo ... Compilation Unit @ offset 0x0: Length: 0x24 (32-bit) Version: 5 Unit Type: DW_UT_compile (1) Abbrev Offset: 0x0 Pointer Size: 8 <0><c>: Abbrev Number: 1 (DW_TAG_compile_unit) <d> DW_AT_stmt_list : 0x0 <11> DW_AT_low_pc : 0x1020 <19> DW_AT_high_pc : 38 <1a> DW_AT_name : (indirect string, offset: 0x0): ../sysdeps/x86_64/start.S <1e> DW_AT_comp_dir : (indirect string, offset: 0x1a): /build/glibc/src/glibc/csu <22> DW_AT_producer : (indirect string, offset: 0x35): GNU AS 2.38 ...
Ah, there's a bunch of DWARF 5 debug info from crti.o
and friends. Can I tell gcc or ld to omit them from the binary, while keeping my own debug info?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想到了这种骇人听闻的方法:首先,首先,通过将
-v
传递给链接器的链接到哪些CRT对象:接下来,手动剥离它们:
它有效!
I came up with this hacky approach: first, first, figure out which crt objects are being linked by passing
-v
to the linker:Next, strip them manually:
And it works!