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