* [PATCH] Fix SH/FDPIC bad codegen with ssp enabled
@ 2015-11-13 16:56 Rich Felker
2015-11-14 0:24 ` Kaz Kojima
0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2015-11-13 16:56 UTC (permalink / raw)
To: gcc-patches
The "chk_guard_add" pattern used for loading the GOT slot address for
__stack_chk_guard hard-codes use of r12 as a fixed GOT register and
thus is not suitable for FDPIC, where the saved initial value of r12
from function entry is what we need.
I would actually prefer removing this hack entirely if possible. I
tried non-FDPIC with it disabled and did not experience any problems;
I suspect it was written to work around a bug that no longer exists.
2015-11-13 Rich Felker <dalias@libc.org>
gcc/
* config/sh/sh.md (symGOT_load): Suppress __stack_chk_guard
address loading hack for FDPIC targets.
diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md
index 7a40d0f..45c9995 100644
--- a/gcc/config/sh/sh.md
+++ b/gcc/config/sh/sh.md
@@ -11082,7 +11082,7 @@ (define_expand "symGOT_load"
operands[2] = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode);
operands[3] = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode);
- if (!TARGET_SHMEDIA
+ if (!TARGET_SHMEDIA && !TARGET_FDPIC
&& flag_stack_protect
&& GET_CODE (operands[1]) == CONST
&& GET_CODE (XEXP (operands[1], 0)) == UNSPEC
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix SH/FDPIC bad codegen with ssp enabled
2015-11-13 16:56 [PATCH] Fix SH/FDPIC bad codegen with ssp enabled Rich Felker
@ 2015-11-14 0:24 ` Kaz Kojima
2015-11-15 0:55 ` Rich Felker
0 siblings, 1 reply; 3+ messages in thread
From: Kaz Kojima @ 2015-11-14 0:24 UTC (permalink / raw)
To: dalias; +Cc: gcc-patches
Rich Felker <dalias@libc.org> wrote:
> The "chk_guard_add" pattern used for loading the GOT slot address for
> __stack_chk_guard hard-codes use of r12 as a fixed GOT register and
> thus is not suitable for FDPIC, where the saved initial value of r12
> from function entry is what we need.
The patch is OK. Committed as revision 230366.
> I would actually prefer removing this hack entirely if possible. I
> tried non-FDPIC with it disabled and did not experience any problems;
> I suspect it was written to work around a bug that no longer exists.
Even we don't see the problem without that, it'll be a latent
issue with the old reload, I think. When SH switches to LRA
completely, this should be revisit.
Regards,
kaz
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix SH/FDPIC bad codegen with ssp enabled
2015-11-14 0:24 ` Kaz Kojima
@ 2015-11-15 0:55 ` Rich Felker
0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2015-11-15 0:55 UTC (permalink / raw)
To: Kaz Kojima; +Cc: gcc-patches
On Sat, Nov 14, 2015 at 09:24:32AM +0900, Kaz Kojima wrote:
> Rich Felker <dalias@libc.org> wrote:
> > The "chk_guard_add" pattern used for loading the GOT slot address for
> > __stack_chk_guard hard-codes use of r12 as a fixed GOT register and
> > thus is not suitable for FDPIC, where the saved initial value of r12
> > from function entry is what we need.
>
> The patch is OK. Committed as revision 230366.
Thanks!
> > I would actually prefer removing this hack entirely if possible. I
> > tried non-FDPIC with it disabled and did not experience any problems;
> > I suspect it was written to work around a bug that no longer exists.
>
> Even we don't see the problem without that, it'll be a latent
> issue with the old reload, I think. When SH switches to LRA
> completely, this should be revisit.
I thought about trying a patch to eliminate the use of the hard-coded
PIC register and instead generate a pseudo for the GOT address. Then
some FDPIC and non-FDPIC code could potentially be unified to use this
pseudo, just with different ways of defining it (r12-at-entry vs
PC-relative symbolic load of _GLOBAL_OFFSET_TABLE_). Would this be
acceptable?
I've already done some experiments removing r12 from fixed_regs for
FDPIC and nothing visibly broke; gcc correctly used r12 as a temp in
functions which didn't need the GOT address, and codegen was improved
even in functions which do use it. These results were observed on musl
libc.so.
Rich
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-15 0:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 16:56 [PATCH] Fix SH/FDPIC bad codegen with ssp enabled Rich Felker
2015-11-14 0:24 ` Kaz Kojima
2015-11-15 0:55 ` Rich Felker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).