about summary refs log tree commit diff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
authorStan Shebs <stanshebs@google.com>2019-03-25 14:03:24 -0700
committerFangrui Song <i@maskray.me>2021-08-27 17:26:00 -0700
commit895947a3cadfcffe12f108738f42855aff7a32b8 (patch)
tree80b8980599bb24bb3e4303233356f50cc899d617 /sysdeps/unix/sysv
parentb930ad424b81a11296a87ff068ef92dfb6118901 (diff)
downloadglibc-895947a3cadfcffe12f108738f42855aff7a32b8.tar.gz
glibc-895947a3cadfcffe12f108738f42855aff7a32b8.tar.xz
glibc-895947a3cadfcffe12f108738f42855aff7a32b8.zip
Also work around clang bctrl issue in get_clockfreq.c
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
index 3a2216021b..8821218ece 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
@@ -25,11 +25,29 @@
 #include <libc-vdso.h>
 #include <not-cancel.h>
 
+#if defined __clang__ && defined __powerpc64__
+/* On ppc, __get_clockfreq'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 get_clockfreq_dummy_glob;
+
+void __attribute__((noinline)) get_clockfreq_dummy ()
+{
+  get_clockfreq_dummy_glob = 45;
+}
+#endif
+
 hp_timing_t
 __get_clockfreq (void)
 {
   hp_timing_t result = 0L;
 
+#if defined __clang__ && defined __powerpc64__
+  get_clockfreq_dummy ();
+#endif
+
 #ifdef SHARED
   /* The vDSO does not return an error (it clear cr0.so on returning).  */
   INTERNAL_SYSCALL_DECL (err);