Commit a169f358 by Jim Wilson Committed by Jim Wilson

RISC-V: Disable -msave-restore for shared libraries.

This was noticed while trying to test -msave-restore support.  The
save/restore routines use the alternate return register t0/x5 which is
clobbered by the PLT header, so we can't use them in shared libraries.
This patch disables -msave-restore when -fpic (and -mplt), and emits a
warning if the user explicitly turned on -msave-restore.

	gcc/
	* config/riscv/riscv.c (riscv_option_override): If -msave-restore
	and -fpic and -mplt then disable -msave-restore and warn.

From-SVN: r275231
parent 4a140826
2019-08-30 Jim Wilson <jimw@sifive.com>
* config/riscv/riscv.c (riscv_option_override): If -msave-restore
and -fpic and -mplt then disable -msave-restore and warn.
2019-08-30 Martin Sebor <msebor@redhat.com> 2019-08-30 Martin Sebor <msebor@redhat.com>
PR middle-end/91599 PR middle-end/91599
......
...@@ -4636,6 +4636,16 @@ riscv_option_override (void) ...@@ -4636,6 +4636,16 @@ riscv_option_override (void)
error ("%<-mriscv-attribute%> RISC-V ELF attribute requires GNU as 2.32" error ("%<-mriscv-attribute%> RISC-V ELF attribute requires GNU as 2.32"
" [%<-mriscv-attribute%>]"); " [%<-mriscv-attribute%>]");
#endif #endif
/* The save-restore routines use t0 which is clobbered by the plt header,
so we can't use them when building shared libraries. */
if (TARGET_SAVE_RESTORE && flag_pic && TARGET_PLT)
{
target_flags &= ~MASK_SAVE_RESTORE;
if (target_flags_explicit & MASK_SAVE_RESTORE)
warning (0, "%<-msave-restore%> disabled; not supported with PLT "
"based shared libraries");
}
} }
/* Implement TARGET_CONDITIONAL_REGISTER_USAGE. */ /* Implement TARGET_CONDITIONAL_REGISTER_USAGE. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment