Fix unw_getcontext() return value on AArch64.
authorLogan Chien <tzuhsiang.chien@gmail.com>
Thu, 25 Jun 2015 15:12:46 +0000 (15:12 +0000)
committerLogan Chien <tzuhsiang.chien@gmail.com>
Thu, 25 Jun 2015 15:12:46 +0000 (15:12 +0000)
unw_getcontext() should return UNW_ESUCCESS on success.  Therefore, the
assembly for AArch64 is incorrect because "ldr x0, #0" is a PC-relative
load instead of an immediate value load.

llvm-svn: 240648

libunwind/src/UnwindRegistersSave.S
libunwind/test/unw_getcontext.pass.cpp [new file with mode: 0644]

index 3d457216d6f786b5080080307070796dce28ea81..d26908c76484290787eeeb4473cfd7c898333c13 100644 (file)
@@ -277,7 +277,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
   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__)
diff --git a/libunwind/test/unw_getcontext.pass.cpp b/libunwind/test/unw_getcontext.pass.cpp
new file mode 100644 (file)
index 0000000..b012706
--- /dev/null
@@ -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);
+}