This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcov fails to work with shared library on 64bit platform
- From: Ian Lance Taylor <iant at google dot com>
- To: Mu Qiao <qiaomuf at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 13 May 2011 07:49:23 -0700
- Subject: Re: gcov fails to work with shared library on 64bit platform
- References: <BANLkTi=4VuBRyZockyFNj0OcMYXe+Dehuw@mail.gmail.com>
Mu Qiao <qiaomuf@gmail.com> writes:
> I have a C++ shared library project. When I add "--coverage" to
> CXXFLAGS(I also added -g and -O0) and LDFLAGS, the project fails to
> compile, here's the error message:
>
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/bin/ld:
> .libs/variable_printer: hidden symbol `atexit' in
> /usr/lib64/libc_nonshared.a(atexit.oS) is referenced by DSO
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/bin/ld:
> final link failed: Nonrepresentable section on output
> collect2: ld returned 1 exit status
> make[1]: *** [variable_printer] Error 1
The linker message is not very helpful in that it doesn't tell us where
the hidden symbol is referenced from. At a guess, the reference is from
your C++ shared library. You can verify that by using "readelf -r" and
"readelf -s" on the shared library and looking for atexit. If you find
it there as an undefined symbol, then what is the command that you use
to build your shared library?
> I tried with
> "configure --disable-shared" and it worked for us. But I don't know
> the reason of the above error and can't be sure if --disable-shared is
> the correct solution.
Which configure script do you mean here? The gcc configure script or
yours?
Ian