H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_DWARF2_H |
| 2 | #define _ASM_X86_DWARF2_H |
Glauber Costa | 392a0fc | 2008-07-11 12:36:52 -0300 | [diff] [blame] | 3 | |
| 4 | #ifndef __ASSEMBLY__ |
| 5 | #warning "asm/dwarf2.h should be only included in pure assembly files" |
| 6 | #endif |
| 7 | |
| 8 | /* |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 9 | * 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 Costa | 392a0fc | 2008-07-11 12:36:52 -0300 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #ifdef CONFIG_AS_CFI |
| 16 | |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 17 | #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 Beulich | eab9e61 | 2011-09-28 16:57:52 +0100 | [diff] [blame] | 30 | #define CFI_ESCAPE .cfi_escape |
Glauber Costa | 392a0fc | 2008-07-11 12:36:52 -0300 | [diff] [blame] | 31 | |
| 32 | #ifdef CONFIG_AS_CFI_SIGNAL_FRAME |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 33 | #define CFI_SIGNAL_FRAME .cfi_signal_frame |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 34 | #else |
Glauber Costa | 392a0fc | 2008-07-11 12:36:52 -0300 | [diff] [blame] | 35 | #define CFI_SIGNAL_FRAME |
| 36 | #endif |
| 37 | |
Roland McGrath | 9e56529 | 2010-05-13 21:43:03 -0700 | [diff] [blame] | 38 | #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 Costa | 392a0fc | 2008-07-11 12:36:52 -0300 | [diff] [blame] | 50 | #else |
| 51 | |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 52 | /* |
| 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 Winchester | 3f1c387 | 2008-07-14 21:36:13 -0300 | [diff] [blame] | 56 | .macro cfi_ignore a=0, b=0, c=0, d=0 |
Glauber Costa | 392a0fc | 2008-07-11 12:36:52 -0300 | [diff] [blame] | 57 | .endm |
| 58 | |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 59 | #define CFI_STARTPROC cfi_ignore |
| 60 | #define CFI_ENDPROC cfi_ignore |
| 61 | #define CFI_DEF_CFA cfi_ignore |
Kevin Winchester | 3f1c387 | 2008-07-14 21:36:13 -0300 | [diff] [blame] | 62 | #define CFI_DEF_CFA_REGISTER cfi_ignore |
| 63 | #define CFI_DEF_CFA_OFFSET cfi_ignore |
| 64 | #define CFI_ADJUST_CFA_OFFSET cfi_ignore |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 65 | #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 Beulich | eab9e61 | 2011-09-28 16:57:52 +0100 | [diff] [blame] | 72 | #define CFI_ESCAPE cfi_ignore |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 73 | #define CFI_SIGNAL_FRAME cfi_ignore |
Glauber Costa | 392a0fc | 2008-07-11 12:36:52 -0300 | [diff] [blame] | 74 | |
| 75 | #endif |
| 76 | |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 77 | /* |
| 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 | |
| 89 | .macro popq_cfi reg |
| 90 | popq \reg |
| 91 | CFI_ADJUST_CFA_OFFSET -8 |
| 92 | .endm |
| 93 | |
Jan Beulich | df5d187 | 2010-09-02 14:07:16 +0100 | [diff] [blame] | 94 | .macro pushfq_cfi |
| 95 | pushfq |
| 96 | CFI_ADJUST_CFA_OFFSET 8 |
| 97 | .endm |
| 98 | |
| 99 | .macro popfq_cfi |
| 100 | popfq |
| 101 | CFI_ADJUST_CFA_OFFSET -8 |
| 102 | .endm |
| 103 | |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 104 | .macro movq_cfi reg offset=0 |
| 105 | movq %\reg, \offset(%rsp) |
| 106 | CFI_REL_OFFSET \reg, \offset |
| 107 | .endm |
| 108 | |
| 109 | .macro movq_cfi_restore offset reg |
| 110 | movq \offset(%rsp), %\reg |
| 111 | CFI_RESTORE \reg |
| 112 | .endm |
| 113 | #else /*!CONFIG_X86_64*/ |
H. Peter Anvin | fe9b4e4 | 2009-08-31 11:53:23 -0700 | [diff] [blame] | 114 | .macro pushl_cfi reg |
| 115 | pushl \reg |
| 116 | CFI_ADJUST_CFA_OFFSET 4 |
| 117 | .endm |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 118 | |
H. Peter Anvin | fe9b4e4 | 2009-08-31 11:53:23 -0700 | [diff] [blame] | 119 | .macro popl_cfi reg |
| 120 | popl \reg |
| 121 | CFI_ADJUST_CFA_OFFSET -4 |
| 122 | .endm |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 123 | |
Jan Beulich | df5d187 | 2010-09-02 14:07:16 +0100 | [diff] [blame] | 124 | .macro pushfl_cfi |
| 125 | pushfl |
| 126 | CFI_ADJUST_CFA_OFFSET 4 |
| 127 | .endm |
| 128 | |
| 129 | .macro popfl_cfi |
| 130 | popfl |
| 131 | CFI_ADJUST_CFA_OFFSET -4 |
| 132 | .endm |
| 133 | |
H. Peter Anvin | fe9b4e4 | 2009-08-31 11:53:23 -0700 | [diff] [blame] | 134 | .macro movl_cfi reg offset=0 |
| 135 | movl %\reg, \offset(%esp) |
| 136 | CFI_REL_OFFSET \reg, \offset |
| 137 | .endm |
| 138 | |
| 139 | .macro movl_cfi_restore offset reg |
| 140 | movl \offset(%esp), %\reg |
| 141 | CFI_RESTORE \reg |
| 142 | .endm |
Cyrill Gorcunov | 8a2503f | 2008-11-23 14:53:43 +0300 | [diff] [blame] | 143 | #endif /*!CONFIG_X86_64*/ |
| 144 | #endif /*__ASSEMBLY__*/ |
| 145 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 146 | #endif /* _ASM_X86_DWARF2_H */ |