https://sourceware.org/bugzilla/show_bug.cgi?id=33033
Bug ID: 33033 Summary: objcopy/objdump/gdb cannot handle >4GiB compressed debug info section Product: binutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: rui314 at gmail dot com Target Milestone: --- Debug info for modern programs can be quite large. This example is somewhat artificial (the real programs that trigger this issue are proprietary), but if you, for example, build LLVM/Clang with the following CMake options, the binary’s .debug_info section exceeds 5 GiB. cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DLLVM_USE_LINKER=mold -DLLVM_ENABLE_PROJECTS='clang;lld' -DLLVM_OPTIMIZED_TABLEGEN=ON -DCMAKE_CXX_FLAGS='-g3 -gdwarf-5 -gdwarf64' ../llvm Although binutils and GDB generally can handle such large debug info sections, they fail when these sections are compressed. ``` $ ls -lh bin/clang-21 -rwxrwxr-x 1 ruiu ruiu 6.4G May 30 16:52 bin/clang-21 $ readelf -S bin/clang-21 | grep debug [34] .debug_abbrev PROGBITS 0000000000000000 172765e3 1eddb28 00 0 0 1 [35] .debug_aranges PROGBITS 0000000000000000 19154110 36290c0 00 0 0 16 [36] .debug_info PROGBITS 0000000000000000 1c77d1d0 14358dd3d 00 0 0 1 [37] .debug_line PROGBITS 0000000000000000 15fd0af0d bd54cb3 00 0 0 1 [38] .debug_line_str PROGBITS 0000000000000000 16ba5fbc0 055101 01 MS 0 0 1 [39] .debug_macro PROGBITS 0000000000000000 16bab4cc1 1efee00 00 0 0 1 [40] .debug_rnglists PROGBITS 0000000000000000 16d9b3ac1 2263595 00 0 0 1 [41] .debug_str PROGBITS 0000000000000000 16fc17056 10f2833f 01 MS 0 0 1 $ gdb bin/clang-21 -ex quit Reading symbols from bin/clang-21... $ objcopy --compress-debug-sections bin/clang-21 $ readelf -S bin/clang-21 | grep debug [34] .debug_abbrev PROGBITS 0000000000000000 172765e8 71ffc7 00 C 0 0 8 [35] .debug_aranges PROGBITS 0000000000000000 179965b0 66ff32 00 C 0 0 8 [36] .debug_info PROGBITS 0000000000000000 180064e8 6bd68c49 00 C 0 0 8 [37] .debug_line PROGBITS 0000000000000000 83d6f138 308aa4b 00 C 0 0 8 [38] .debug_line_str PROGBITS 0000000000000000 86df9b88 011d4e 01 MSC 0 0 8 [39] .debug_macro PROGBITS 0000000000000000 86e0b8d8 751893 00 C 0 0 8 [40] .debug_rnglists PROGBITS 0000000000000000 8755d170 60ef25 00 C 0 0 8 [41] .debug_str PROGBITS 0000000000000000 87b6c098 4bd8975 01 MSC 0 0 8 $ gdb bin/clang-21 -ex quit "/home/ruiu/llvm-project/b3/bin/clang-21": not in executable format: file format not recognized $ objcopy --decompress-debug-sections bin/clang-21 objcopy: bin/clang-21: file format not recognized ``` As shown, objcopy can compress extremely large debug info sections, but fails to decompress its own output. It appears that binutils/GDB cannot handle compressed debug sections if their uncompressed size exceeds 4 GiB. The expected behavior is that binutils and GDB handle such large compressed sections just as they do uncompressed ones. If you have trouble reproducing the issue, I've uploaded the clang executable with very large debug info sections here. You should be able to reproduce the problem simply by running the above commands. You may need the mold linker to link such large clang executable. https://drive.google.com/file/d/1wCtdnT3Iu9FRiF3bFCcvARZfp7C8-x4d/view?usp=sharing -- You are receiving this mail because: You are on the CC list for the bug.