Commit | Line | Data |
---|---|---|
f8621c6a MP |
1 | /* |
2 | * Copyright (c) 2016 Martin Pieuchot <mpi@openbsd.org> | |
3 | * | |
4 | * Permission to use, copy, modify, and distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
17 | /* | |
18 | * CTF ``Compact ANSI-C Type Format'' ABI header file. | |
19 | */ | |
20 | ||
21 | struct ctf_header { | |
22 | unsigned short cth_magic; | |
23 | unsigned char cth_version; | |
24 | unsigned char cth_flags; | |
25 | unsigned int cth_parlabel; | |
26 | unsigned int cth_parname; | |
27 | unsigned int cth_lbloff; | |
28 | unsigned int cth_objtoff; | |
29 | unsigned int cth_funcoff; | |
30 | unsigned int cth_typeoff; | |
31 | unsigned int cth_stroff; | |
32 | unsigned int cth_strlen; | |
33 | }; | |
34 | ||
35 | #define CTF_F_COMPRESS (1 << 0) /* zlib compression */ | |
36 | ||
37 | struct ctf_lblent { | |
38 | unsigned int ctl_label; | |
39 | unsigned int ctl_typeidx; | |
40 | }; | |
41 | ||
42 | struct ctf_stype { | |
43 | unsigned int cts_name; | |
44 | unsigned short cts_info; | |
45 | union { | |
46 | unsigned short _size; | |
47 | unsigned short _type; | |
48 | } _ST; | |
49 | #define cts_size _ST._size | |
50 | #define cts_type _ST._type | |
51 | }; | |
52 | ||
74b86e22 MP |
53 | struct ctf_type { |
54 | struct ctf_stype _ctt_stype; | |
55 | #define ctt_name _ctt_stype.cts_name | |
56 | #define ctt_info _ctt_stype.cts_info | |
57 | #define ctt_size _ctt_stype.cts_size | |
58 | #define ctt_type _ctt_stype.cts_type | |
59 | unsigned int ctt_lsizehi; | |
60 | unsigned int ctt_lsizelo; | |
61 | }; | |
62 | ||
f8621c6a MP |
63 | struct ctf_array { |
64 | unsigned short cta_contents; | |
65 | unsigned short cta_index; | |
66 | unsigned int cta_nelems; | |
67 | }; | |
68 | ||
69 | struct ctf_member { | |
70 | unsigned int ctm_name; | |
71 | unsigned short ctm_type; | |
72 | unsigned short ctm_offset; | |
73 | }; | |
74 | ||
75 | struct ctf_lmember { | |
76 | struct ctf_member _ctlm_member; | |
77 | #define ctlm_name _ctlm_member.ctm_name | |
23543ec6 | 78 | #define ctlm_type _ctlm_member.ctm_type |
f8621c6a MP |
79 | #define ctlm_pad0 _ctlm_member.ctm_offset |
80 | unsigned int ctlm_offsethi; | |
81 | unsigned int ctlm_offsetlo; | |
82 | }; | |
83 | ||
84 | #define CTF_LSTRUCT_THRESH 8192 | |
85 | ||
86 | struct ctf_enum { | |
87 | unsigned int cte_name; | |
88 | int cte_value; | |
89 | }; | |
90 | ||
91 | #define CTF_MAGIC 0xcff1 | |
92 | #define CTF_VERSION 2 | |
93 | ||
94 | #define CTF_MAX_NAME 0x7fffffff | |
acada86d | 95 | #define CTF_MAX_VLEN 0x03ff |
74b86e22 | 96 | #define CTF_MAX_SIZE 0xfffe |
acada86d | 97 | |
f8621c6a MP |
98 | #define CTF_STRTAB_0 0 |
99 | #define CTF_STRTAB_1 1 | |
100 | ||
acada86d MP |
101 | /* |
102 | * Info macro. | |
103 | */ | |
104 | #define CTF_INFO_VLEN(i) (((i) & CTF_MAX_VLEN)) | |
105 | #define CTF_INFO_ISROOT(i) (((i) & 0x0400) >> 10) | |
106 | #define CTF_INFO_KIND(i) (((i) & 0xf800) >> 11) | |
107 | #define CTF_K_UNKNOWN 0 | |
108 | #define CTF_K_INTEGER 1 | |
109 | #define CTF_K_FLOAT 2 | |
110 | #define CTF_K_POINTER 3 | |
111 | #define CTF_K_ARRAY 4 | |
112 | #define CTF_K_FUNCTION 5 | |
113 | #define CTF_K_STRUCT 6 | |
114 | #define CTF_K_UNION 7 | |
115 | #define CTF_K_ENUM 8 | |
116 | #define CTF_K_FORWARD 9 | |
117 | #define CTF_K_TYPEDEF 10 | |
118 | #define CTF_K_VOLATILE 11 | |
119 | #define CTF_K_CONST 12 | |
120 | #define CTF_K_RESTRICT 13 | |
121 | #define CTF_K_MAX 31 | |
122 | ||
23543ec6 MP |
123 | /* |
124 | * Integer/Float Encoding macro. | |
125 | */ | |
126 | #define _CTF_ENCODING(e) (((e) & 0xff000000) >> 24) | |
127 | #define _CTF_OFFSET(e) (((e) & 0x00ff0000) >> 16) | |
128 | #define _CTF_BITS(e) (((e) & 0x0000ffff)) | |
129 | ||
130 | #define CTF_INT_ENCODING(e) _CTF_ENCODING(e) | |
131 | #define CTF_INT_SIGNED (1 << 0) | |
132 | #define CTF_INT_CHAR (1 << 1) | |
133 | #define CTF_INT_BOOL (1 << 2) | |
134 | #define CTF_INT_VARARGS (1 << 3) | |
135 | #define CTF_INT_OFFSET(e) _CTF_OFFSET(e) | |
136 | #define CTF_INT_BITS(e) _CTF_BITS(e) | |
137 | ||
138 | #define CTF_FP_ENCODING(e) _CTF_ENCODING(e) | |
139 | #define CTF_FP_SINGLE 1 | |
140 | #define CTF_FP_DOUBLE 2 | |
141 | #define CTF_FP_CPLX 3 | |
142 | #define CTF_FP_DCPLX 4 | |
143 | #define CTF_FP_LDCPLX 5 | |
144 | #define CTF_FP_LDOUBLE 6 | |
145 | #define CTF_FP_INTRVL 7 | |
146 | #define CTF_FP_DINTRVL 8 | |
147 | #define CTF_FP_LDINTRVL 9 | |
148 | #define CTF_FP_IMAGRY 10 | |
149 | #define CTF_FP_DIMAGRY 11 | |
150 | #define CTF_FP_LDIMAGRY 12 | |
151 | #define CTF_FP_OFFSET(e) _CTF_OFFSET(e) | |
152 | #define CTF_FP_BITS(e) _CTF_BITS(e) | |
153 | ||
f8621c6a MP |
154 | /* |
155 | * Name reference macro. | |
156 | */ | |
157 | #define CTF_NAME_STID(n) ((n) >> 31) | |
158 | #define CTF_NAME_OFFSET(n) ((n) & CTF_MAX_NAME) | |
74b86e22 MP |
159 | |
160 | /* | |
161 | * Type macro. | |
162 | */ | |
163 | #define CTF_SIZE_TO_LSIZE_HI(s) ((uint32_t)((uint64_t)(s) >> 32)) | |
164 | #define CTF_SIZE_TO_LSIZE_LO(s) ((uint32_t)(s)) | |
165 | #define CTF_TYPE_LSIZE(t) \ | |
166 | (((uint64_t)(t)->ctt_lsizehi) << 32 | (t)->ctt_lsizelo) | |
23543ec6 MP |
167 | |
168 | /* | |
169 | * Member macro. | |
170 | */ | |
171 | #define CTF_LMEM_OFFSET(m) \ | |
172 | (((uint64_t)(m)->ctlm_offsethi) << 32 | (m)->ctlm_offsetlo) |