public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/google/grte/v5-2.27/master] Add workaround for infinite looping in ppc vsyscalls
@ 2021-08-28 0:39 Fangrui Song
0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2021-08-28 0:39 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b2d69ea7ac4b918e5325bf477bf06a3ad6685f4d
commit b2d69ea7ac4b918e5325bf477bf06a3ad6685f4d
Author: Stan Shebs <stanshebs@google.com>
Date: Tue Sep 25 10:52:37 2018 -0700
Add workaround for infinite looping in ppc vsyscalls
Diff:
---
sysdeps/posix/clock_getres.c | 17 +++++++++++++++++
sysdeps/unix/clock_gettime.c | 17 +++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c
index 8bc7e813e6..3f6fdcf9aa 100644
--- a/sysdeps/posix/clock_getres.c
+++ b/sysdeps/posix/clock_getres.c
@@ -73,6 +73,19 @@ realtime_getres (struct timespec *res)
return -1;
}
+#if defined __clang__ && defined __powerpc64__
+/* On ppc, __clock_getres's body eventually expands into asm code
+ that does a bctrl, but clang does not recognize the need to save
+ the link register, so calls loop infinitely instead of returning.
+ As workaround, make a dummy function call that forces a link
+ register save. */
+volatile int clock_getres_dummy_glob;
+
+void __attribute__((noinline)) clock_getres_dummy ()
+{
+ clock_getres_dummy_glob = 45;
+}
+#endif
/* Get resolution of clock. */
int
@@ -80,6 +93,10 @@ __clock_getres (clockid_t clock_id, struct timespec *res)
{
int retval = -1;
+#if defined __clang__ && defined __powerpc64__
+ clock_getres_dummy ();
+#endif
+
switch (clock_id)
{
#ifdef SYSDEP_GETRES
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
index 96df78ab1e..7ef43307b5 100644
--- a/sysdeps/unix/clock_gettime.c
+++ b/sysdeps/unix/clock_gettime.c
@@ -86,6 +86,19 @@ realtime_gettime (struct timespec *tp)
return retval;
}
+#if defined __clang__ && defined __powerpc64__
+/* On ppc, __clock_gettime's body eventually expands into asm code
+ that does a bctrl, but clang does not recognize the need to save
+ the link register, so calls loop infinitely instead of returning.
+ As workaround, make a dummy function call that forces a link
+ register save. */
+volatile int clock_gettime_dummy_glob;
+
+void __attribute__((noinline)) clock_gettime_dummy ()
+{
+ clock_gettime_dummy_glob = 45;
+}
+#endif
/* Get current value of CLOCK and store it in TP. */
int
@@ -93,6 +106,10 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp)
{
int retval = -1;
+#if defined __clang__ && defined __powerpc64__
+ clock_gettime_dummy ();
+#endif
+
switch (clock_id)
{
#ifdef SYSDEP_GETTIME
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-28 0:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-28 0:39 [glibc/google/grte/v5-2.27/master] Add workaround for infinite looping in ppc vsyscalls Fangrui Song
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).