| 1 |
/* syntax.h -- Definitions for x86 syntax variations. |
| 2 |
* |
| 3 |
* Copyright (C) 1992, 1994, 1995, 1998, |
| 4 |
* 2001, 2002 Free Software Foundation, Inc. |
| 5 |
* |
| 6 |
* This file is part of Libgcrypt. |
| 7 |
* |
| 8 |
* Libgcrypt is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as |
| 10 |
* published by the Free Software Foundation; either version 2.1 of |
| 11 |
* the License, or (at your option) any later version. |
| 12 |
* |
| 13 |
* Libgcrypt is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public |
| 19 |
* License along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 20 |
* SPDX-License-Identifier: LGPL-2.1-or-later |
| 21 |
* |
| 22 |
* Note: This code is heavily based on the GNU MP Library. |
| 23 |
* Actually it's the same code with only minor changes in the |
| 24 |
* way the data is stored; this is to support the abstraction |
| 25 |
* of an optional secure memory allocation which may be used |
| 26 |
* to avoid revealing of sensitive data due to paging etc. |
| 27 |
*/ |
| 28 |
|
| 29 |
#include <config.h> |
| 30 |
|
| 31 |
#ifdef __i386__ |
| 32 |
#include "asm-common-i386.h" |
| 33 |
#endif |
| 34 |
|
| 35 |
#undef ALIGN |
| 36 |
|
| 37 |
#if defined (BSD_SYNTAX) || defined (ELF_SYNTAX) |
| 38 |
#define R(r) %r |
| 39 |
#define MEM(base)(base) |
| 40 |
#define MEM_DISP(base,displacement)displacement(R(base)) |
| 41 |
#define MEM_INDEX(base,index,size)(R(base),R(index),size) |
| 42 |
#ifdef __STDC__ |
| 43 |
#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst |
| 44 |
#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst |
| 45 |
#else |
| 46 |
#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst |
| 47 |
#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst |
| 48 |
#endif |
| 49 |
#define TEXT .text |
| 50 |
#if defined (BSD_SYNTAX) |
| 51 |
#define ALIGN(log) .align log |
| 52 |
#endif |
| 53 |
#if defined (ELF_SYNTAX) |
| 54 |
#define ALIGN(log) .align 1<<(log) |
| 55 |
#endif |
| 56 |
#define GLOBL .globl |
| 57 |
#endif |
| 58 |
|
| 59 |
#ifdef INTEL_SYNTAX |
| 60 |
#define R(r) r |
| 61 |
#define MEM(base)[base] |
| 62 |
#define MEM_DISP(base,displacement)[base+(displacement)] |
| 63 |
#define MEM_INDEX(base,index,size)[base+index*size] |
| 64 |
#define INSN1(mnemonic,size_suffix,dst)mnemonic dst |
| 65 |
#define INSN2(mnemonic,size_suffix,dst,src)mnemonic dst,src |
| 66 |
#define TEXT .text |
| 67 |
#define ALIGN(log) .align log |
| 68 |
#define GLOBL .globl |
| 69 |
#endif |
| 70 |
|
| 71 |
#ifdef X86_BROKEN_ALIGN |
| 72 |
#undef ALIGN |
| 73 |
#define ALIGN(log) .align log,0x90 |
| 74 |
#endif |
| 75 |
|
| 76 |
/* 'ret' instruction replacement for straight-line speculation mitigation */ |
| 77 |
#define ret_spec_stop \ |
| 78 |
ret; int3; |