我个人认为这是一个巨大的生产力杀手,至少对我而言.我们尝试使用更新版本的ld(2.19)但没有任何成功.我在#freenode的#debian上问过,但这个问题似乎很独特.我没有在网上找到有关类似问题的任何信息.它只在我们使用调试符号构建时才会发生.我将gcc deBUG-information标志更改为-g,-g3和-ggdb,但这也没有帮助.
所以我的问题是,你如何分析和调试链接器?我从未做过类似的事情,我也找不到任何关于它的文档.基本上任何合理的gprof gmon.out都会非常有用,因为我可以向binutils开发人员询问具体问题.我对此完全没有意识到.
编辑:我们在大多数系统上“修复”我们的问题转换为debian lenny.谢谢你的答案!
解决方法 如果您正在观察运行gcc的减速(而不是直接将链接器作为ld运行),请尝试使用$gcc -save-temps -v [... rest of your command line ...]
这将打印出所有中间命令,例如内部collect2和final ld,并确保传递给这些命令的对象即使在命令完成后仍将保留在磁盘上.
然后,您应该能够单独运行命令以找到最差的阶段,然后使用不同的选项或分析运行它.
例如,
$echo 'int main() {}' > test.c$gcc -save-temps -v test.cUsing built-in specs.Target: x86_64-pc-linux-gnuConfigured with: /var/tmp/paludis/sys-devel-gcc-4.3.3-r2/work/gcc-4.3.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.3.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --disable-libgcj --enable-objc-gc --enable-languages=c,c++,objc,obj-c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-BUGurl=http://BUGs.gentoo.org/ --with-pkgversion='Gentoo 4.3.3-r2 p1.1,pIE-10.1.5'Thread model: posixgcc version 4.3.3 (Gentoo 4.3.3-r2 p1.1,pIE-10.1.5)ColLECT_GCC_OPTIONS='-save-temps' '-v' '-mtune=generic' /usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/cc1 -E -quIEt -v test.c -D_FORTIFY_SOURCE=2 -mtune=generic -fpch-preprocess -o test.iignoring nonexistent directory "/usr/local/include"ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/include"#include "..." search starts here:#include search starts here: /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/include /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/include-fixed /usr/includeEnd of search List.ColLECT_GCC_OPTIONS='-save-temps' '-v' '-mtune=generic' /usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/cc1 -fpreprocessed test.i -quIEt -dumpbase test.c -mtune=generic -auxbase test -version -o test.sGNU C (Gentoo 4.3.3-r2 p1.1,pIE-10.1.5) version 4.3.3 (x86_64-pc-linux-gnu) compiled by GNU C version 4.3.3,GMP version 4.2.4,MPFR version 2.4.1-p5.warning: GMP header version 4.2.4 differs from library version 4.3.1.GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072Compiler executable checksum: 20f3dbffbfd03e5311a257ae1239cd71ColLECT_GCC_OPTIONS='-save-temps' '-v' '-mtune=generic' /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy -o test.o test.sGNU assembler version 2.19.1 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.19.1COMPILER_PATH=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/bin/liBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../:/lib/:/usr/lib/ColLECT_GCC_OPTIONS='-save-temps' '-v' '-mtune=generic' /usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/crtbegin.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../.. test.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/crtend.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crtn.o$lsa.out test.c test.i test.o test.s$/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/crtbegin.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../.. test.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/crtend.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crtn.o$.../collect2 -v ...collect2 version 4.3.3 (x86-64 linux/ELF)/usr/bin/ld -v --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/crtbegin.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../.. test.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/crtend.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crtn.oGNU ld (GNU Binutils) 2.19.1$
如果您需要帮助构建ld的调试版本,这里有一个快速的方法来帮助您.
$sudo apt-get install build-essential dpkg-dev$sudo apt-get build-dep binutils$apt-get source binutils$cd binutils-*$DEB_BUILD_OPTIONS='deBUG noopt nostrip' dpkg-buildpackage -uc -us$cd ..$sudo dpkg -i *.deb
但是,我建议使用schroot或sbuild来避免污染您自己的系统,而不是快速入侵.
总结以上是内存溢出为你收集整理的linux – 如何在debian系统上调试(慢)链接器全部内容,希望文章能够帮你解决linux – 如何在debian系统上调试(慢)链接器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)