blob: 326099199318c4ce1066a03a04220c08914ca890 [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
Glauber Costa392a0fc2008-07-11 12:36:52 -030030
31#ifdef CONFIG_AS_CFI_SIGNAL_FRAME
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030032#define CFI_SIGNAL_FRAME .cfi_signal_frame
Thomas Gleixner96a388d2007-10-11 11:20:03 +020033#else
Glauber Costa392a0fc2008-07-11 12:36:52 -030034#define CFI_SIGNAL_FRAME
35#endif
36
Roland McGrath9e565292010-05-13 21:43:03 -070037#if defined(CONFIG_AS_CFI_SECTIONS) && defined(__ASSEMBLY__)
38 /*
39 * Emit CFI data in .debug_frame sections, not .eh_frame sections.
40 * The latter we currently just discard since we don't do DWARF
41 * unwinding at runtime. So only the offline DWARF information is
42 * useful to anyone. Note we should not use this directive if this
43 * file is used in the vDSO assembly, or if vmlinux.lds.S gets
44 * changed so it doesn't discard .eh_frame.
45 */
46 .cfi_sections .debug_frame
47#endif
48
Glauber Costa392a0fc2008-07-11 12:36:52 -030049#else
50
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030051/*
52 * Due to the structure of pre-exisiting code, don't use assembler line
53 * comment character # to ignore the arguments. Instead, use a dummy macro.
54 */
Kevin Winchester3f1c3872008-07-14 21:36:13 -030055.macro cfi_ignore a=0, b=0, c=0, d=0
Glauber Costa392a0fc2008-07-11 12:36:52 -030056.endm
57
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030058#define CFI_STARTPROC cfi_ignore
59#define CFI_ENDPROC cfi_ignore
60#define CFI_DEF_CFA cfi_ignore
Kevin Winchester3f1c3872008-07-14 21:36:13 -030061#define CFI_DEF_CFA_REGISTER cfi_ignore
62#define CFI_DEF_CFA_OFFSET cfi_ignore
63#define CFI_ADJUST_CFA_OFFSET cfi_ignore
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030064#define CFI_OFFSET cfi_ignore
65#define CFI_REL_OFFSET cfi_ignore
66#define CFI_REGISTER cfi_ignore
67#define CFI_RESTORE cfi_ignore
68#define CFI_REMEMBER_STATE cfi_ignore
69#define CFI_RESTORE_STATE cfi_ignore
70#define CFI_UNDEFINED cfi_ignore
71#define CFI_SIGNAL_FRAME cfi_ignore
Glauber Costa392a0fc2008-07-11 12:36:52 -030072
73#endif
74
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +030075/*
76 * An attempt to make CFI annotations more or less
77 * correct and shorter. It is implied that you know
78 * what you're doing if you use them.
79 */
80#ifdef __ASSEMBLY__
81#ifdef CONFIG_X86_64
82 .macro pushq_cfi reg
83 pushq \reg
84 CFI_ADJUST_CFA_OFFSET 8
85 .endm
86
87 .macro popq_cfi reg
88 popq \reg
89 CFI_ADJUST_CFA_OFFSET -8
90 .endm
91
Jan Beulichdf5d1872010-09-02 14:07:16 +010092 .macro pushfq_cfi
93 pushfq
94 CFI_ADJUST_CFA_OFFSET 8
95 .endm
96
97 .macro popfq_cfi
98 popfq
99 CFI_ADJUST_CFA_OFFSET -8
100 .endm
101
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +0300102 .macro movq_cfi reg offset=0
103 movq %\reg, \offset(%rsp)
104 CFI_REL_OFFSET \reg, \offset
105 .endm
106
107 .macro movq_cfi_restore offset reg
108 movq \offset(%rsp), %\reg
109 CFI_RESTORE \reg
110 .endm
111#else /*!CONFIG_X86_64*/
H. Peter Anvinfe9b4e42009-08-31 11:53:23 -0700112 .macro pushl_cfi reg
113 pushl \reg
114 CFI_ADJUST_CFA_OFFSET 4
115 .endm
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +0300116
H. Peter Anvinfe9b4e42009-08-31 11:53:23 -0700117 .macro popl_cfi reg
118 popl \reg
119 CFI_ADJUST_CFA_OFFSET -4
120 .endm
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +0300121
Jan Beulichdf5d1872010-09-02 14:07:16 +0100122 .macro pushfl_cfi
123 pushfl
124 CFI_ADJUST_CFA_OFFSET 4
125 .endm
126
127 .macro popfl_cfi
128 popfl
129 CFI_ADJUST_CFA_OFFSET -4
130 .endm
131
H. Peter Anvinfe9b4e42009-08-31 11:53:23 -0700132 .macro movl_cfi reg offset=0
133 movl %\reg, \offset(%esp)
134 CFI_REL_OFFSET \reg, \offset
135 .endm
136
137 .macro movl_cfi_restore offset reg
138 movl \offset(%esp), %\reg
139 CFI_RESTORE \reg
140 .endm
Cyrill Gorcunov8a2503f2008-11-23 14:53:43 +0300141#endif /*!CONFIG_X86_64*/
142#endif /*__ASSEMBLY__*/
143
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700144#endif /* _ASM_X86_DWARF2_H */