2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * $NetBSD: asm.h,v 1.6.18.1 2000/07/25 08:37:14 kleink Exp $
37 #ifndef _MACHINE_ASM_H_
38 #define _MACHINE_ASM_H_
40 #include <sys/cdefs.h>
42 #if defined(PIC) && !defined(__powerpc64__)
43 #define PIC_PROLOGUE XXX
44 #define PIC_EPILOGUE XXX
45 #define PIC_PLT(x) x@plt
47 #define PIC_GOT(x) XXX
48 #else /* not __STDC__ */
49 #define PIC_GOT(x) XXX
58 #define CNAME(csym) csym
59 #define ASMNAME(asmsym) asmsym
61 #define HIDENAME(asmsym) __CONCAT(_,asmsym)
63 #define HIDENAME(asmsym) __CONCAT(.,asmsym)
66 #if !defined(_CALL_ELF) || _CALL_ELF == 1
68 /* ELFv1 kernel uses global dot symbols */
69 #define DOT_LABEL(name) __CONCAT(.,name)
70 #define TYPE_ENTRY(name) .size name,24; \
71 .type DOT_LABEL(name),@function; \
72 .globl DOT_LABEL(name);
73 #define END_SIZE(name) .size DOT_LABEL(name),.-DOT_LABEL(name);
75 /* ELFv1 user code uses local function entry points */
76 #define DOT_LABEL(name) __CONCAT(.L.,name)
77 #define TYPE_ENTRY(name) .type name,@function;
78 #define END_SIZE(name) .size name,.-DOT_LABEL(name);
81 /* ELFv2 doesn't have any of this complication */
82 #define DOT_LABEL(name) name
83 #define TYPE_ENTRY(name) .type name,@function;
84 #define END_SIZE(name) .size name,.-DOT_LABEL(name);
87 #define _GLOBAL(name) \
94 #define TOC_NAME_FOR_REF(name) __CONCAT(.L,name)
95 #define TOC_REF(name) TOC_NAME_FOR_REF(name)@toc
96 #define TOC_ENTRY(name) \
97 .section ".toc","aw"; \
98 TOC_NAME_FOR_REF(name): \
104 #if !defined(_CALL_ELF) || _CALL_ELF == 1
105 #define _ENTRY(name) \
109 .section ".opd","aw"; \
112 .quad DOT_LABEL(name),.TOC.@tocbase,0; \
117 #define _NAKED_ENTRY(name) _ENTRY(name)
119 #define _ENTRY(name) \
123 .type name,@function; \
125 addis %r2, %r12, (.TOC.-name)@ha; \
126 addi %r2, %r2, (.TOC.-name)@l; \
127 .localentry name, .-name;
129 /* "Naked" function entry. No TOC prologue for ELFv2. */
130 #define _NAKED_ENTRY(name) \
134 .type name,@function; \
136 .localentry name, .-name;
141 .byte 0,0,0,0,0,0,0,0; \
144 #define LOAD_ADDR(reg, var) \
145 lis reg, var@highest; \
146 ori reg, reg, var@higher; \
147 rldicr reg, reg, 32, 31; \
148 oris reg, reg, var@h; \
150 #else /* !__powerpc64__ */
151 #define _ENTRY(name) \
155 .type name,@function; \
159 #define _NAKED_ENTRY(name) _ENTRY(name)
161 #define LOAD_ADDR(reg, var) \
164 #endif /* __powerpc64__ */
166 #if defined(PROF) || (defined(_KERNEL) && defined(GPROF))
167 # ifdef __powerpc64__
168 # define _PROF_PROLOGUE mflr 0; \
183 # define _PROF_PROLOGUE mflr 0; stw 0,4(1); bl _mcount
186 # define _PROF_PROLOGUE
189 #define ASENTRY(y) _ENTRY(ASMNAME(y)); _PROF_PROLOGUE
190 #define END(y) _END(CNAME(y))
191 #define ENTRY(y) _ENTRY(CNAME(y)); _PROF_PROLOGUE
192 #define GLOBAL(y) _GLOBAL(CNAME(y))
194 #define ASENTRY_NOPROF(y) _ENTRY(ASMNAME(y))
195 #define ENTRY_NOPROF(y) _ENTRY(CNAME(y))
197 #define ASMSTR .asciz
199 #define RCSID(x) .text; .asciz x
202 #if !defined(lint) && !defined(STRIP_FBSDID)
203 #define __FBSDID(s) .ident s
205 #define __FBSDID(s) /* nothing */
206 #endif /* not lint and not STRIP_FBSDID */
208 #define WEAK_REFERENCE(sym, alias) \
213 #define WARN_REFERENCES(_sym,_msg) \
214 .section .gnu.warning. ## _sym ; .ascii _msg ; .text
216 #define WARN_REFERENCES(_sym,_msg) \
217 .section .gnu.warning./**/_sym ; .ascii _msg ; .text
218 #endif /* __STDC__ */
220 #endif /* !_MACHINE_ASM_H_ */