1 /* Copyright (C) 1997-2017 Free Software Foundation, Inc.
2 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #ifndef _LINUX_SPARC64_SYSDEP_H
19 #define _LINUX_SPARC64_SYSDEP_H 1
21 #include <common/sysdep.h>
24 #define SYS_ify(syscall_name) __NR_##syscall_name
28 #define SPARC_PIC_THUNK(reg) \
29 .ifndef __sparc_get_pc_thunk.reg; \
30 .section .text.__sparc_get_pc_thunk.reg,"axG",@progbits,__sparc_get_pc_thunk.reg,comdat; \
32 .weak __sparc_get_pc_thunk.reg; \
33 .hidden __sparc_get_pc_thunk.reg; \
34 .type __sparc_get_pc_thunk.reg, #function; \
35 __sparc_get_pc_thunk.reg: \
37 add %o7, %reg, %##reg; \
41 /* The "-4" and "+4" offsets against _GLOBAL_OFFSET_TABLE_ are
42 critical since they represent the offset from the thunk call to the
43 instruction containing the _GLOBAL_OFFSET_TABLE_ reference.
44 Therefore these instructions cannot be moved around without
45 appropriate adjustments to those offsets.
47 Furthermore, these expressions are special in another regard. When
48 the assembler sees a reference to _GLOBAL_OFFSET_TABLE_ inside of
49 a %hi() or %lo(), it emits a PC-relative relocation. This causes
50 R_SPARC_HI22 to turn into R_SPARC_PC22, and R_SPARC_LO10 to turn into
51 R_SPARC_PC10, respectively.
53 Even when v9 we use a call sequence instead of using "rd %pc" because
54 RDPC is extremely expensive and incurs a full pipeline flush. */
56 #define SPARC_PIC_THUNK_CALL(reg) \
57 sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %##reg; \
58 call __sparc_get_pc_thunk.reg; \
59 or %##reg, %lo(_GLOBAL_OFFSET_TABLE_+4), %##reg;
61 #define SETUP_PIC_REG(reg) \
62 SPARC_PIC_THUNK(reg) \
63 SPARC_PIC_THUNK_CALL(reg)
65 #define SETUP_PIC_REG_LEAF(reg, tmp) \
66 SPARC_PIC_THUNK(reg) \
68 SPARC_PIC_THUNK_CALL(reg); \
72 #define LOADSYSCALL(x) mov __NR_##x, %g1
76 .global C_SYMBOL_NAME(name); \
77 .type name, @function; \
86 #define ENTRY_NOCFI(name) \
88 .global C_SYMBOL_NAME(name); \
89 .type name, @function; \
92 #define END_NOCFI(name) \
95 #define LOC(name) .L##name
98 #define PSEUDO(name, syscall_name, args) \
101 LOADSYSCALL(syscall_name); \
105 SYSCALL_ERROR_HANDLER \
108 #undef PSEUDO_NOERRNO
109 #define PSEUDO_NOERRNO(name, syscall_name, args)\
112 LOADSYSCALL(syscall_name); \
116 #define PSEUDO_ERRVAL(name, syscall_name, args) \
119 LOADSYSCALL(syscall_name); \
123 #define PSEUDO_END(name) \
127 # define SYSCALL_ERROR_HANDLER \
129 call __syscall_error; \
132 # define SYSCALL_ERROR_HANDLER \
133 0: SETUP_PIC_REG_LEAF(o2,g1) \
134 sethi %gdop_hix22(errno), %g1;\
135 xor %g1, %gdop_lox10(errno), %g1;\
136 ldx [%o2 + %g1], %g1, %gdop(errno);\
142 #endif /* __ASSEMBLER__ */
144 /* This is the offset from the %sp to the backing store above the
145 register windows. So if you poke stack memory directly you add this. */
146 #define STACK_BIAS 2047