1 /* Assembly macros for 32-bit PowerPC.
2 Copyright (C) 1999-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <sysdeps/powerpc/sysdep.h>
23 /* If compiled for profiling, call `_mcount' at the start of each
26 /* The mcount code relies on a the return address being on the stack
27 to locate our caller and so it can restore it; so store one just
29 # define CALL_MCOUNT \
33 bl JUMPTARGET(_mcount);
35 # define CALL_MCOUNT /* Do nothing. */
39 .globl C_SYMBOL_NAME(name); \
40 .type C_SYMBOL_NAME(name),@function; \
46 #define ENTRY_TOCLESS(name) ENTRY(name)
48 /* helper macro for accessing the 32-bit powerpc GOT. */
50 #define SETUP_GOT_ACCESS(regname,GOT_LABEL) \
51 bcl 20,31,GOT_LABEL ; \
55 #define EALIGN_W_0 /* No words to insert. */
56 #define EALIGN_W_1 nop
57 #define EALIGN_W_2 nop;nop
58 #define EALIGN_W_3 nop;nop;nop
59 #define EALIGN_W_4 EALIGN_W_3;nop
60 #define EALIGN_W_5 EALIGN_W_4;nop
61 #define EALIGN_W_6 EALIGN_W_5;nop
62 #define EALIGN_W_7 EALIGN_W_6;nop
64 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
65 past a 2^align boundary. */
67 # define EALIGN(name, alignt, words) \
68 .globl C_SYMBOL_NAME(name); \
69 .type C_SYMBOL_NAME(name),@function; \
75 .align ALIGNARG(alignt); \
79 # define EALIGN(name, alignt, words) \
80 .globl C_SYMBOL_NAME(name); \
81 .type C_SYMBOL_NAME(name),@function; \
82 .align ALIGNARG(alignt); \
91 ASM_SIZE_DIRECTIVE(name)
93 #define DO_CALL(syscall) \
102 # define JUMPTARGET(name) name##@plt
104 # define JUMPTARGET(name) name
107 #if defined SHARED && defined PIC && !defined NO_HIDDEN
108 # undef HIDDEN_JUMPTARGET
109 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
112 #define TAIL_CALL_SYSCALL_ERROR \
113 b __syscall_error@local
115 #define PSEUDO(name, syscall_name, args) \
118 DO_CALL (SYS_ify (syscall_name));
125 TAIL_CALL_SYSCALL_ERROR
126 #define ret PSEUDO_RET
129 #define PSEUDO_END(name) \
132 #define PSEUDO_NOERRNO(name, syscall_name, args) \
135 DO_CALL (SYS_ify (syscall_name));
137 #define PSEUDO_RET_NOERRNO \
139 #define ret_NOERRNO PSEUDO_RET_NOERRNO
141 #undef PSEUDO_END_NOERRNO
142 #define PSEUDO_END_NOERRNO(name) \
145 #define PSEUDO_ERRVAL(name, syscall_name, args) \
148 DO_CALL (SYS_ify (syscall_name));
150 #define PSEUDO_RET_ERRVAL \
152 #define ret_ERRVAL PSEUDO_RET_ERRVAL
154 #undef PSEUDO_END_ERRVAL
155 #define PSEUDO_END_ERRVAL(name) \
158 /* Local labels stripped out by the linker. */
162 #define XGLUE(a,b) a##b
163 #define GLUE(a,b) XGLUE (a,b)
164 #define GENERATE_GOT_LABEL(name) GLUE (.got_label, name)
166 /* Label in text section. */
167 #define C_TEXT(name) name
169 /* Read the value of member from rtld_global_ro. */
173 /* Inside ld.so we use the local alias to avoid runtime GOT
175 # define __GLRO(rOUT, rGOT, member, offset) \
176 lwz rOUT,_rtld_local_ro@got(rGOT); \
177 lwz rOUT,offset(rOUT)
179 # define __GLRO(rOUT, rGOT, member, offset) \
180 lwz rOUT,_rtld_global_ro@got(rGOT); \
181 lwz rOUT,offset(rOUT)
184 # define __GLRO(rOUT, rGOT, member, offset) \
185 lwz rOUT,member@got(rGOT); \
189 /* Position-dependent code does not require access to the GOT. */
190 # define __GLRO(rOUT, rGOT, member, offset) \
191 lis rOUT,(member)@ha; \
192 lwz rOUT,(member)@l(rOUT)
195 #endif /* __ASSEMBLER__ */