This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/51643] Incorrect code produced for tail-call of weak function with -O2/-O3 option
- From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 22 Dec 2011 23:27:29 +0000
- Subject: [Bug target/51643] Incorrect code produced for tail-call of weak function with -O2/-O3 option
- Auto-submitted: auto-generated
- References: <bug-51643-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51643
--- Comment #14 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2011-12-22 23:27:29 UTC ---
Because the ABI says it only works for bare metal.
On a system with shared libraries, you can't tell at static link time if a weak
symbol will be resolved by a shared library, so it has to left up to the
dynamic linker which will fill in a PLT stub. Once you have those, it's pretty
hard to make the call become a stub (and even if it were, it wouldn't be a NOP
(the linker would have to turn the call into something that simply returned as
the PLT sequence can't be patched). Tail-calling PLT sequences is perfectly
safe, so there's no reason not to perform the optimization.