]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/i386/sysdep.h
Replace FSF snail mail address with URLs.
[thirdparty/glibc.git] / sysdeps / i386 / sysdep.h
CommitLineData
e75154a6 1/* Assembler macros for i386.
0269750c 2 Copyright (C) 1991-93,95,96,98,2002,2003,2005,2006,2011,2012
11bf311e 3 Free Software Foundation, Inc.
2c6fe0bd
UD
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
2c6fe0bd
UD
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 14 Lesser General Public License for more details.
2c6fe0bd 15
41bdb6e2 16 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
e75154a6
RM
19
20#include <sysdeps/generic/sysdep.h>
21
314054ea
JM
22#include <features.h> /* For __GNUC_PREREQ. */
23
24/* It is desirable that the names of PIC thunks match those used by
d4a54ac6
JM
25 GCC so that multiple copies are eliminated by the linker. Because
26 GCC 4.6 and earlier use __i686 in the names, it is necessary to
27 override that predefined macro. */
28#if defined __i686 && defined __ASSEMBLER__
29#undef __i686
30#define __i686 __i686
31#endif
314054ea
JM
32
33#ifdef __ASSEMBLER__
34# if __GNUC_PREREQ (4, 7)
35# define GET_PC_THUNK(reg) __x86.get_pc_thunk.reg
36# else
37# define GET_PC_THUNK(reg) __i686.get_pc_thunk.reg
38# endif
b1da7dd9 39#else
314054ea
JM
40# if __GNUC_PREREQ (4, 7)
41# define GET_PC_THUNK_STR(reg) "__x86.get_pc_thunk." #reg
42# else
43# define GET_PC_THUNK_STR(reg) "__i686.get_pc_thunk." #reg
44# endif
b1da7dd9
JM
45#endif
46
66715f83 47#ifdef __ASSEMBLER__
e75154a6
RM
48
49/* Syntactic details of assembler. */
50
e75154a6
RM
51/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
52#define ALIGNARG(log2) 1<<log2
53/* For ELF we need the `.type' directive to make shared libs work right. */
54#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
ae828bc6 55#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
e75154a6 56
e75154a6 57
ae828bc6
UD
58/* Define an entry point visible from C.
59
60 There is currently a bug in gdb which prevents us from specifying
61 incomplete stabs information. Fake some entries here which specify
62 the current source file. */
e75154a6 63#define ENTRY(name) \
ae828bc6
UD
64 STABS_CURRENT_FILE1("") \
65 STABS_CURRENT_FILE(name) \
e75154a6
RM
66 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
67 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
68 .align ALIGNARG(4); \
ae828bc6 69 STABS_FUN(name) \
e75154a6 70 C_LABEL(name) \
62d01985 71 cfi_startproc; \
e75154a6
RM
72 CALL_MCOUNT
73
6ed0492f
UD
74#undef END
75#define END(name) \
62d01985 76 cfi_endproc; \
ae828bc6
UD
77 ASM_SIZE_DIRECTIVE(name) \
78 STABS_FUN_END(name)
79
3af48cbd
L
80#define ENTRY_CHK(name) ENTRY (name)
81#define END_CHK(name) END (name)
82
e48f9638
RM
83#ifdef HAVE_CPP_ASM_DEBUGINFO
84/* Disable that goop, because we just pass -g through to the assembler
85 and it generates proper line number information directly. */
86# define STABS_CURRENT_FILE1(name)
87# define STABS_CURRENT_FILE(name)
88# define STABS_FUN(name)
89# define STABS_FUN_END(name)
90#else
ae828bc6
UD
91/* Remove the following two lines once the gdb bug is fixed. */
92#define STABS_CURRENT_FILE(name) \
93 STABS_CURRENT_FILE1 (#name)
94#define STABS_CURRENT_FILE1(name) \
95 1: .stabs name,100,0,0,1b;
96/* Emit stabs definition lines. We use F(0,1) and define t(0,1) as `int',
97 the same way gcc does it. */
98#define STABS_FUN(name) STABS_FUN2(name, name##:F(0,1))
99#define STABS_FUN2(name, namestr) \
100 .stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,0,0; \
101 .stabs #namestr,36,0,0,name;
102#define STABS_FUN_END(name) \
103 1: .stabs "",36,0,0,1b-name;
e48f9638 104#endif
6ed0492f 105
e75154a6
RM
106/* If compiled for profiling, call `mcount' at the start of each function. */
107#ifdef PROF
108/* The mcount code relies on a normal frame pointer being on the stack
109 to locate our caller, so push one just for its benefit. */
110#define CALL_MCOUNT \
cb8d9c93 111 pushl %ebp; cfi_adjust_cfa_offset (4); movl %esp, %ebp; \
62d01985
UD
112 cfi_def_cfa_register (ebp); call JUMPTARGET(mcount); \
113 popl %ebp; cfi_def_cfa (esp, 4);
e75154a6
RM
114#else
115#define CALL_MCOUNT /* Do nothing. */
116#endif
117
e75154a6
RM
118/* Since C identifiers are not normally prefixed with an underscore
119 on this system, the asm identifier `syscall_error' intrudes on the
120 C name space. Make sure we use an innocuous name. */
121#define syscall_error __syscall_error
122#define mcount _mcount
e75154a6
RM
123
124#define PSEUDO(name, syscall_name, args) \
e75154a6 125 .globl syscall_error; \
ffa8d2a0
RM
126lose: SYSCALL_PIC_SETUP \
127 jmp JUMPTARGET(syscall_error); \
e75154a6
RM
128 ENTRY (name) \
129 DO_CALL (syscall_name, args); \
130 jb lose
131
cccda09f
UD
132#undef PSEUDO_END
133#define PSEUDO_END(name) \
6ed0492f 134 END (name)
cccda09f 135
11bf311e 136# define SETUP_PIC_REG(reg) \
b1da7dd9
JM
137 .ifndef GET_PC_THUNK(reg); \
138 .section .gnu.linkonce.t.GET_PC_THUNK(reg),"ax",@progbits; \
139 .globl GET_PC_THUNK(reg); \
140 .hidden GET_PC_THUNK(reg); \
9a1d9254 141 .p2align 4; \
b1da7dd9
JM
142 .type GET_PC_THUNK(reg),@function; \
143GET_PC_THUNK(reg): \
1f708405
RM
144 movl (%esp), %e##reg; \
145 ret; \
b1da7dd9 146 .size GET_PC_THUNK(reg), . - GET_PC_THUNK(reg); \
1f708405
RM
147 .previous; \
148 .endif; \
b1da7dd9 149 call GET_PC_THUNK(reg)
1f708405
RM
150
151# define LOAD_PIC_REG(reg) \
152 SETUP_PIC_REG(reg); addl $_GLOBAL_OFFSET_TABLE_, %e##reg
153
9a1d9254
JM
154#undef JUMPTARGET
155#ifdef PIC
156#define JUMPTARGET(name) name##@PLT
157#define SYSCALL_PIC_SETUP \
158 pushl %ebx; \
159 cfi_adjust_cfa_offset (4); \
160 call 0f; \
1610: popl %ebx; \
162 cfi_adjust_cfa_offset (-4); \
163 addl $_GLOBAL_OFFSET_TABLE+[.-0b], %ebx;
164
e75154a6
RM
165#else
166#define JUMPTARGET(name) name
167#define SYSCALL_PIC_SETUP /* Nothing. */
168#endif
169
ac16e905
UD
170/* Local label name for asm code. */
171#ifndef L
ffa8d2a0 172#define L(name) .L##name
ffa8d2a0 173#endif
ac16e905 174
ceaa0c5d
UD
175#define atom_text_section .section ".text.atom", "ax"
176
d8e0ca50
JM
177#else /* __ASSEMBLER__ */
178
179# define SETUP_PIC_REG_STR(reg) \
180 ".ifndef " GET_PC_THUNK_STR (reg) "\n" \
181 ".section .gnu.linkonce.t." GET_PC_THUNK_STR (reg) ",\"ax\",@progbits\n" \
182 ".globl " GET_PC_THUNK_STR (reg) "\n" \
183 ".hidden " GET_PC_THUNK_STR (reg) "\n" \
184 ".p2align 4\n" \
185 ".type " GET_PC_THUNK_STR (reg) ",@function\n" \
186GET_PC_THUNK_STR (reg) ":" \
187 "movl (%%esp), %%e" #reg "\n" \
188 "ret\n" \
189 ".size " GET_PC_THUNK_STR (reg) ", . - " GET_PC_THUNK_STR (reg) "\n" \
190 ".previous\n" \
191 ".endif\n" \
192 "call " GET_PC_THUNK_STR (reg)
193
194# define LOAD_PIC_REG_STR(reg) \
195 SETUP_PIC_REG_STR (reg) "\naddl $_GLOBAL_OFFSET_TABLE_, %%e" #reg
196
66715f83 197#endif /* __ASSEMBLER__ */