xref: /illumos-gate/usr/src/common/core/core_shstrtab.h (revision 8e458de0baeb1fee50643403223bc7e909a48464)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
14  * Use is subject to license terms.
15  */
16 
17 /*
18  * Copyright 2021 Oxide Computer Company
19  */
20 
21 #ifndef _CORE_SHSTRTAB_H
22 #define	_CORE_SHSTRTAB_H
23 
24 /*
25  * This header contains common definitions that are used to generate a
26  * shstrtab_t for core files. This is used by libproc and the kernel to generate
27  * core files in a similar way.
28  */
29 
30 #include <sys/list.h>
31 #include <sys/stdint.h>
32 #include <sys/elf.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 typedef enum {
39 	STR_NONE,
40 	STR_CTF,
41 	STR_SYMTAB,
42 	STR_DYNSYM,
43 	STR_STRTAB,
44 	STR_DYNSTR,
45 	STR_SHSTRTAB,
46 	STR_NUM
47 } shstrtype_t;
48 
49 extern const char *shstrtab_data[STR_NUM];
50 
51 typedef struct shstrtab_ent {
52 	list_node_t	sste_link;
53 	char		*sste_name;
54 	size_t		sste_len;
55 	uint32_t	sste_offset;
56 } shstrtab_ent_t;
57 
58 typedef struct shstrtab {
59 	list_t		sst_names;
60 	uint32_t	sst_len;
61 } shstrtab_t;
62 
63 extern boolean_t shstrtab_init(shstrtab_t *s);
64 extern boolean_t shstrtab_ndx(shstrtab_t *, const char *, Elf32_Word *);
65 extern void shstrtab_fini(shstrtab_t *);
66 extern size_t shstrtab_size(const shstrtab_t *);
67 extern void shstrtab_dump(shstrtab_t *, void *);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif /* _CORE_SHSTRTAB_H */
74