public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug target/106338] New: RISC-V static-chain register may be clobbered by PLT stubs @ 2022-07-18 8:00 funanzeng at gmail dot com 2022-07-18 8:12 ` [Bug target/106338] " pinskia at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: funanzeng at gmail dot com @ 2022-07-18 8:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106338 Bug ID: 106338 Summary: RISC-V static-chain register may be clobbered by PLT stubs Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: funanzeng at gmail dot com Target Milestone: --- In commit 09cae7507d9e88f2b05cf3a9404bf181e65ccbac, Palmer ported GCC to RISC-V and t2 were chosen as the static chain register. However, when I supporting this feature in LLVM(https://reviews.llvm.org/D129106), jrtc27 pointed out that this issue. In practice, static chain parameters are only used in Go and is always used with closures, where the function pointer is already resolved. As a result, this issue may not be triggered unless a user directly calls a foreign function with a static chain parameter, and thus has not caused any problem. FYI, in a recent change to the RISC-V ABI, STO_RISCV_VARIANT_CC was added to support unknown ABI. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/106338] RISC-V static-chain register may be clobbered by PLT stubs 2022-07-18 8:00 [Bug target/106338] New: RISC-V static-chain register may be clobbered by PLT stubs funanzeng at gmail dot com @ 2022-07-18 8:12 ` pinskia at gcc dot gnu.org 2022-07-18 8:13 ` pinskia at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-07-18 8:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106338 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I don't see how this is an issue static chain is only used for nested functions in gcc and always local functions (except maybe with LTO). ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/106338] RISC-V static-chain register may be clobbered by PLT stubs 2022-07-18 8:00 [Bug target/106338] New: RISC-V static-chain register may be clobbered by PLT stubs funanzeng at gmail dot com 2022-07-18 8:12 ` [Bug target/106338] " pinskia at gcc dot gnu.org @ 2022-07-18 8:13 ` pinskia at gcc dot gnu.org 2022-07-18 8:17 ` schwab@linux-m68k.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-07-18 8:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106338 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- > static chain parameters are only used in Go This is a lie. They are used with both Ada and fortan a lot. Both heavily use nested functions. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/106338] RISC-V static-chain register may be clobbered by PLT stubs 2022-07-18 8:00 [Bug target/106338] New: RISC-V static-chain register may be clobbered by PLT stubs funanzeng at gmail dot com 2022-07-18 8:12 ` [Bug target/106338] " pinskia at gcc dot gnu.org 2022-07-18 8:13 ` pinskia at gcc dot gnu.org @ 2022-07-18 8:17 ` schwab@linux-m68k.org 2022-08-09 19:47 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: schwab@linux-m68k.org @ 2022-07-18 8:17 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106338 --- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> --- I think every port is using a call-clobbered register for the static chain, and it is not part of the ABI. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/106338] RISC-V static-chain register may be clobbered by PLT stubs 2022-07-18 8:00 [Bug target/106338] New: RISC-V static-chain register may be clobbered by PLT stubs funanzeng at gmail dot com ` (2 preceding siblings ...) 2022-07-18 8:17 ` schwab@linux-m68k.org @ 2022-08-09 19:47 ` pinskia at gcc dot gnu.org 2022-08-09 21:11 ` andrew at sifive dot com 2022-08-10 2:58 ` kito at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-08-09 19:47 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106338 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |WONTFIX --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The only reason why aarch64 changed their static chain register was because it was used for TLS on darwin (and IIRC on VXWorks). static chain is not part of the ABI (unless RISCV folks want to do that). And there are no PLTs between the function calls. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/106338] RISC-V static-chain register may be clobbered by PLT stubs 2022-07-18 8:00 [Bug target/106338] New: RISC-V static-chain register may be clobbered by PLT stubs funanzeng at gmail dot com ` (3 preceding siblings ...) 2022-08-09 19:47 ` pinskia at gcc dot gnu.org @ 2022-08-09 21:11 ` andrew at sifive dot com 2022-08-10 2:58 ` kito at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: andrew at sifive dot com @ 2022-08-09 21:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106338 Andrew Waterman <andrew at sifive dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrew at sifive dot com --- Comment #5 from Andrew Waterman <andrew at sifive dot com> --- (I don't want to make the static chain register part of the RISC-V ABI; the status quo seems fine.) ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/106338] RISC-V static-chain register may be clobbered by PLT stubs 2022-07-18 8:00 [Bug target/106338] New: RISC-V static-chain register may be clobbered by PLT stubs funanzeng at gmail dot com ` (4 preceding siblings ...) 2022-08-09 21:11 ` andrew at sifive dot com @ 2022-08-10 2:58 ` kito at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: kito at gcc dot gnu.org @ 2022-08-10 2:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106338 --- Comment #6 from Kito Cheng <kito at gcc dot gnu.org> --- My understanding is static chain is sort of compiler internal implementation, any register could be picked if that is not used for passing argument, so I would also prefer keep that out psABI spec for now. And just record info for myself: x86-64 ABI has document function's static chain pointer in their ABI https://gitlab.com/x86-psABIs/x86-64-ABI/-/blob/master/x86-64-ABI/low-level-sys-info.tex#L701 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-08-10 2:58 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-07-18 8:00 [Bug target/106338] New: RISC-V static-chain register may be clobbered by PLT stubs funanzeng at gmail dot com 2022-07-18 8:12 ` [Bug target/106338] " pinskia at gcc dot gnu.org 2022-07-18 8:13 ` pinskia at gcc dot gnu.org 2022-07-18 8:17 ` schwab@linux-m68k.org 2022-08-09 19:47 ` pinskia at gcc dot gnu.org 2022-08-09 21:11 ` andrew at sifive dot com 2022-08-10 2:58 ` kito at gcc dot gnu.org
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).