]>
Commit | Line | Data |
---|---|---|
c9cf6dde | 1 | /* Assembler macros for x86-64. |
bfff8b1b | 2 | Copyright (C) 2001-2017 Free Software Foundation, Inc. |
c9cf6dde AJ |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
c9cf6dde | 18 | |
3b550e9e L |
19 | #ifndef _X86_64_SYSDEP_H |
20 | #define _X86_64_SYSDEP_H 1 | |
21 | ||
c9cf6dde AJ |
22 | #include <sysdeps/generic/sysdep.h> |
23 | ||
24 | #ifdef __ASSEMBLER__ | |
25 | ||
26 | /* Syntactic details of assembler. */ | |
27 | ||
21933112 AS |
28 | /* This macro is for setting proper CFI with DW_CFA_expression describing |
29 | the register as saved relative to %rsp instead of relative to the CFA. | |
30 | Expression is DW_OP_drop, DW_OP_breg7 (%rsp is register 7), sleb128 offset | |
31 | from %rsp. */ | |
32 | #define cfi_offset_rel_rsp(regn, off) .cfi_escape 0x10, regn, 0x4, 0x13, \ | |
33 | 0x77, off & 0x7F | 0x80, off >> 7 | |
34 | ||
c9cf6dde AJ |
35 | /* ELF uses byte-counts for .align, most others use log2 of count of bytes. */ |
36 | #define ALIGNARG(log2) 1<<log2 | |
c9cf6dde AJ |
37 | #define ASM_SIZE_DIRECTIVE(name) .size name,.-name; |
38 | ||
c9cf6dde AJ |
39 | |
40 | /* Define an entry point visible from C. */ | |
41 | #define ENTRY(name) \ | |
b67e9372 MP |
42 | .globl C_SYMBOL_NAME(name); \ |
43 | .type C_SYMBOL_NAME(name),@function; \ | |
c9cf6dde AJ |
44 | .align ALIGNARG(4); \ |
45 | C_LABEL(name) \ | |
50189569 | 46 | cfi_startproc; \ |
c9cf6dde AJ |
47 | CALL_MCOUNT |
48 | ||
49 | #undef END | |
50 | #define END(name) \ | |
50189569 AJ |
51 | cfi_endproc; \ |
52 | ASM_SIZE_DIRECTIVE(name) | |
c9cf6dde | 53 | |
6fb8cbcb L |
54 | #define ENTRY_CHK(name) ENTRY (name) |
55 | #define END_CHK(name) END (name) | |
56 | ||
c9cf6dde AJ |
57 | /* If compiled for profiling, call `mcount' at the start of each function. */ |
58 | #ifdef PROF | |
c9cf6dde AJ |
59 | /* The mcount code relies on a normal frame pointer being on the stack |
60 | to locate our caller, so push one just for its benefit. */ | |
50189569 AJ |
61 | #define CALL_MCOUNT \ |
62 | pushq %rbp; \ | |
63 | cfi_adjust_cfa_offset(8); \ | |
64 | movq %rsp, %rbp; \ | |
65 | cfi_def_cfa_register(%rbp); \ | |
66 | call JUMPTARGET(mcount); \ | |
67 | popq %rbp; \ | |
68 | cfi_def_cfa(rsp,8); | |
c9cf6dde AJ |
69 | #else |
70 | #define CALL_MCOUNT /* Do nothing. */ | |
71 | #endif | |
72 | ||
c9cf6dde AJ |
73 | /* Since C identifiers are not normally prefixed with an underscore |
74 | on this system, the asm identifier `syscall_error' intrudes on the | |
75 | C name space. Make sure we use an innocuous name. */ | |
76 | #define syscall_error __syscall_error | |
77 | #define mcount _mcount | |
c9cf6dde AJ |
78 | |
79 | #define PSEUDO(name, syscall_name, args) \ | |
80 | lose: \ | |
81 | jmp JUMPTARGET(syscall_error) \ | |
82 | .globl syscall_error; \ | |
83 | ENTRY (name) \ | |
84 | DO_CALL (syscall_name, args); \ | |
85 | jb lose | |
86 | ||
87 | #undef PSEUDO_END | |
88 | #define PSEUDO_END(name) \ | |
89 | END (name) | |
90 | ||
29d9a17d | 91 | #undef JUMPTARGET |
c9070e63 | 92 | #ifdef SHARED |
6901def6 L |
93 | # ifdef BIND_NOW |
94 | # define JUMPTARGET(name) *name##@GOTPCREL(%rip) | |
95 | # else | |
96 | # define JUMPTARGET(name) name##@PLT | |
97 | # endif | |
c9cf6dde | 98 | #else |
c9070e63 | 99 | /* For static archives, branch to target directly. */ |
6901def6 | 100 | # define JUMPTARGET(name) name |
c9cf6dde AJ |
101 | #endif |
102 | ||
103 | /* Local label name for asm code. */ | |
104 | #ifndef L | |
5bbfc1ea | 105 | /* ELF-like local names start with `.L'. */ |
0269750c | 106 | # define L(name) .L##name |
c9cf6dde AJ |
107 | #endif |
108 | ||
ceaa0c5d UD |
109 | #define atom_text_section .section ".text.atom", "ax" |
110 | ||
520ae0fd L |
111 | /* Long and pointer size in bytes. */ |
112 | #define LP_SIZE 8 | |
113 | ||
114 | /* Instruction to operate on long and pointer. */ | |
115 | #define LP_OP(insn) insn##q | |
116 | ||
117 | /* Assembler address directive. */ | |
118 | #define ASM_ADDR .quad | |
119 | ||
120 | /* Registers to hold long and pointer. */ | |
121 | #define RAX_LP rax | |
122 | #define RBP_LP rbp | |
123 | #define RBX_LP rbx | |
124 | #define RCX_LP rcx | |
125 | #define RDI_LP rdi | |
126 | #define RDX_LP rdx | |
127 | #define RSI_LP rsi | |
128 | #define RSP_LP rsp | |
129 | #define R8_LP r8 | |
130 | #define R9_LP r9 | |
131 | #define R10_LP r10 | |
132 | #define R11_LP r11 | |
133 | #define R12_LP r12 | |
134 | #define R13_LP r13 | |
135 | #define R14_LP r14 | |
136 | #define R15_LP r15 | |
137 | ||
138 | #else /* __ASSEMBLER__ */ | |
139 | ||
140 | /* Long and pointer size in bytes. */ | |
141 | #define LP_SIZE "8" | |
142 | ||
143 | /* Instruction to operate on long and pointer. */ | |
144 | #define LP_OP(insn) #insn "q" | |
145 | ||
146 | /* Assembler address directive. */ | |
147 | #define ASM_ADDR ".quad" | |
148 | ||
149 | /* Registers to hold long and pointer. */ | |
150 | #define RAX_LP "rax" | |
151 | #define RBP_LP "rbp" | |
152 | #define RBX_LP "rbx" | |
153 | #define RCX_LP "rcx" | |
154 | #define RDI_LP "rdi" | |
155 | #define RDX_LP "rdx" | |
156 | #define RSI_LP "rsi" | |
157 | #define RSP_LP "rsp" | |
158 | #define R8_LP "r8" | |
159 | #define R9_LP "r9" | |
160 | #define R10_LP "r10" | |
161 | #define R11_LP "r11" | |
162 | #define R12_LP "r12" | |
163 | #define R13_LP "r13" | |
164 | #define R14_LP "r14" | |
165 | #define R15_LP "r15" | |
166 | ||
c9cf6dde | 167 | #endif /* __ASSEMBLER__ */ |
3b550e9e L |
168 | |
169 | #endif /* _X86_64_SYSDEP_H */ |