Re: Why do my application binaries always contain the _mcount symbol?

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

 



Joseph Garvin <joseph.h.garvin@xxxxxxxxx> writes:

> On Solaris 10, with GCC 4.2 and GCC 4.4, any application I compile
> *always* has the _mcount symbol, which if I understand correctly
> should only be present if my application is being built with
> profiling. I've verified that I don't see this behavior on Linux, only
> on Solaris, and I've double checked that gcc/g++ aren't aliased in my
> shell. I am also linking no libraries explicitly. If I run ldd on the
> resulting executable, and then run nm on all of the listed shared
> libraries (libc and such) none of them contain the symbol _mcount,
> although one does contain the symbol _mcount_newent.
>
> Any idea why this would be happening? I have a post-build script that
> verifies that _mcount is not present when the profile setting is off,
> to ensure that my build system is working correctly. I could remove
> it, but I don't want to do so unless this symbol is really supposed to
> be present.

On Solaris gcc provides its own copy of crt1.o.  The copy it provides
has a weak definition of _mcount.  The comment in the file
(gcc/config/i386/sol2-c1.asm) says

! A dummy profiling support routine for non-profiling executables,
! in case we link in some objects that have been compiled for profiling.

	.weak	_mcount
_mcount:

However, that may not fully account for what you are seeing, since
that should be a weak definition and you reported a strong one.  One
thing you can do is run gcc -v to get the list of startup files
automatically included when gcc invokes the linker.  Check each of
those files to see if any of them define _mcount.

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