user2302555
user2302555

Reputation: 41

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

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.

Upvotes: 4

Views: 4100

Answers (2)

rashok
rashok

Reputation: 13464

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.

Upvotes: 2

user2302555
user2302555

Reputation: 41

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.

Upvotes: 0

Related Questions