[LLVMbugs] [Bug 24331] New: Wrong code for saving registers on ARM

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Aug 1 06:39:01 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24331

            Bug ID: 24331
           Summary: Wrong code for saving registers on ARM
           Product: libc++abi
           Version: 3.7
          Hardware: Other
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: manuel.freiberger at gmx.at
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

Hello,

The function unw_getcontext() implemented in the file UnwindRegistersSave.S has
a wrong instruction in line 304:
    stm r0!, {r0-r7}
As a write-back on R0 is used here, the offsets for the instructions in line
307-309 are wrong. The code should be changed to
    stm r0, {r0-r7}
i.e. register R0 should not be modified, similar to the code in the lines
314--317. 

I have tested this on a Cortex-M4. Before making the modification, backtraces 
with libunwind were not working because the PC register was always zero when
unw_step() was called. After the modification everything was fine.

/Manuel

--- UnwindRegistersSave.S       2015-08-01 15:35:38.847465964 +0200
+++ UnwindRegistersSave.S_modified      2015-08-01 15:35:57.105379894 +0200
@@ -301,7 +301,7 @@
   .p2align 2
 DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
 #if !defined(__ARM_ARCH_ISA_ARM)
-  stm r0!, {r0-r7}
+  stm r0, {r0-r7}
   mov r2, sp
   mov r3, lr
   str r2, [r0, #52]

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150801/e72f87f5/attachment.html>


More information about the llvm-bugs mailing list