gnu ld/gdb: separate debug files. How to produce the debug file when there's too much debug info to link?

*爱你&永不变心* 提交于 2019-12-05 18:12:59

Initially it appeared that the binutils gold linker was capable of building large -g shared libs, providing a solution for (3) above, however, it turns out that is because of a lack of error checking.

On the other hand it looks like work on (1) and (2) is in available if a bleeding edge toolchain is used, part of the fission dwarf/binutils/gcc work described here:

This fission work was mentioned in discussion of a bugzilla report on this relocation truncation error:

http://sourceware.org/bugzilla/show_bug.cgi?id=15444

An example of the use of this split debug files is:

g++ -gsplit-dwarf -gdwarf-4   -c -o main.o main.cpp
gcc -gsplit-dwarf -gdwarf-4   -c -o d1/t1.o d1/t1.c
g++ -gsplit-dwarf -gdwarf-4   -c -o d2/t2.o d2/t2.cpp
gcc -Wl,--index-gdb main.o d1/t1.o d2/t2.o   -o main

where gcc/g++ are version 4.8, the binutils trunk (cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils) has been used configured with --enable-gold=default, and finally using gdb version 7.6 which can read the split debug info.

Joining gcc in the party, the intel (version 16) compiler supports -gsplit-dwarf. The intel compiler documents that binutils-2.24+,gdb-7.6.1+ are required. The clang compiler codebase has some split dwarf support, but I don't know what state that support is in.

I had similar issue with linker when compiling with g++ (v6.3.0) + gold linker (v2.27) + “-g” parameter.

staticlib.a(sharedlib.o):(.debug_loc+0x1d38): relocation truncated to fit: R_X86_64_32 against `.debug_info' staticlib.a(sharedlib.o):(.debug_loc+0x6c8c): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status gmake: *** [exec_file] Error 1 287.760u 35.837s 7:30.37 71.8% 0+0k 17217048+14932696io 0pf+0w

Adding the parameter "-fdebug-types-section" fixed this issue.

More details at: https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!