aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorStan Shebs <stanshebs@google.com>2018-09-25 07:20:18 -0700
committerFangrui Song <i@maskray.me>2021-08-27 17:23:12 -0700
commit9b6c937b0041de8b65a6f11db9c5a05efd3fd7c6 (patch)
treeaa7d170eb801cd26cca0b6dcdbb0566f7c7a9472 /elf
parentf9bd60b7c0da8e9ad74ac5e20f0c7cb5cf690183 (diff)
downloadglibc-9b6c937b0041de8b65a6f11db9c5a05efd3fd7c6.zip
glibc-9b6c937b0041de8b65a6f11db9c5a05efd3fd7c6.tar.gz
glibc-9b6c937b0041de8b65a6f11db9c5a05efd3fd7c6.tar.bz2
Add workaround for segfaults in __longjmp when compiled with ppc clang
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-error-skeleton.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/elf/dl-error-skeleton.c b/elf/dl-error-skeleton.c
index d5f418a..01870c5 100644
--- a/elf/dl-error-skeleton.c
+++ b/elf/dl-error-skeleton.c
@@ -85,6 +85,21 @@ fatal_error (int errcode, const char *objname, const char *occasion,
: ""));
}
+/* Due to a complicated set of interactions with different symbol
+ versions, presumably including a VMX-specific __vmx__longjmp, PPC
+ clang ends calling __longjump with ld.so through the global entry
+ point (+0x0) instead of via the local entry point (+0x8) which
+ results in ld.so exceptions crashing because the TOC is not set up.
+ The hack here simply calls the function through a pointer, which
+ guarantees that the global entry point has the TOC set up. (This
+ may or may not be a clang bug, the symbol aliasing is tricky and
+ literally affects only __longjmp out of all the symbols in
+ libc.) */
+#if defined __clang__ && defined __powerpc64__
+volatile void (*longjmpptr) (struct __jmp_buf_tag __env[1], int __val)
+__attribute__ ((__nothrow__)) __attribute__ ((__noreturn__)) = __longjmp;
+#endif
+
void
_dl_signal_exception (int errcode, struct dl_exception *exception,
const char *occasion)
@@ -96,7 +111,11 @@ _dl_signal_exception (int errcode, struct dl_exception *exception,
*lcatch->errcode = errcode;
/* We do not restore the signal mask because none was saved. */
+#if defined __clang__ && defined __powerpc64__
+ (*longjmpptr) (lcatch->env[0].__jmpbuf, 1);
+#else
__longjmp (lcatch->env[0].__jmpbuf, 1);
+#endif
}
else
fatal_error (errcode, exception->objname, occasion, exception->errstring);
@@ -118,7 +137,11 @@ _dl_signal_error (int errcode, const char *objname, const char *occation,
*lcatch->errcode = errcode;
/* We do not restore the signal mask because none was saved. */
+#if defined __clang__ && defined __powerpc64__
+ (*longjmpptr) (lcatch->env[0].__jmpbuf, 1);
+#else
__longjmp (lcatch->env[0].__jmpbuf, 1);
+#endif
}
else
fatal_error (errcode, objname, occation, errstring);