/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1990 The Regents of the University of California.4* All rights reserved.5*6* This code is derived from software contributed to Berkeley by7* William Jolitz.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17* 3. Neither the name of the University nor the names of its contributors18* may be used to endorse or promote products derived from this software19* without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND22* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE25* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31* SUCH DAMAGE.32*/3334#ifndef _MACHINE_ASM_H_35#define _MACHINE_ASM_H_3637#include <sys/cdefs.h>3839#ifdef PIC40#define PIC_PROLOGUE \41pushl %ebx; \42call 1f; \431: \44popl %ebx; \45addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx46#define PIC_EPILOGUE \47popl %ebx48#define PIC_PLT(x) x@PLT49#define PIC_GOT(x) x@GOT(%ebx)50#define PIC_GOTOFF(x) x@GOTOFF(%ebx)51#else52#define PIC_PROLOGUE53#define PIC_EPILOGUE54#define PIC_PLT(x) x55#define PIC_GOTOFF(x) x56#endif5758/*59* CNAME and HIDENAME manage the relationship between symbol names in C60* and the equivalent assembly language names. CNAME is given a name as61* it would be used in a C program. It expands to the equivalent assembly62* language name. HIDENAME is given an assembly-language name, and expands63* to a possibly-modified form that will be invisible to C programs.64*/65#define CNAME(csym) csym66#define HIDENAME(asmsym) .asmsym6768/* XXX should use .p2align 4,0x90 for -m486. */69#define _START_ENTRY .text; .p2align 2,0x907071#define _ENTRY(x) _START_ENTRY; \72.globl CNAME(x); .type CNAME(x),@function; CNAME(x): \73.cfi_startproc74#define END(x) .cfi_endproc; .size x, . - x7576#ifdef PROF77#define ALTENTRY(x) _ENTRY(x); \78pushl %ebp; \79.cfi_def_cfa_offset 8; \80.cfi_offset %ebp, -8; \81movl %esp,%ebp; \82call PIC_PLT(HIDENAME(mcount)); \83popl %ebp; \84.cfi_restore %ebp; \85.cfi_def_cfa_offset 4; \86jmp 9f87#define ENTRY(x) _ENTRY(x); \88pushl %ebp; \89.cfi_def_cfa_offset 8; \90.cfi_offset %ebp, -8; \91movl %esp,%ebp; \92call PIC_PLT(HIDENAME(mcount)); \93popl %ebp; \94.cfi_restore %ebp; \95.cfi_def_cfa_offset 4; \969:97#else98#define ALTENTRY(x) _ENTRY(x)99#define ENTRY(x) _ENTRY(x)100#endif101102/*103* WEAK_REFERENCE(): create a weak reference alias from sym.104* The macro is not a general asm macro that takes arbitrary names,105* but one that takes only C names. It does the non-null name106* translation inside the macro.107*/108109#define WEAK_REFERENCE(sym, alias) \110.weak CNAME(alias); \111.equ CNAME(alias),CNAME(sym)112113/*114* STRONG_ALIAS: create a strong alias.115*/116#define STRONG_ALIAS(alias,sym) \117.globl alias; \118alias = sym119120#define RCSID(x) .text; .asciz x121122#undef __FBSDID123#if !defined(STRIP_FBSDID)124#define __FBSDID(s) .ident s125#else126#define __FBSDID(s) /* nothing */127#endif /* not STRIP_FBSDID */128129#endif /* !_MACHINE_ASM_H_ */130131132