2 * Copyright (c) 2016 Martin Pieuchot <mpi@openbsd.org>
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.
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.
18 * CTF ``Compact ANSI-C Type Format'' ABI header file.
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;
35 #define CTF_F_COMPRESS (1 << 0) /* zlib compression */
38 unsigned int ctl_label;
39 unsigned int ctl_typeidx;
43 unsigned int cts_name;
44 unsigned short cts_info;
49 #define cts_size _ST._size
50 #define cts_type _ST._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;
64 unsigned short cta_contents;
65 unsigned short cta_index;
66 unsigned int cta_nelems;
70 unsigned int ctm_name;
71 unsigned short ctm_type;
72 unsigned short ctm_offset;
76 struct ctf_member _ctlm_member;
77 #define ctlm_name _ctlm_member.ctm_name
78 #define ctlm_type _ctlm_member.ctm_type
79 #define ctlm_pad0 _ctlm_member.ctm_offset
80 unsigned int ctlm_offsethi;
81 unsigned int ctlm_offsetlo;
84 #define CTF_LSTRUCT_THRESH 8192
87 unsigned int cte_name;
91 #define CTF_MAGIC 0xcff1
94 #define CTF_MAX_NAME 0x7fffffff
95 #define CTF_MAX_VLEN 0x03ff
96 #define CTF_MAX_SIZE 0xfffe
98 #define CTF_STRTAB_0 0
99 #define CTF_STRTAB_1 1
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
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
124 * Integer/Float Encoding macro.
126 #define _CTF_ENCODING(e) (((e) & 0xff000000) >> 24)
127 #define _CTF_OFFSET(e) (((e) & 0x00ff0000) >> 16)
128 #define _CTF_BITS(e) (((e) & 0x0000ffff))
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)
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)
155 * Name reference macro.
157 #define CTF_NAME_STID(n) ((n) >> 31)
158 #define CTF_NAME_OFFSET(n) ((n) & CTF_MAX_NAME)
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)
171 #define CTF_LMEM_OFFSET(m) \
172 (((uint64_t)(m)->ctlm_offsethi) << 32 | (m)->ctlm_offsetlo)