This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC 4.7.2: Mudflap linker errors


On 09/22/2012 07:11 AM, bd satish wrote:
> Hi,
>
> Here is the output of (gcc -v):
> Using built-in specs.
> COLLECT_GCC=g++
> COLLECT_LTO_WRAPPER=/home/user/installed/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/lto-wrapper
> Target: x86_64-unknown-linux-gnu
> Configured with: ../configure --prefix=/home/user/installed/gcc
> --enable-languages=c,c++ --disable-multilib --disable-multiarch
> --enable-checking=runtime --enable-libmudflap --enable-libgomp
> --disable-bootstrap --enable-static --disable-shared
> --disable-decimal-float --with-system-zlib --disable-libitm
> --disable-build-poststage1-with-cxx --disable-build-with-cxx
> --without-cloog --without-ppl --disable-nls --enable-threads
> --enable-__cxa_atexit --with-gmp=/home/bdsatish/foss/installed/gmp
> --with-mpfr=/home/bdsatish/foss/installed/mpfr
> --with-mpc=/home/bdsatish/foss/installed/mpc
> Thread model: posix
> gcc version 4.7.2 (GCC)
I think that he wanted you to run this instead:

$ g++ -v -fmudflap references.cc -lmudflap

It will show command lines for linker and assembler.

>
> Thanks & Regards,
> Satish
>
> On 22 September 2012 04:33, Frank Ch. Eigler <fche@redhat.com> wrote:
>> bd satish <bdsatish@gmail.com> writes:
>>
>>> [...]
>>> The following piece of code, gives "undefined references" to
>>> __real_malloc, __real_free, etc.:
>>> Compiled with:
>>> g++ -fmudflap references.cc -lmudflap
>>>
>>> /lib64/libmudflap.a(mf-runtime.o): In function `__mfu_check':
>>> ../libmudflap/mf-runtime.c:912: undefined reference to `__real_malloc'
>>> [...]
>> According to libmudflap/mf-impl.h, since you're using ordinary
>> archives rather than shared libraries (-fPIC) these __real_FOO
>> functions are expected to be provided by the linker:
>>
>>    (1) The static method involves a list of -wrap=foo flags being passed to
>>    the linker, which then links references to "foo" to the symbol
>>    "__wrap_foo", and links references to "__real_foo" to the symbol "foo".
>>    When compiled without -DPIC, libmudflap.a contains such __wrap_foo
>>    functions which delegate to __real_foo functions in libc to get their
>>    work done.
>>
>> So, something appears wrong with this wrapping mechanism in your case.
>> Can you rerun g++ with -v to see how the linker is invoked?  Perhaps
>> there is something missing for the C++ static-linking case.
>>
>>
>> - FChE

-- 
VZ

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]