blob: de1cdaf4d74346040667da81e767a5a32697c7c6 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_DWARF2_H
2#define _ASM_X86_DWARF2_H
Glauber Costa392a0fc2008-07-11 12:36:52 -03003
4#ifndef __ASSEMBLY__
5#warning "asm/dwarf2.h should be only included in pure assembly files"
6#endif
7
8/*
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +03009 * Macros for dwarf2 CFI unwind table entries.
10 * See "as.info" for details on these pseudo ops. Unfortunately
11 * they are only supported in very new binutils, so define them
12 * away for older version.
Glauber Costa392a0fc2008-07-11 12:36:52 -030013 */
14
15#ifdef CONFIG_AS_CFI
16
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030017#define CFI_STARTPROC .cfi_startproc
18#define CFI_ENDPROC .cfi_endproc
19#define CFI_DEF_CFA .cfi_def_cfa
20#define CFI_DEF_CFA_REGISTER .cfi_def_cfa_register
21#define CFI_DEF_CFA_OFFSET .cfi_def_cfa_offset
22#define CFI_ADJUST_CFA_OFFSET .cfi_adjust_cfa_offset
23#define CFI_OFFSET .cfi_offset
24#define CFI_REL_OFFSET .cfi_rel_offset
25#define CFI_REGISTER .cfi_register
26#define CFI_RESTORE .cfi_restore
27#define CFI_REMEMBER_STATE .cfi_remember_state
28#define CFI_RESTORE_STATE .cfi_restore_state
29#define CFI_UNDEFINED .cfi_undefined
Jan Beulicheab9e612011-09-28 16:57:52 +010030#define CFI_ESCAPE .cfi_escape
Glauber Costa392a0fc2008-07-11 12:36:52 -030031
32#ifdef CONFIG_AS_CFI_SIGNAL_FRAME
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030033#define CFI_SIGNAL_FRAME .cfi_signal_frame
Thomas Gleixner96a388d2007-10-11 11:20:03 +020034#else
Glauber Costa392a0fc2008-07-11 12:36:52 -030035#define CFI_SIGNAL_FRAME
36#endif
37
Roland McGrath9e565292010-05-13 21:43:03 -070038#if defined(CONFIG_AS_CFI_SECTIONS) && defined(__ASSEMBLY__)
39 /*
40 * Emit CFI data in .debug_frame sections, not .eh_frame sections.
41 * The latter we currently just discard since we don't do DWARF
42 * unwinding at runtime. So only the offline DWARF information is
43 * useful to anyone. Note we should not use this directive if this
44 * file is used in the vDSO assembly, or if vmlinux.lds.S gets
45 * changed so it doesn't discard .eh_frame.
46 */
47 .cfi_sections .debug_frame
48#endif
49
Glauber Costa392a0fc2008-07-11 12:36:52 -030050#else
51
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030052/*
53 * Due to the structure of pre-exisiting code, don't use assembler line
54 * comment character # to ignore the arguments. Instead, use a dummy macro.
55 */
Kevin Winchester3f1c3872008-07-14 21:36:13 -030056.macro cfi_ignore a=0, b=0, c=0, d=0
Glauber Costa392a0fc2008-07-11 12:36:52 -030057.endm
58
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030059#define CFI_STARTPROC cfi_ignore
60#define CFI_ENDPROC cfi_ignore
61#define CFI_DEF_CFA cfi_ignore
Kevin Winchester3f1c3872008-07-14 21:36:13 -030062#define CFI_DEF_CFA_REGISTER cfi_ignore
63#define CFI_DEF_CFA_OFFSET cfi_ignore
64#define CFI_ADJUST_CFA_OFFSET cfi_ignore
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030065#define CFI_OFFSET cfi_ignore
66#define CFI_REL_OFFSET cfi_ignore
67#define CFI_REGISTER cfi_ignore
68#define CFI_RESTORE cfi_ignore
69#define CFI_REMEMBER_STATE cfi_ignore
70#define CFI_RESTORE_STATE cfi_ignore
71#define CFI_UNDEFINED cfi_ignore
Jan Beulicheab9e612011-09-28 16:57:52 +010072#define CFI_ESCAPE cfi_ignore
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030073#define CFI_SIGNAL_FRAME cfi_ignore
Glauber Costa392a0fc2008-07-11 12:36:52 -030074
75#endif
76
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030077/*
78 * An attempt to make CFI annotations more or less
79 * correct and shorter. It is implied that you know
80 * what you're doing if you use them.
81 */
82#ifdef __ASSEMBLY__
83#ifdef CONFIG_X86_64
84 .macro pushq_cfi reg
85 pushq \reg
86 CFI_ADJUST_CFA_OFFSET 8
87 .endm
88
Denys Vlasenko49db46a2015-02-26 14:40:25 -080089 .macro pushq_cfi_reg reg
90 pushq %\reg
91 CFI_ADJUST_CFA_OFFSET 8
92 CFI_REL_OFFSET \reg, 0
93 .endm
94
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030095 .macro popq_cfi reg
96 popq \reg
97 CFI_ADJUST_CFA_OFFSET -8
98 .endm
99
Denys Vlasenko49db46a2015-02-26 14:40:25 -0800100 .macro popq_cfi_reg reg
101 popq %\reg
102 CFI_ADJUST_CFA_OFFSET -8
103 CFI_RESTORE \reg
104 .endm
105
Jan Beulichdf5d1872010-09-02 14:07:16 +0100106 .macro pushfq_cfi
107 pushfq
108 CFI_ADJUST_CFA_OFFSET 8
109 .endm
110
111 .macro popfq_cfi
112 popfq
113 CFI_ADJUST_CFA_OFFSET -8
114 .endm
115
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +0300116 .macro movq_cfi reg offset=0
117 movq %\reg, \offset(%rsp)
118 CFI_REL_OFFSET \reg, \offset
119 .endm
120
121 .macro movq_cfi_restore offset reg
122 movq \offset(%rsp), %\reg
123 CFI_RESTORE \reg
124 .endm
125#else /*!CONFIG_X86_64*/
H. Peter Anvinfe9b4e42009-08-31 11:53:23 -0700126 .macro pushl_cfi reg
127 pushl \reg
128 CFI_ADJUST_CFA_OFFSET 4
129 .endm
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +0300130
Denys Vlasenko49db46a2015-02-26 14:40:25 -0800131 .macro pushl_cfi_reg reg
132 pushl %\reg
133 CFI_ADJUST_CFA_OFFSET 4
134 CFI_REL_OFFSET \reg, 0
135 .endm
136
H. Peter Anvinfe9b4e42009-08-31 11:53:23 -0700137 .macro popl_cfi reg
138 popl \reg
139 CFI_ADJUST_CFA_OFFSET -4
140 .endm
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +0300141
Denys Vlasenko49db46a2015-02-26 14:40:25 -0800142 .macro popl_cfi_reg reg
143 popl %\reg
144 CFI_ADJUST_CFA_OFFSET -4
145 CFI_RESTORE \reg
146 .endm
147
Jan Beulichdf5d1872010-09-02 14:07:16 +0100148 .macro pushfl_cfi
149 pushfl
150 CFI_ADJUST_CFA_OFFSET 4
151 .endm
152
153 .macro popfl_cfi
154 popfl
155 CFI_ADJUST_CFA_OFFSET -4
156 .endm
157
H. Peter Anvinfe9b4e42009-08-31 11:53:23 -0700158 .macro movl_cfi reg offset=0
159 movl %\reg, \offset(%esp)
160 CFI_REL_OFFSET \reg, \offset
161 .endm
162
163 .macro movl_cfi_restore offset reg
164 movl \offset(%esp), %\reg
165 CFI_RESTORE \reg
166 .endm
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +0300167#endif /*!CONFIG_X86_64*/
168#endif /*__ASSEMBLY__*/
169
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700170#endif /* _ASM_X86_DWARF2_H */