Dump string table if "-s" is given
[ctfdump/.git] / ctf.h
CommitLineData
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
21struct 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
37struct ctf_lblent {
38 unsigned int ctl_label;
39 unsigned int ctl_typeidx;
40};
41
42struct 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
53struct ctf_array {
54 unsigned short cta_contents;
55 unsigned short cta_index;
56 unsigned int cta_nelems;
57};
58
59struct ctf_member {
60 unsigned int ctm_name;
61 unsigned short ctm_type;
62 unsigned short ctm_offset;
63};
64
65struct ctf_lmember {
66 struct ctf_member _ctlm_member;
67#define ctlm_name _ctlm_member.ctm_name
68#define ctlm_type _ctlm_member.ctlm_type
69#define ctlm_pad0 _ctlm_member.ctm_offset
70 unsigned int ctlm_offsethi;
71 unsigned int ctlm_offsetlo;
72};
73
74#define CTF_LSTRUCT_THRESH 8192
75
76struct ctf_enum {
77 unsigned int cte_name;
78 int cte_value;
79};
80
81#define CTF_MAGIC 0xcff1
82#define CTF_VERSION 2
83
84#define CTF_MAX_NAME 0x7fffffff
acada86d
MP
85#define CTF_MAX_VLEN 0x03ff
86
f8621c6a
MP
87#define CTF_STRTAB_0 0
88#define CTF_STRTAB_1 1
89
acada86d
MP
90/*
91 * Info macro.
92 */
93#define CTF_INFO_VLEN(i) (((i) & CTF_MAX_VLEN))
94#define CTF_INFO_ISROOT(i) (((i) & 0x0400) >> 10)
95#define CTF_INFO_KIND(i) (((i) & 0xf800) >> 11)
96#define CTF_K_UNKNOWN 0
97#define CTF_K_INTEGER 1
98#define CTF_K_FLOAT 2
99#define CTF_K_POINTER 3
100#define CTF_K_ARRAY 4
101#define CTF_K_FUNCTION 5
102#define CTF_K_STRUCT 6
103#define CTF_K_UNION 7
104#define CTF_K_ENUM 8
105#define CTF_K_FORWARD 9
106#define CTF_K_TYPEDEF 10
107#define CTF_K_VOLATILE 11
108#define CTF_K_CONST 12
109#define CTF_K_RESTRICT 13
110#define CTF_K_MAX 31
111
f8621c6a
MP
112/*
113 * Name reference macro.
114 */
115#define CTF_NAME_STID(n) ((n) >> 31)
116#define CTF_NAME_OFFSET(n) ((n) & CTF_MAX_NAME)