Add CFI statements to ARM's assembly code.
[glibc.git] / sysdeps / unix / arm / sysdep.S
blobd3ad81b7bdd738cd72d27e5cfbe8dc8408ce850c
1 /* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2002, 2003,
2    2004, 2005, 2009
3    Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
21 #include <sysdep.h>
22 #define _ERRNO_H
23 #include <bits/errno.h>
25 #ifdef IS_IN_rtld
26 # include <dl-sysdep.h>                 /* Defines RTLD_PRIVATE_ERRNO.  */
27 #endif
29 #include <tls.h>
31 #undef syscall_error
32 #ifdef NO_UNDERSCORES
33 __syscall_error:
34 #else
35 syscall_error:
36 #endif
37 #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
38         /* We translate the system's EWOULDBLOCK error into EAGAIN.
39            The GNU C library always defines EWOULDBLOCK==EAGAIN.
40            EWOULDBLOCK_sys is the original number.  */
41         cmp r0, $EWOULDBLOCK_sys /* Is it the old EWOULDBLOCK?  */
42         moveq r0, $EAGAIN       /* Yes; translate it to EAGAIN.  */
43 #endif
45 #if USE___THREAD
46         mov ip, lr
47         cfi_register (lr, ip)
48         mov r1, r0
50         mov r0, #0xffff0fff
51         mov lr, pc
52         sub pc, r0, #31
54         ldr r2, 1f
55 2:      ldr r2, [pc, r2]
56         str r1, [r0, r2]
57         mvn r0, #0
58         RETINSTR (, ip)
60 1:      .word errno(gottpoff) + (. - 2b - 8)
61 #elif RTLD_PRIVATE_ERRNO
62         ldr r1, 1f
63 0:      str r0, [pc, r1]
64         mvn r0, $0
65         DO_RET(r14)
67 1:      .word C_SYMBOL_NAME(rtld_errno) - 0b - 8
68 #elif defined(_LIBC_REENTRANT)
69         str lr, [sp, #-4]!
70         cfi_adjust_cfa_offset (4)
71         cfi_rel_offset (lr, 0)
72         str r0, [sp, #-4]!
73         cfi_adjust_cfa_offset (4)
74         bl PLTJMP(C_SYMBOL_NAME(__errno_location))
75         ldr r1, [sp], #4
76         cfi_adjust_cfa_offset (-4)
77         str r1, [r0]
78         mvn r0, $0
79         ldr pc, [sp], #4        
80 #else
81 #ifndef PIC
82         ldr r1, 1f
83         str r0, [r1]
84         mvn r0, $0
85         DO_RET (r14)
87 1:      .long C_SYMBOL_NAME(errno)
88 #else
89         @ we have to establish our PIC register
90         ldr r2, 1f
91         ldr r1, 2f
92 0:      add r2, pc, r2
93         str r0, [r1, r2]
94         mvn r0, $0
95         DO_RET (r14)
97 1:      .word _GLOBAL_OFFSET_TABLE_ - 0b - 8
98 2:      .word C_SYMBOL_NAME(errno)(GOTOFF)
99 #endif
100 #endif
102 #undef  __syscall_error
103 END (__syscall_error)