1*199767f8SToomas Soome /*- 2*199767f8SToomas Soome * Copyright (c) 1990 The Regents of the University of California. 3*199767f8SToomas Soome * All rights reserved. 4*199767f8SToomas Soome * 5*199767f8SToomas Soome * This code is derived from software contributed to Berkeley by 6*199767f8SToomas Soome * William Jolitz. 7*199767f8SToomas Soome * 8*199767f8SToomas Soome * Redistribution and use in source and binary forms, with or without 9*199767f8SToomas Soome * modification, are permitted provided that the following conditions 10*199767f8SToomas Soome * are met: 11*199767f8SToomas Soome * 1. Redistributions of source code must retain the above copyright 12*199767f8SToomas Soome * notice, this list of conditions and the following disclaimer. 13*199767f8SToomas Soome * 2. Redistributions in binary form must reproduce the above copyright 14*199767f8SToomas Soome * notice, this list of conditions and the following disclaimer in the 15*199767f8SToomas Soome * documentation and/or other materials provided with the distribution. 16*199767f8SToomas Soome * 4. Neither the name of the University nor the names of its contributors 17*199767f8SToomas Soome * may be used to endorse or promote products derived from this software 18*199767f8SToomas Soome * without specific prior written permission. 19*199767f8SToomas Soome * 20*199767f8SToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21*199767f8SToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22*199767f8SToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23*199767f8SToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24*199767f8SToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25*199767f8SToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26*199767f8SToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27*199767f8SToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28*199767f8SToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29*199767f8SToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30*199767f8SToomas Soome * SUCH DAMAGE. 31*199767f8SToomas Soome * 32*199767f8SToomas Soome * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 33*199767f8SToomas Soome * $FreeBSD$ 34*199767f8SToomas Soome */ 35*199767f8SToomas Soome 36*199767f8SToomas Soome #ifndef _MACHINE_ASM_H_ 37*199767f8SToomas Soome #define _MACHINE_ASM_H_ 38*199767f8SToomas Soome 39*199767f8SToomas Soome #include <sys/cdefs.h> 40*199767f8SToomas Soome 41*199767f8SToomas Soome #ifdef PIC 42*199767f8SToomas Soome #define PIC_PROLOGUE \ 43*199767f8SToomas Soome pushl %ebx; \ 44*199767f8SToomas Soome call 1f; \ 45*199767f8SToomas Soome 1: \ 46*199767f8SToomas Soome popl %ebx; \ 47*199767f8SToomas Soome addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx 48*199767f8SToomas Soome #define PIC_EPILOGUE \ 49*199767f8SToomas Soome popl %ebx 50*199767f8SToomas Soome #define PIC_PLT(x) x@PLT 51*199767f8SToomas Soome #define PIC_GOT(x) x@GOT(%ebx) 52*199767f8SToomas Soome #define PIC_GOTOFF(x) x@GOTOFF(%ebx) 53*199767f8SToomas Soome #else 54*199767f8SToomas Soome #define PIC_PROLOGUE 55*199767f8SToomas Soome #define PIC_EPILOGUE 56*199767f8SToomas Soome #define PIC_PLT(x) x 57*199767f8SToomas Soome #define PIC_GOTOFF(x) x 58*199767f8SToomas Soome #endif 59*199767f8SToomas Soome 60*199767f8SToomas Soome /* 61*199767f8SToomas Soome * CNAME and HIDENAME manage the relationship between symbol names in C 62*199767f8SToomas Soome * and the equivalent assembly language names. CNAME is given a name as 63*199767f8SToomas Soome * it would be used in a C program. It expands to the equivalent assembly 64*199767f8SToomas Soome * language name. HIDENAME is given an assembly-language name, and expands 65*199767f8SToomas Soome * to a possibly-modified form that will be invisible to C programs. 66*199767f8SToomas Soome */ 67*199767f8SToomas Soome #define CNAME(csym) csym 68*199767f8SToomas Soome #define HIDENAME(asmsym) .asmsym 69*199767f8SToomas Soome 70*199767f8SToomas Soome /* XXX should use .p2align 4,0x90 for -m486. */ 71*199767f8SToomas Soome #define _START_ENTRY .text; .p2align 2,0x90 72*199767f8SToomas Soome 73*199767f8SToomas Soome #define _ENTRY(x) _START_ENTRY; \ 74*199767f8SToomas Soome .globl CNAME(x); .type CNAME(x),@function; CNAME(x): 75*199767f8SToomas Soome #define END(x) .size x, . - x 76*199767f8SToomas Soome 77*199767f8SToomas Soome #ifdef PROF 78*199767f8SToomas Soome #define ALTENTRY(x) _ENTRY(x); \ 79*199767f8SToomas Soome pushl %ebp; movl %esp,%ebp; \ 80*199767f8SToomas Soome call PIC_PLT(HIDENAME(mcount)); \ 81*199767f8SToomas Soome popl %ebp; \ 82*199767f8SToomas Soome jmp 9f 83*199767f8SToomas Soome #define ENTRY(x) _ENTRY(x); \ 84*199767f8SToomas Soome pushl %ebp; movl %esp,%ebp; \ 85*199767f8SToomas Soome call PIC_PLT(HIDENAME(mcount)); \ 86*199767f8SToomas Soome popl %ebp; \ 87*199767f8SToomas Soome 9: 88*199767f8SToomas Soome #else 89*199767f8SToomas Soome #define ALTENTRY(x) _ENTRY(x) 90*199767f8SToomas Soome #define ENTRY(x) _ENTRY(x) 91*199767f8SToomas Soome #endif 92*199767f8SToomas Soome 93*199767f8SToomas Soome /* 94*199767f8SToomas Soome * WEAK_REFERENCE(): create a weak reference alias from sym. 95*199767f8SToomas Soome * The macro is not a general asm macro that takes arbitrary names, 96*199767f8SToomas Soome * but one that takes only C names. It does the non-null name 97*199767f8SToomas Soome * translation inside the macro. 98*199767f8SToomas Soome */ 99*199767f8SToomas Soome 100*199767f8SToomas Soome #define WEAK_REFERENCE(sym, alias) \ 101*199767f8SToomas Soome .weak CNAME(alias); \ 102*199767f8SToomas Soome .equ CNAME(alias),CNAME(sym) 103*199767f8SToomas Soome 104*199767f8SToomas Soome /* 105*199767f8SToomas Soome * STRONG_ALIAS: create a strong alias. 106*199767f8SToomas Soome */ 107*199767f8SToomas Soome #define STRONG_ALIAS(alias,sym) \ 108*199767f8SToomas Soome .globl alias; \ 109*199767f8SToomas Soome alias = sym 110*199767f8SToomas Soome 111*199767f8SToomas Soome #define RCSID(x) .text; .asciz x 112*199767f8SToomas Soome 113*199767f8SToomas Soome #undef __FBSDID 114*199767f8SToomas Soome #if !defined(lint) && !defined(STRIP_FBSDID) 115*199767f8SToomas Soome #define __FBSDID(s) .ident s 116*199767f8SToomas Soome #else 117*199767f8SToomas Soome #define __FBSDID(s) /* nothing */ 118*199767f8SToomas Soome #endif /* not lint and not STRIP_FBSDID */ 119*199767f8SToomas Soome 120*199767f8SToomas Soome #endif /* !_MACHINE_ASM_H_ */ 121