gcc ld error “libgcov.a(_gcov_merge_add.o) is referenced by DSO”

◇◆丶佛笑我妖孽 提交于 2020-01-15 04:36:26

问题


Trying to compiler our code for code coverage using gcov. Getting following error:

hidden symbol `__gcov_merge_add' in /usr/lib/gcc/i686-redhat-linux/4.4.4/libgcov.a(_gcov_merge_add.o) is referenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status

Following compiler options are newly added for gcov:

-O0 -fprofile-arcs -ftest-coverage  -Xlinker -zmuldefs

and ld flags:

-fprofile-generate -fprofile-arcs

and linked with library -lgcov

Please suggest.


回答1:


We are able to enable the code coverage using simply --coverage -O0 compiler options and finally linking with -lgcov for RHEL 6.* version.

However same doesnt with debian where we had to use -O0 -fprofile-arcs -ftest-coverage -Xlinker -zmuldefs to make code coverage enabled binaries.




回答2:


Solution for this issue is

  • Compile with -fprofile-arcs -ftest-coverage
  • Link with -fprofile-arcs -lgcov

I also got this same error when I was not using -fprofile-arcs while linking.



来源:https://stackoverflow.com/questions/16122599/gcc-ld-error-libgcov-a-gcov-merge-add-o-is-referenced-by-dso

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