Re: gcov fails to work with shared library on 64bit platform

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mu Qiao <qiaomuf@xxxxxxxxx> writes:

> On Fri, May 13, 2011 at 10:49 PM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
>> Mu Qiao <qiaomuf@xxxxxxxxx> writes:
>>
>>> /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 find this line in the output of readelf -s:
> 18447: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND atexit
>
> These are the flags I used for compiling:
> -D_GLIBCXX_DEBUG -std=c++0x -Wall -Wextra -Wold-style-cast
> -Woverloaded-virtual -Wsign-promo -pedantic-errors -Werror --coverage
> -fvisibility=hidden -fvisibility-inlines-hidden -g -fPIC -DPIC
>
> This is the command for linking:
>
> libtool: link: g++ -shared -nostdlib
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/crti.o
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/crtbeginS.o
> src/.libs/libcppbash_la-libbash.o
> src/.libs/libcppbash_la-cppbash_builtin.o
> src/builtins/.libs/libcppbash_la-echo_builtin.o
> src/builtins/.libs/libcppbash_la-source_builtin.o
> src/builtins/.libs/libcppbash_la-return_builtin.o
> src/builtins/.libs/libcppbash_la-inherit_builtin.o
> .libs/libcppbash_la-libbashLexer.o .libs/libcppbash_la-libbashParser.o
> src/core/.libs/libcppbash_la-interpreter.o
> src/core/.libs/libcppbash_la-bash_ast.o  -Wl,--whole-archive
> ./.libs/libwalker.a -Wl,--no-whole-archive  -lantlr3c
> -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2
> -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64
> -L/lib/../lib64 -L/usr/lib/../lib64
> -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/lib
> -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../.. -lstdc++ -lm -lc
> -lgcc_s /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/crtendS.o
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../lib64/crtn.o
> --coverage   -Wl,-soname -Wl,libcppbash.so.0 -o
> .libs/libcppbash.so.0.0.0
>
> I googled and some people say that -nostdlib in the linking command
> caused the problem. But the command is run by libtool. I don't know
> what to do with it except applying a patch.


Yes, this problem is coming from -nostdlib.  That is telling g++ to not
link against -lc, which means that there is no definition of atexit.

If this command is coming from libtool then you need to talk to the
libtool maintainers to find out why they are using -nostdlib.  Or I
suppose you could explicitly link against -lc.


>>> 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?
>>
>
> I mean my configure script. "configure --diable-shared" works fine on
> both 32bit and 64bit machine.

If this works for you, there is nothing wrong with doing that.  Of
course, then you don't get a shared library.

Ian



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux