Home | History | Annotate | Download | only in arm
      1 /* libunwind - a platform-independent unwind library
      2    Copyright (C) 2008 CodeSourcery
      3 
      4 This file is part of libunwind.
      5 
      6 Permission is hereby granted, free of charge, to any person obtaining
      7 a copy of this software and associated documentation files (the
      8 "Software"), to deal in the Software without restriction, including
      9 without limitation the rights to use, copy, modify, merge, publish,
     10 distribute, sublicense, and/or sell copies of the Software, and to
     11 permit persons to whom the Software is furnished to do so, subject to
     12 the following conditions:
     13 
     14 The above copyright notice and this permission notice shall be
     15 included in all copies or substantial portions of the Software.
     16 
     17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     21 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     22 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     23 WITH 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