1/* libunwind - a platform-independent unwind library 2 Copyright (C) 2008 CodeSourcery 3 4This file is part of libunwind. 5 6Permission is hereby granted, free of charge, to any person obtaining 7a copy of this software and associated documentation files (the 8"Software"), to deal in the Software without restriction, including 9without limitation the rights to use, copy, modify, merge, publish, 10distribute, sublicense, and/or sell copies of the Software, and to 11permit persons to whom the Software is furnished to do so, subject to 12the following conditions: 13 14The above copyright notice and this permission notice shall be 15included in all copies or substantial portions of the Software. 16 17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 24 25#include "offsets.h" 26 27 .text 28 .arm 29 30 .global _Uarm_getcontext 31 .type _Uarm_getcontext, %function 32 @ This is a stub version of getcontext() for ARM which only stores core 33 @ registers. It must be called in a special way, not as a regular 34 @ function -- see also the libunwind-arm.h:unw_tdep_getcontext macro. 35_Uarm_getcontext: 36 stmfd sp!, {r0, r1} 37 @ store r0 38 str r0, [r0, #LINUX_UC_MCONTEXT_OFF + LINUX_SC_R0_OFF] 39 add r0, r0, #LINUX_UC_MCONTEXT_OFF + LINUX_SC_R0_OFF 40 @ store r1 to r12 41 stmib r0, {r1-r12} 42 @ reconstruct r13 at call site, then store 43 add r1, sp, #12 44 str r1, [r0, #13 * 4] 45 @ retrieve r14 from call site, then store 46 ldr r1, [sp, #8] 47 str r1, [r0, #14 * 4] 48 @ point lr to instruction after call site's stack adjustment 49 add r1, lr, #4 50 str r1, [r0, #15 * 4] 51 ldmfd sp!, {r0, r1} 52 bx lr 53#ifdef __linux__ 54 /* We do not need executable stack. */ 55 .section .note.GNU-stack,"",%progbits 56#endif 57