/*-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#ifdef __i386__35#include <i386/asm.h>36#else /* !__i386__ */3738#ifndef _MACHINE_ASM_H_39#define _MACHINE_ASM_H_4041#include <sys/cdefs.h>4243#ifdef PIC44#define PIC_PLT(x) x@PLT45#define PIC_GOT(x) x@GOTPCREL(%rip)46#else47#define PIC_PLT(x) x48#endif4950/*51* CNAME and HIDENAME manage the relationship between symbol names in C52* and the equivalent assembly language names. CNAME is given a name as53* it would be used in a C program. It expands to the equivalent assembly54* language name. HIDENAME is given an assembly-language name, and expands55* to a possibly-modified form that will be invisible to C programs.56*/57#define CNAME(csym) csym58#define HIDENAME(asmsym) .asmsym5960#define _START_ENTRY .text; .p2align 4,0x906162#define _ENTRY(x) _START_ENTRY; \63.globl CNAME(x); .type CNAME(x),@function; CNAME(x):; \64.cfi_startproc6566#ifdef PROF67#define ALTENTRY(x) _ENTRY(x); \68pushq %rbp; \69.cfi_def_cfa_offset 16; \70.cfi_offset %rbp, -16; \71movq %rsp,%rbp; \72call PIC_PLT(HIDENAME(mcount)); \73popq %rbp; \74.cfi_restore %rbp; \75.cfi_def_cfa_offset 8; \76jmp 9f77#define ENTRY(x) _ENTRY(x); \78pushq %rbp; \79.cfi_def_cfa_offset 16; \80.cfi_offset %rbp, -16; \81movq %rsp,%rbp; \82call PIC_PLT(HIDENAME(mcount)); \83popq %rbp; \84.cfi_restore %rbp; \85.cfi_def_cfa_offset 8; \869:87#else88#define ALTENTRY(x) _ENTRY(x)89#define ENTRY(x) _ENTRY(x)90#endif9192#define END(x) .size x, . - x; .cfi_endproc93/*94* WEAK_REFERENCE(): create a weak reference alias from sym.95* The macro is not a general asm macro that takes arbitrary names,96* but one that takes only C names. It does the non-null name97* translation inside the macro.98*/99#define WEAK_REFERENCE(sym, alias) \100.weak CNAME(alias); \101.equ CNAME(alias),CNAME(sym)102103#define RCSID(x) .text; .asciz x104105#undef __FBSDID106#if !defined(STRIP_FBSDID)107#define __FBSDID(s) .ident s108#else109#define __FBSDID(s) /* nothing */110#endif /* !STRIP_FBSDID */111112#endif /* !_MACHINE_ASM_H_ */113114#endif /* __i386__ */115116117