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.cint 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?