1 /* $NetBSD: asm.h,v 1.25 2006/01/20 22:02:40 christos Exp $ */
4 * Copyright (c) 1990 The Regents of the University of California.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)asm.h 5.5 (Berkeley) 5/7/91
41 * The old NetBSD/sh3 ELF toolchain used underscores. The new
42 * NetBSD/sh3 ELF toolchain does not. The C pre-processor
43 * defines __NO_LEADING_UNDERSCORES__ for the new ELF toolchain.
46 #if defined(__ELF__) && defined(__NO_LEADING_UNDERSCORES__)
47 # define _C_LABEL(x) x
50 # define _C_LABEL(x) _ ## x
52 # define _C_LABEL(x) _/**/x
55 #define _ASM_LABEL(x) x
57 /* let kernels and others override entrypoint alignment */
59 # define _ALIGN_TEXT .align 2
78 #define _PROF_PROLOGUE \
87 #define _PROF_PROLOGUE
90 #define ENTRY(y) _ENTRY(_C_LABEL(y)) _PROF_PROLOGUE
91 #define NENTRY(y) _ENTRY(_C_LABEL(y))
92 #define ASENTRY(y) _ENTRY(_ASM_LABEL(y)) _PROF_PROLOGUE
94 #define SET_ENTRY_SIZE(y) \
95 .size _C_LABEL(y), . - _C_LABEL(y)
97 #define SET_ASENTRY_SIZE(y) \
98 .size _ASM_LABEL(y), . - _ASM_LABEL(y)
101 #define ALTENTRY(name) \
102 .globl _C_LABEL(name) ;\
103 .type _C_LABEL(name),@function ;\
106 #define ALTENTRY(name) \
107 .globl _C_LABEL(name) ;\
113 * Hide the gory details of PIC calls vs. normal calls. Use as in the
117 * PIC_PROLOGUE(.L_got, r0) ! saves old r12 on stack
119 * mov.l .L_function_1, r0
120 * 1: CALL r0 ! each call site needs a label
123 * mov.l .L_function_2, r0
127 * PIC_EPILOGUE ! restores r12 from stack
128 * lds.l @sp+, pr ! so call in right order
135 * .L_function_1: ! if you call the same function twice
136 * CALL_DATUM(function, 1b) ! provide call datum for each call
138 * CALL_DATUM(function, 2b)
143 #define PIC_PLT(x) x@PLT
144 #define PIC_GOT(x) x@GOT
145 #define PIC_GOTOFF(x) x@GOTOFF
147 #define PIC_PROLOGUE(got) \
149 PIC_PROLOGUE_NOSAVE(got)
152 * Functions that do non local jumps don't need to preserve r12,
153 * so we can shave off two instructions to save/restore it.
155 #define PIC_PROLOGUE_NOSAVE(got) \
160 #define PIC_EPILOGUE \
163 #define PIC_EPILOGUE_SLOT \
166 #define PIC_GOT_DATUM \
167 .long _GLOBAL_OFFSET_TABLE_
172 #define CALL_DATUM(function, lpcs) \
173 .long PIC_PLT(function) - ((lpcs) + 4 - (.))
176 * This will result in text relocations in the shared library,
177 * unless the function is local or has hidden or protected visibility.
178 * Does not require PIC prologue.
180 #define CALL_DATUM_LOCAL(function, lpcs) \
181 .long function - ((lpcs) + 4)
185 #define PIC_PROLOGUE(label)
186 #define PIC_PROLOGUE_NOSAVE(label)
188 #define PIC_EPILOGUE_SLOT nop
189 #define PIC_GOT_DATUM
194 #define CALL_DATUM(function, lpcs) \
197 #define CALL_DATUM_LOCAL(function, lpcs) \
203 #define ASMSTR .asciz
206 #define RCSID(x) .pushsection ".ident"; .asciz x; .popsection
208 #define RCSID(x) .text; .asciz x
211 #ifdef NO_KERNEL_RCSIDS
212 #define __KERNEL_RCSID(_n, _s) /* nothing */
214 #define __KERNEL_RCSID(_n, _s) RCSID(_s)
218 #define WEAK_ALIAS(alias,sym) \
219 .weak _C_LABEL(alias); \
220 _C_LABEL(alias) = _C_LABEL(sym)
224 * STRONG_ALIAS: create a strong alias.
226 #define STRONG_ALIAS(alias,sym) \
227 .globl _C_LABEL(alias); \
228 _C_LABEL(alias) = _C_LABEL(sym)
230 #define WARN_REFERENCES(_sym,_msg) \
231 .section .gnu.warning._sym; .ascii _msg; .previous
233 #endif /* !_SH3_ASM_H_ */