2 SPDX-License-Identifier: GPL-2.0-only
4 Copyright (C) 2019 Arnaldo Carvalho de Melo <acme@redhat.com>
16 #include "elf_symtab.h"
22 struct elf_symtab
*symtab
;
24 struct gobuffer objects
; /* data/variables */
25 struct gobuffer types
;
26 struct gobuffer funcs
;
27 struct strings
*strings
;
36 struct ctf
*ctf__new(const char *filename
, Elf
*elf
);
37 void ctf__delete(struct ctf
*ctf
);
39 bool ctf__ignore_symtab_function(const GElf_Sym
*sym
, const char *sym_name
);
40 bool ctf__ignore_symtab_object(const GElf_Sym
*sym
, const char *sym_name
);
42 int ctf__load(struct ctf
*ctf
);
44 uint16_t ctf__get16(struct ctf
*ctf
, uint16_t *p
);
45 uint32_t ctf__get32(struct ctf
*ctf
, uint32_t *p
);
46 void ctf__put16(struct ctf
*ctf
, uint16_t *p
, uint16_t val
);
47 void ctf__put32(struct ctf
*ctf
, uint32_t *p
, uint32_t val
);
49 void *ctf__get_buffer(struct ctf
*ctf
);
50 size_t ctf__get_size(struct ctf
*ctf
);
52 int ctf__load_symtab(struct ctf
*ctf
);
54 uint32_t ctf__add_base_type(struct ctf
*ctf
, uint32_t name
, uint16_t size
);
55 uint32_t ctf__add_fwd_decl(struct ctf
*ctf
, uint32_t name
);
56 uint32_t ctf__add_short_type(struct ctf
*ctf
, uint16_t kind
, uint16_t type
, uint32_t name
);
57 void ctf__add_short_member(struct ctf
*ctf
, uint32_t name
, uint16_t type
,
58 uint16_t offset
, int64_t *position
);
59 void ctf__add_full_member(struct ctf
*ctf
, uint32_t name
, uint16_t type
,
60 uint64_t offset
, int64_t *position
);
61 uint32_t ctf__add_struct(struct ctf
*ctf
, uint16_t kind
, uint32_t name
,
62 uint64_t size
, uint16_t nr_members
, int64_t *position
);
63 uint32_t ctf__add_array(struct ctf
*ctf
, uint16_t type
, uint16_t index_type
, uint32_t nelems
);
64 void ctf__add_parameter(struct ctf
*ctf
, uint16_t type
, int64_t *position
);
65 uint32_t ctf__add_function_type(struct ctf
*ctf
, uint16_t type
,
66 uint16_t nr_parms
, bool varargs
, int64_t *position
);
67 uint32_t ctf__add_enumeration_type(struct ctf
*ctf
, uint32_t name
, uint16_t size
,
68 uint16_t nr_entries
, int64_t *position
);
69 void ctf__add_enumerator(struct ctf
*ctf
, uint32_t name
, uint32_t value
,
72 void ctf__add_function_parameter(struct ctf
*ctf
, uint16_t type
,
74 int ctf__add_function(struct ctf
*ctf
, uint16_t type
, uint16_t nr_parms
,
75 bool varargs
, int64_t *position
);
77 int ctf__add_object(struct ctf
*ctf
, uint16_t type
);
79 void ctf__set_strings(struct ctf
*ctf
, struct strings
*strings
);
80 int ctf__encode(struct ctf
*ctf
, uint8_t flags
);
82 char *ctf__string(struct ctf
*ctf
, uint32_t ref
);
85 * ctf__for_each_symtab_function - iterate thru all the symtab functions
87 * @ctf: struct ctf instance to iterate
88 * @index: uint32_t index
89 * @sym: GElf_Sym iterator
91 #define ctf__for_each_symtab_function(ctf, index, sym) \
92 elf_symtab__for_each_symbol(ctf->symtab, index, sym) \
93 if (ctf__ignore_symtab_function(&sym, \
100 * ctf__for_each_symtab_object - iterate thru all the symtab objects
102 * @ctf: struct ctf instance to iterate
103 * @index: uint32_t index
104 * @sym: GElf_Sym iterator
106 #define ctf__for_each_symtab_object(ctf, index, sym) \
107 elf_symtab__for_each_symbol(ctf->symtab, index, sym) \
108 if (ctf__ignore_symtab_object(&sym, \
109 elf_sym__name(&sym, \
115 #endif /* _LIBCTF_H */