diff options
author | Jim Wilson <jimw@sifive.com> | 2019-08-30 23:32:52 +0000 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 2019-08-30 16:32:52 -0700 |
commit | a169f35890152e8a31ef9bdc0d28a2e0a62e866e (patch) | |
tree | 65cc8352d4cfbbf79ce8d3e14f69b6f8196876f7 /gcc | |
parent | 4a140826453da37a134d792e0224f4e37343e68a (diff) | |
download | gcc-a169f35890152e8a31ef9bdc0d28a2e0a62e866e.zip gcc-a169f35890152e8a31ef9bdc0d28a2e0a62e866e.tar.gz gcc-a169f35890152e8a31ef9bdc0d28a2e0a62e866e.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/config/riscv/riscv.c | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1a8026c..04e773a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +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> PR middle-end/91599 diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index 9b16a1e..1e7528f 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. */ |