Libraries do not always contain the _mcount character, but applications (you can check this with gobjdump or nm utility). I read that _mcount is used to implement profiling, but the symbol is present even when profiling is disabled and optimization is enabled (-O2). Does it provide other additional goals?
Update: I'm on Solaris, so this is the Solaris linker in conjunction with GCC, I'm not sure if it matters or not. The GCC version is 4.2.2. This happens even if I compile a file containing only int main() { return 0; } code int main() { return 0; } int main() { return 0; } without binding libraries.
Update2: I type:
$ g++ -O2 mytest.cpp $ nm a.out | grep _mcount [65] | 134547444| 1|FUNC |GLOB |0 |11 |_mcount
And g ++ is not imposed on anyone. In addition, I tried compiling with the Sun CC compiler, and it does not have this problem. I also tried updating GCC, the symbol still exists in 4.4.1.
gcc profiling symbols shared-libraries
Joseph Garvin
source share