[PATCH] libunwind: Fix unw_getcontext() return value on AArch64.

Logan Chien tzuhsiang.chien at gmail.com
Wed Jun 24 17:29:33 PDT 2015


Hi kledzik, rengolin,

unw_getcontext() should return UNW_ESUCCESS on success.  However, the assembly
for AArch64 is incorrect since "ldr x0, #0" is a PC-relative load instead of an
immediate value load.

This patch should fix the problem by changing ldr to mov.

http://reviews.llvm.org/D10720

Files:
  src/UnwindRegistersSave.S
  test/unw_getcontext.pass.cpp

Index: src/UnwindRegistersSave.S
===================================================================
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -277,7 +277,7 @@
   stp    d28,d29, [x0, #0x1F0]
   str    d30,     [x0, #0x200]
   str    d31,     [x0, #0x208]
-  ldr    x0, #0                   // return UNW_ESUCCESS
+  mov    x0, #0                   // return UNW_ESUCCESS
   ret
 
 #elif defined(__arm__) && !defined(__APPLE__)
Index: test/unw_getcontext.pass.cpp
===================================================================
--- /dev/null
+++ test/unw_getcontext.pass.cpp
@@ -0,0 +1,8 @@
+#include <assert.h>
+#include <libunwind.h>
+
+int main() {
+  unw_context_t context;
+  int ret = unw_getcontext(&context);
+  assert(ret == UNW_ESUCCESS);
+}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10720.28429.patch
Type: text/x-patch
Size: 777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150625/0a1454c1/attachment.bin>


More information about the cfe-commits mailing list