From: Stan Shebs Date: Fri, 24 Jan 2020 16:17:38 +0000 (-0800) Subject: Add workaround for infinite looping in ppc vsyscall for sched_getcpu. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=144448d56646f119c227f171473372855dd17e95;p=thirdparty%2Fglibc.git Add workaround for infinite looping in ppc vsyscall for sched_getcpu. --- diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c index b69eeda15c6..2279026bec4 100644 --- a/sysdeps/unix/sysv/linux/sched_getcpu.c +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c @@ -24,11 +24,28 @@ #endif #include +#if defined __clang__ && defined __powerpc64__ +/* On ppc, sched_getcpu'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 sched_getcpu_dummy_glob; + +void __attribute__((noinline)) sched_getcpu_dummy () +{ + sched_getcpu_dummy_glob = 45; +} +#endif + int sched_getcpu (void) { #ifdef __NR_getcpu unsigned int cpu; +#if defined __clang__ && defined __powerpc64__ + sched_getcpu_dummy (); +#endif int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL); return r == -1 ? r : cpu;