dw2gencfi.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* dw2gencfi.h - Support for generating Dwarf2 CFI information.
  2. Copyright (C) 2003-2015 Free Software Foundation, Inc.
  3. Contributed by Michal Ludvig <mludvig@suse.cz>
  4. This file is part of GAS, the GNU Assembler.
  5. GAS is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. GAS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GAS; see the file COPYING. If not, write to the Free
  15. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  16. 02110-1301, USA. */
  17. #ifndef DW2GENCFI_H
  18. #define DW2GENCFI_H
  19. #include "dwarf2.h"
  20. struct symbol;
  21. extern const pseudo_typeS cfi_pseudo_table[];
  22. /* cfi_finish() is called at the end of file. It will complain if
  23. the last CFI wasn't properly closed by .cfi_endproc. */
  24. extern void cfi_finish (void);
  25. /* Entry points for backends to add unwind information. */
  26. extern void cfi_new_fde (struct symbol *);
  27. extern void cfi_end_fde (struct symbol *);
  28. extern void cfi_set_return_column (unsigned);
  29. extern void cfi_set_sections (void);
  30. extern void cfi_add_advance_loc (struct symbol *);
  31. extern void cfi_add_label (const char *);
  32. extern void cfi_add_CFA_offset (unsigned, offsetT);
  33. extern void cfi_add_CFA_def_cfa (unsigned, offsetT);
  34. extern void cfi_add_CFA_register (unsigned, unsigned);
  35. extern void cfi_add_CFA_def_cfa_register (unsigned);
  36. extern void cfi_add_CFA_def_cfa_offset (offsetT);
  37. extern void cfi_add_CFA_restore (unsigned);
  38. extern void cfi_add_CFA_undefined (unsigned);
  39. extern void cfi_add_CFA_same_value (unsigned);
  40. extern void cfi_add_CFA_remember_state (void);
  41. extern void cfi_add_CFA_restore_state (void);
  42. /* Structures for md_cfi_end. */
  43. #if defined (TE_PE) || defined (TE_PEP)
  44. #define SUPPORT_FRAME_LINKONCE 1
  45. #else
  46. #define SUPPORT_FRAME_LINKONCE 0
  47. #endif
  48. #ifdef tc_cfi_reloc_for_encoding
  49. #define SUPPORT_COMPACT_EH 1
  50. #else
  51. #define SUPPORT_COMPACT_EH 0
  52. #endif
  53. #define MULTIPLE_FRAME_SECTIONS (SUPPORT_FRAME_LINKONCE || SUPPORT_COMPACT_EH)
  54. struct cfi_insn_data
  55. {
  56. struct cfi_insn_data *next;
  57. #if MULTIPLE_FRAME_SECTIONS
  58. segT cur_seg;
  59. #endif
  60. int insn;
  61. union
  62. {
  63. struct
  64. {
  65. unsigned reg;
  66. offsetT offset;
  67. } ri;
  68. struct
  69. {
  70. unsigned reg1;
  71. unsigned reg2;
  72. } rr;
  73. unsigned r;
  74. offsetT i;
  75. struct
  76. {
  77. symbolS *lab1;
  78. symbolS *lab2;
  79. } ll;
  80. struct cfi_escape_data *esc;
  81. struct
  82. {
  83. unsigned reg, encoding;
  84. expressionS exp;
  85. } ea;
  86. const char *sym_name;
  87. } u;
  88. };
  89. /* An enumeration describing the Compact EH header format. The least
  90. significant bit is used to distinguish the entries.
  91. Inline Compact: Function offset [0]
  92. Four chars of unwind data.
  93. Out-of-line Compact: Function offset [1]
  94. Compact unwind data offset [0]
  95. Legacy: Function offset [1]
  96. Unwind data offset [1]
  97. The header type is initialized to EH_COMPACT_UNKNOWN until the
  98. format is discovered by encountering a .fde_data entry.
  99. Failure to find a .fde_data entry will cause an EH_COMPACT_LEGACY
  100. header to be generated. */
  101. enum {
  102. EH_COMPACT_UNKNOWN,
  103. EH_COMPACT_LEGACY,
  104. EH_COMPACT_INLINE,
  105. EH_COMPACT_OUTLINE,
  106. EH_COMPACT_OUTLINE_DONE,
  107. /* Outline if .cfi_inline_lsda used, otherwise legacy FDE. */
  108. EH_COMPACT_HAS_LSDA
  109. };
  110. struct fde_entry
  111. {
  112. struct fde_entry *next;
  113. #if MULTIPLE_FRAME_SECTIONS
  114. segT cur_seg;
  115. #endif
  116. symbolS *start_address;
  117. symbolS *end_address;
  118. struct cfi_insn_data *data;
  119. struct cfi_insn_data **last;
  120. unsigned char per_encoding;
  121. unsigned char lsda_encoding;
  122. int personality_id;
  123. expressionS personality;
  124. expressionS lsda;
  125. unsigned int return_column;
  126. unsigned int signal_frame;
  127. #if MULTIPLE_FRAME_SECTIONS
  128. int handled;
  129. #endif
  130. int eh_header_type;
  131. /* Compact unwinding opcodes, not including the PR byte or LSDA. */
  132. int eh_data_size;
  133. bfd_byte *eh_data;
  134. /* For out of line tables and FDEs. */
  135. symbolS *eh_loc;
  136. int sections;
  137. };
  138. /* The list of all FDEs that have been collected. */
  139. extern struct fde_entry *all_fde_data;
  140. /* Fake CFI type; outside the byte range of any real CFI insn. */
  141. #define CFI_adjust_cfa_offset 0x100
  142. #define CFI_return_column 0x101
  143. #define CFI_rel_offset 0x102
  144. #define CFI_escape 0x103
  145. #define CFI_signal_frame 0x104
  146. #define CFI_val_encoded_addr 0x105
  147. #define CFI_label 0x106
  148. /* By default emit .eh_frame only, not .debug_frame. */
  149. #define CFI_EMIT_eh_frame (1 << 0)
  150. #define CFI_EMIT_debug_frame (1 << 1)
  151. #define CFI_EMIT_target (1 << 2)
  152. #define CFI_EMIT_eh_frame_compact (1 << 3)
  153. #endif /* DW2GENCFI_H */