1644ba7e8SBruce Evans /*- 2644ba7e8SBruce Evans * Copyright (c) 1990 The Regents of the University of California. 3644ba7e8SBruce Evans * All rights reserved. 4644ba7e8SBruce Evans * 5644ba7e8SBruce Evans * This code is derived from software contributed to Berkeley by 6644ba7e8SBruce Evans * William Jolitz. 7644ba7e8SBruce Evans * 8644ba7e8SBruce Evans * Redistribution and use in source and binary forms, with or without 9644ba7e8SBruce Evans * modification, are permitted provided that the following conditions 10644ba7e8SBruce Evans * are met: 11644ba7e8SBruce Evans * 1. Redistributions of source code must retain the above copyright 12644ba7e8SBruce Evans * notice, this list of conditions and the following disclaimer. 13644ba7e8SBruce Evans * 2. Redistributions in binary form must reproduce the above copyright 14644ba7e8SBruce Evans * notice, this list of conditions and the following disclaimer in the 15644ba7e8SBruce Evans * documentation and/or other materials provided with the distribution. 16*fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 17644ba7e8SBruce Evans * may be used to endorse or promote products derived from this software 18644ba7e8SBruce Evans * without specific prior written permission. 19644ba7e8SBruce Evans * 20644ba7e8SBruce Evans * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21644ba7e8SBruce Evans * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22644ba7e8SBruce Evans * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23644ba7e8SBruce Evans * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24644ba7e8SBruce Evans * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25644ba7e8SBruce Evans * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26644ba7e8SBruce Evans * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27644ba7e8SBruce Evans * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28644ba7e8SBruce Evans * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29644ba7e8SBruce Evans * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30644ba7e8SBruce Evans * SUCH DAMAGE. 31644ba7e8SBruce Evans * 32644ba7e8SBruce Evans * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 33c3aac50fSPeter Wemm * $FreeBSD$ 34644ba7e8SBruce Evans */ 35644ba7e8SBruce Evans 36a8626855SBruce Evans #ifndef _MACHINE_ASM_H_ 37a8626855SBruce Evans #define _MACHINE_ASM_H_ 38a8626855SBruce Evans 39644ba7e8SBruce Evans #include <sys/cdefs.h> 40644ba7e8SBruce Evans 41294246bbSEd Maste #ifdef PIC 42644ba7e8SBruce Evans #define PIC_PLT(x) x@PLT 43afa88623SPeter Wemm #define PIC_GOT(x) x@GOTPCREL(%rip) 44644ba7e8SBruce Evans #else 45644ba7e8SBruce Evans #define PIC_PLT(x) x 46644ba7e8SBruce Evans #endif 47644ba7e8SBruce Evans 48644ba7e8SBruce Evans /* 49644ba7e8SBruce Evans * CNAME and HIDENAME manage the relationship between symbol names in C 50644ba7e8SBruce Evans * and the equivalent assembly language names. CNAME is given a name as 51644ba7e8SBruce Evans * it would be used in a C program. It expands to the equivalent assembly 52644ba7e8SBruce Evans * language name. HIDENAME is given an assembly-language name, and expands 53644ba7e8SBruce Evans * to a possibly-modified form that will be invisible to C programs. 54644ba7e8SBruce Evans */ 55644ba7e8SBruce Evans #define CNAME(csym) csym 56193b147cSPeter Wemm #define HIDENAME(asmsym) .asmsym 57644ba7e8SBruce Evans 5816f571bdSAlan Cox #define _START_ENTRY .text; .p2align 4,0x90 59a8626855SBruce Evans 60a8626855SBruce Evans #define _ENTRY(x) _START_ENTRY; \ 61a8626855SBruce Evans .globl CNAME(x); .type CNAME(x),@function; CNAME(x): 62a8626855SBruce Evans 63644ba7e8SBruce Evans #ifdef PROF 64be16a3abSBruce Evans #define ALTENTRY(x) _ENTRY(x); \ 65a5200470SPeter Wemm pushq %rbp; movq %rsp,%rbp; \ 66a8626855SBruce Evans call PIC_PLT(HIDENAME(mcount)); \ 67a5200470SPeter Wemm popq %rbp; \ 68be16a3abSBruce Evans jmp 9f 69be16a3abSBruce Evans #define ENTRY(x) _ENTRY(x); \ 70a5200470SPeter Wemm pushq %rbp; movq %rsp,%rbp; \ 71be16a3abSBruce Evans call PIC_PLT(HIDENAME(mcount)); \ 72a5200470SPeter Wemm popq %rbp; \ 73be16a3abSBruce Evans 9: 74a8626855SBruce Evans #else 75ed253219SJason Evans #define ALTENTRY(x) _ENTRY(x) 76be16a3abSBruce Evans #define ENTRY(x) _ENTRY(x) 77644ba7e8SBruce Evans #endif 7813a44161SBruce Evans 79298889efSJoseph Koshy #define END(x) .size x, . - x 80d2ef321aSAndreas Tobler /* 81d2ef321aSAndreas Tobler * WEAK_REFERENCE(): create a weak reference alias from sym. 82d2ef321aSAndreas Tobler * The macro is not a general asm macro that takes arbitrary names, 83d2ef321aSAndreas Tobler * but one that takes only C names. It does the non-null name 84d2ef321aSAndreas Tobler * translation inside the macro. 85d2ef321aSAndreas Tobler */ 86d2ef321aSAndreas Tobler #define WEAK_REFERENCE(sym, alias) \ 87d2ef321aSAndreas Tobler .weak CNAME(alias); \ 88d2ef321aSAndreas Tobler .equ CNAME(alias),CNAME(sym) 89298889efSJoseph Koshy 90a8626855SBruce Evans #define RCSID(x) .text; .asciz x 91a8626855SBruce Evans 92439a4003SDavid E. O'Brien #undef __FBSDID 93439a4003SDavid E. O'Brien #if !defined(lint) && !defined(STRIP_FBSDID) 94439a4003SDavid E. O'Brien #define __FBSDID(s) .ident s 95439a4003SDavid E. O'Brien #else 96439a4003SDavid E. O'Brien #define __FBSDID(s) /* nothing */ 97439a4003SDavid E. O'Brien #endif /* not lint and not STRIP_FBSDID */ 98439a4003SDavid E. O'Brien 99a8626855SBruce Evans #endif /* !_MACHINE_ASM_H_ */ 100