diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1a8026c63f2..04e773a196a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-08-30 Jim Wilson + + * 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 PR middle-end/91599 diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index 9b16a1eb9c2..1e7528f1cb9 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -4636,6 +4636,16 @@ riscv_option_override (void) error ("%<-mriscv-attribute%> RISC-V ELF attribute requires GNU as 2.32" " [%<-mriscv-attribute%>]"); #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. */