[libunwind] [libunwind][AIX] Fix up TOC register if unw_getcontext is called from a different module (PR #66549)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 18 06:17:59 PDT 2023
================
@@ -305,9 +305,22 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
mflr 0
std 0, PPC64_OFFS_SRR0(3) // store lr as ssr0
PPC64_STR(1)
+ PPC64_STR(4) // Save r4 first since it will be used for fixing r2.
+#if defined(_AIX)
+ // The TOC register (r2) was changed by the glue code if unw_getcontext
+ // is called from a different module. Save the original TOC register
+ // in the context if this is the case.
+ mflr 4
+ lwz 4, 0(4) // Get the first instruction at the return address.
+ lis 0, 0xe841 // Is it reloading the TOC register "ld 2,40(1)"?
----------------
xingxue-ibm wrote:
It does not work if the 32-bit comparison technique is used for 64-bit, and vice versa.
https://github.com/llvm/llvm-project/pull/66549
More information about the cfe-commits
mailing list