RS6000_MCOUNT and -fpic
gp@qnx.com
gp@qnx.com
Thu Feb 19 21:45:00 GMT 2004
Hey, all.
Not sure of this 'fix', so I want to run it by you. Basically, with gcc-
3.3.1 and binutils 2.12.1, the rs6000 output_function_profiler() in rs6000.c
always emits "bl RS6000_MCOUNT" for profiling, which turns out to be "bl
_mcount".
In pic code (like a shared object), when I compile it with "-p", the "bl
_mcount" gets turned into "bl <address of this bl instruction>", so I loop
infinitely on a self-referencing branch and link. If I change that to a "bl
_mcount@plt" then all is good.
What I did was change the following line from output_function_profiler() in
rs6000.c:
fprintf("\tbl %s",RS6000_MCOUNT);
to:
if (flag_pic && DEFAULT_ABI == ABI_V4)
fprintf("\tbl %s@plt",RS6000_MCOUNT);
else
fprintf("\tbl %s",RS6000_MCOUNT);
- Does that look reasonable? In my case, the _mcount symbol is being pulled
in from our pic libcS.a.
- Why would I end up with a self-referencing "bl" instruction without the
"@plt"? Any idea? I think I've seen it before, so even though it looks
like a bug, it might be a feature (I guess...) :-)
Thanks.
GP
More information about the Gcc
mailing list