This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/57260] Generated R_MIPS_GOT_MIPS relocation for direct function call while compiling with -O2 on MIPS N64
- From: "rsandifo at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 14 May 2013 18:22:35 +0000
- Subject: [Bug target/57260] Generated R_MIPS_GOT_MIPS relocation for direct function call while compiling with -O2 on MIPS N64
- Auto-submitted: auto-generated
- References: <bug-57260-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57260
rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2013-05-14
CC| |rsandifo at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |rsandifo at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #10 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Confirmed.
As discusseded on the binutils list, this is definitely a bug IMO.
It's a QoI requirement that we use lazy binding for direct calls.
I don't think I'd realised quite how important that is when
I implemented sibling calls for PIC way back when.
As for why GCC is using %got_disp for sibling calls: the problem
is that lazy-binding stubs require $gp to be valid on entry.
And $gp is call-saved on n32 and n64, so functions must restore
the _caller's_ value of $gp before returning from a function.
This means that $gp might hold the wrong value on entry to a
sibcalled stub.
I think the fix is simply to disable direct sibling calls for
n32 and n64 non-PLT abicalls. (o32 is OK, because $gp is call-clobbered
there.) It's unfortunate that we lose optimisation for a once-per-run
thing, but I don't think there's any alternative.