dwarf-eh.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. This file is part of libunwind.
  5. Permission is hereby granted, free of charge, to any person obtaining
  6. a copy of this software and associated documentation files (the
  7. "Software"), to deal in the Software without restriction, including
  8. without limitation the rights to use, copy, modify, merge, publish,
  9. distribute, sublicense, and/or sell copies of the Software, and to
  10. permit persons to whom the Software is furnished to do so, subject to
  11. the following conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  21. #ifndef dwarf_eh_h
  22. #define dwarf_eh_h
  23. #include "dwarf.h"
  24. /* This header file defines the format of a DWARF exception-header
  25. section (.eh_frame_hdr, pointed to by program-header
  26. PT_GNU_EH_FRAME). The exception-header is self-describing in the
  27. sense that the format of the addresses contained in it is expressed
  28. as a one-byte type-descriptor called a "pointer-encoding" (PE).
  29. The exception header encodes the address of the .eh_frame section
  30. and optionally contains a binary search table for the
  31. Frame Descriptor Entries (FDEs) in the .eh_frame. The contents of
  32. .eh_frame has the format described by the DWARF v3 standard
  33. (http://www.eagercon.com/dwarf/dwarf3std.htm), except that code
  34. addresses may be encoded in different ways. Also, .eh_frame has
  35. augmentations that allow encoding a language-specific data-area
  36. (LSDA) pointer and a pointer to a personality-routine.
  37. Details:
  38. The Common Information Entry (CIE) associated with an FDE may
  39. contain an augmentation string. Each character in this string has
  40. a specific meaning and either one or two associated operands. The
  41. operands are stored in an augmentation body which appears right
  42. after the "return_address_register" member and before the
  43. "initial_instructions" member. The operands appear in the order
  44. in which the characters appear in the string. For example, if the
  45. augmentation string is "zL", the operand for 'z' would be first in
  46. the augmentation body and the operand for 'L' would be second.
  47. The following characters are supported for the CIE augmentation
  48. string:
  49. 'z': The operand for this character is a uleb128 value that gives the
  50. length of the CIE augmentation body, not counting the length
  51. of the uleb128 operand itself. If present, this code must
  52. appear as the first character in the augmentation body.
  53. 'L': Indicates that the FDE's augmentation body contains an LSDA
  54. pointer. The operand for this character is a single byte
  55. that specifies the pointer-encoding (PE) that is used for
  56. the LSDA pointer.
  57. 'R': Indicates that the code-pointers (FDE members
  58. "initial_location" and "address_range" and the operand for
  59. DW_CFA_set_loc) in the FDE have a non-default encoding. The
  60. operand for this character is a single byte that specifies
  61. the pointer-encoding (PE) that is used for the
  62. code-pointers. Note: the "address_range" member is always
  63. encoded as an absolute value. Apart from that, the specified
  64. FDE pointer-encoding applies.
  65. 'P': Indicates the presence of a personality routine (handler).
  66. The first operand for this character specifies the
  67. pointer-encoding (PE) that is used for the second operand,
  68. which specifies the address of the personality routine.
  69. If the augmentation string contains any other characters, the
  70. remainder of the augmentation string should be ignored.
  71. Furthermore, if the size of the augmentation body is unknown
  72. (i.e., 'z' is not the first character of the augmentation string),
  73. then the entire CIE as well all associated FDEs must be ignored.
  74. A Frame Descriptor Entries (FDE) may contain an augmentation body
  75. which, if present, appears right after the "address_range" member
  76. and before the "instructions" member. The contents of this body
  77. is implicitly defined by the augmentation string of the associated
  78. CIE. The meaning of the characters in the CIE's augmentation
  79. string as far as FDEs are concerned is as follows:
  80. 'z': The first operand in the FDE's augmentation body specifies
  81. the total length of the augmentation body as a uleb128 (not
  82. counting the length of the uleb128 operand itself).
  83. 'L': The operand for this character is an LSDA pointer, encoded
  84. in the format specified by the corresponding operand in the
  85. CIE's augmentation body.
  86. */
  87. #define DW_EH_VERSION 1 /* The version we're implementing */
  88. struct dwarf_eh_frame_hdr
  89. {
  90. unsigned char version;
  91. unsigned char eh_frame_ptr_enc;
  92. unsigned char fde_count_enc;
  93. unsigned char table_enc;
  94. /* The rest of the header is variable-length and consists of the
  95. following members:
  96. encoded_t eh_frame_ptr;
  97. encoded_t fde_count;
  98. struct
  99. {
  100. encoded_t start_ip; // first address covered by this FDE
  101. encoded_t fde_addr; // address of the FDE
  102. }
  103. binary_search_table[fde_count]; */
  104. };
  105. #endif /* dwarf_eh_h */