xref: /third_party/elfutils/libebl/ebl-hooks.h (revision da0c48c4)
1da0c48c4Sopenharmony_ci/* Backend hook signatures internal interface for libebl.
2da0c48c4Sopenharmony_ci   Copyright (C) 2000-2011, 2013, 2014, 2016, 2017 Red Hat, Inc.
3da0c48c4Sopenharmony_ci   This file is part of elfutils.
4da0c48c4Sopenharmony_ci
5da0c48c4Sopenharmony_ci   This file is free software; you can redistribute it and/or modify
6da0c48c4Sopenharmony_ci   it under the terms of either
7da0c48c4Sopenharmony_ci
8da0c48c4Sopenharmony_ci     * the GNU Lesser General Public License as published by the Free
9da0c48c4Sopenharmony_ci       Software Foundation; either version 3 of the License, or (at
10da0c48c4Sopenharmony_ci       your option) any later version
11da0c48c4Sopenharmony_ci
12da0c48c4Sopenharmony_ci   or
13da0c48c4Sopenharmony_ci
14da0c48c4Sopenharmony_ci     * the GNU General Public License as published by the Free
15da0c48c4Sopenharmony_ci       Software Foundation; either version 2 of the License, or (at
16da0c48c4Sopenharmony_ci       your option) any later version
17da0c48c4Sopenharmony_ci
18da0c48c4Sopenharmony_ci   or both in parallel, as here.
19da0c48c4Sopenharmony_ci
20da0c48c4Sopenharmony_ci   elfutils is distributed in the hope that it will be useful, but
21da0c48c4Sopenharmony_ci   WITHOUT ANY WARRANTY; without even the implied warranty of
22da0c48c4Sopenharmony_ci   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23da0c48c4Sopenharmony_ci   General Public License for more details.
24da0c48c4Sopenharmony_ci
25da0c48c4Sopenharmony_ci   You should have received copies of the GNU General Public License and
26da0c48c4Sopenharmony_ci   the GNU Lesser General Public License along with this program.  If
27da0c48c4Sopenharmony_ci   not, see <http://www.gnu.org/licenses/>.  */
28da0c48c4Sopenharmony_ci
29da0c48c4Sopenharmony_ci/* Return symbolic representation of relocation type.  */
30da0c48c4Sopenharmony_ciconst char *EBLHOOK(reloc_type_name) (int, char *, size_t);
31da0c48c4Sopenharmony_ci
32da0c48c4Sopenharmony_ci/* Check relocation type.  */
33da0c48c4Sopenharmony_cibool EBLHOOK(reloc_type_check) (int);
34da0c48c4Sopenharmony_ci
35da0c48c4Sopenharmony_ci/* Check if relocation type is for simple absolute relocations.  */
36da0c48c4Sopenharmony_ciElf_Type EBLHOOK(reloc_simple_type) (Ebl *, int, int *);
37da0c48c4Sopenharmony_ci
38da0c48c4Sopenharmony_ci/* Check relocation type use.  */
39da0c48c4Sopenharmony_cibool EBLHOOK(reloc_valid_use) (Elf *, int);
40da0c48c4Sopenharmony_ci
41da0c48c4Sopenharmony_ci/* Return true if the symbol type is that referencing the GOT.  */
42da0c48c4Sopenharmony_cibool EBLHOOK(gotpc_reloc_check) (Elf *, int);
43da0c48c4Sopenharmony_ci
44da0c48c4Sopenharmony_ci/* Return symbolic representation of segment type.  */
45da0c48c4Sopenharmony_ciconst char *EBLHOOK(segment_type_name) (int, char *, size_t);
46da0c48c4Sopenharmony_ci
47da0c48c4Sopenharmony_ci/* Return symbolic representation of section type.  */
48da0c48c4Sopenharmony_ciconst char *EBLHOOK(section_type_name) (int, char *, size_t);
49da0c48c4Sopenharmony_ci
50da0c48c4Sopenharmony_ci/* Return section name.  */
51da0c48c4Sopenharmony_ciconst char *EBLHOOK(section_name) (int, int, char *, size_t);
52da0c48c4Sopenharmony_ci
53da0c48c4Sopenharmony_ci/* Return next machine flag name.  */
54da0c48c4Sopenharmony_ciconst char *EBLHOOK(machine_flag_name) (GElf_Word, GElf_Word *);
55da0c48c4Sopenharmony_ci
56da0c48c4Sopenharmony_ci/* Check whether machine flags are valid.  */
57da0c48c4Sopenharmony_cibool EBLHOOK(machine_flag_check) (GElf_Word);
58da0c48c4Sopenharmony_ci
59da0c48c4Sopenharmony_ci/* Check whether SHF_MASKPROC flag bits are valid.  */
60da0c48c4Sopenharmony_cibool EBLHOOK(machine_section_flag_check) (GElf_Xword);
61da0c48c4Sopenharmony_ci
62da0c48c4Sopenharmony_ci/* Check whether the section with the given index, header, and name
63da0c48c4Sopenharmony_ci   is a special machine section that is valid despite a combination
64da0c48c4Sopenharmony_ci   of flags or other details that are not generically valid.  */
65da0c48c4Sopenharmony_cibool EBLHOOK(check_special_section) (Ebl *, int,
66da0c48c4Sopenharmony_ci				     const GElf_Shdr *, const char *);
67da0c48c4Sopenharmony_ci
68da0c48c4Sopenharmony_ci/* Return symbolic representation of symbol type.  */
69da0c48c4Sopenharmony_ciconst char *EBLHOOK(symbol_type_name) (int, char *, size_t);
70da0c48c4Sopenharmony_ci
71da0c48c4Sopenharmony_ci/* Return symbolic representation of symbol binding.  */
72da0c48c4Sopenharmony_ciconst char *EBLHOOK(symbol_binding_name) (int, char *, size_t);
73da0c48c4Sopenharmony_ci
74da0c48c4Sopenharmony_ci/* Return symbolic representation of dynamic tag.  */
75da0c48c4Sopenharmony_ciconst char *EBLHOOK(dynamic_tag_name) (int64_t, char *, size_t);
76da0c48c4Sopenharmony_ci
77da0c48c4Sopenharmony_ci/* Check dynamic tag.  */
78da0c48c4Sopenharmony_cibool EBLHOOK(dynamic_tag_check) (int64_t);
79da0c48c4Sopenharmony_ci
80da0c48c4Sopenharmony_ci/* Return symbolic representation of OS ABI.  */
81da0c48c4Sopenharmony_ciconst char *EBLHOOK(osabi_name) (int, char *, size_t);
82da0c48c4Sopenharmony_ci
83da0c48c4Sopenharmony_ci/* Name of a note entry type for core files.  */
84da0c48c4Sopenharmony_ciconst char *EBLHOOK(core_note_type_name) (uint32_t, char *, size_t);
85da0c48c4Sopenharmony_ci
86da0c48c4Sopenharmony_ci/* Name of a note entry type for object files.  */
87da0c48c4Sopenharmony_ciconst char *EBLHOOK(object_note_type_name) (const char *, uint32_t,
88da0c48c4Sopenharmony_ci					    char *, size_t);
89da0c48c4Sopenharmony_ci
90da0c48c4Sopenharmony_ci/* Describe core note format.  */
91da0c48c4Sopenharmony_ciint EBLHOOK(core_note) (const GElf_Nhdr *, const char *,
92da0c48c4Sopenharmony_ci			GElf_Word *, size_t *, const Ebl_Register_Location **,
93da0c48c4Sopenharmony_ci			size_t *, const Ebl_Core_Item **);
94da0c48c4Sopenharmony_ci
95da0c48c4Sopenharmony_ci/* Handle object file note.  */
96da0c48c4Sopenharmony_cibool EBLHOOK(object_note) (const char *, uint32_t, uint32_t, const char *);
97da0c48c4Sopenharmony_ci
98da0c48c4Sopenharmony_ci/* Check object attribute.  */
99da0c48c4Sopenharmony_cibool EBLHOOK(check_object_attribute) (Ebl *, const char *, int, uint64_t,
100da0c48c4Sopenharmony_ci				      const char **, const char **);
101da0c48c4Sopenharmony_ci
102da0c48c4Sopenharmony_ci/* Check reloc target section type.  */
103da0c48c4Sopenharmony_cibool EBLHOOK(check_reloc_target_type) (Ebl *, Elf64_Word);
104da0c48c4Sopenharmony_ci
105da0c48c4Sopenharmony_ci/* Describe auxv element type.  */
106da0c48c4Sopenharmony_ciint EBLHOOK(auxv_info) (GElf_Xword, const char **, const char **);
107da0c48c4Sopenharmony_ci
108da0c48c4Sopenharmony_ci/* Check section name for being that of a debug informatino section.  */
109da0c48c4Sopenharmony_cibool EBLHOOK(debugscn_p) (const char *);
110da0c48c4Sopenharmony_ci
111da0c48c4Sopenharmony_ci/* Check whether given relocation is a copy relocation.  */
112da0c48c4Sopenharmony_cibool EBLHOOK(copy_reloc_p) (int);
113da0c48c4Sopenharmony_ci
114da0c48c4Sopenharmony_ci/* Check whether given relocation is a no-op relocation.  */
115da0c48c4Sopenharmony_cibool EBLHOOK(none_reloc_p) (int);
116da0c48c4Sopenharmony_ci
117da0c48c4Sopenharmony_ci/* Check whether given relocation is a relative relocation.  */
118da0c48c4Sopenharmony_cibool EBLHOOK(relative_reloc_p) (int);
119da0c48c4Sopenharmony_ci
120da0c48c4Sopenharmony_ci/* Check whether given symbol's value is ok despite normal checks.  */
121da0c48c4Sopenharmony_cibool EBLHOOK(check_special_symbol) (Elf *, const GElf_Sym *,
122da0c48c4Sopenharmony_ci			      const char *, const GElf_Shdr *);
123da0c48c4Sopenharmony_ci
124da0c48c4Sopenharmony_ci/* Check if this is a data marker symbol.  e.g. '$d' symbols for ARM.  */
125da0c48c4Sopenharmony_cibool EBLHOOK(data_marker_symbol) (const GElf_Sym *sym, const char *sname);
126da0c48c4Sopenharmony_ci
127da0c48c4Sopenharmony_ci/* Check whether only valid bits are set on the st_other symbol flag.
128da0c48c4Sopenharmony_ci   Standard ST_VISIBILITY have already been masked off.  */
129da0c48c4Sopenharmony_cibool EBLHOOK(check_st_other_bits) (unsigned char st_other);
130da0c48c4Sopenharmony_ci
131da0c48c4Sopenharmony_ci/* Check if backend uses a bss PLT in this file.  */
132da0c48c4Sopenharmony_cibool EBLHOOK(bss_plt_p) (Elf *);
133da0c48c4Sopenharmony_ci
134da0c48c4Sopenharmony_ci/* Return location expression to find return value given the
135da0c48c4Sopenharmony_ci   DW_AT_type DIE of a DW_TAG_subprogram DIE.  */
136da0c48c4Sopenharmony_ciint EBLHOOK(return_value_location) (Dwarf_Die *functypedie,
137da0c48c4Sopenharmony_ci				    const Dwarf_Op **locp);
138da0c48c4Sopenharmony_ci
139da0c48c4Sopenharmony_ci/* Return register name information.  */
140da0c48c4Sopenharmony_cissize_t EBLHOOK(register_info) (Ebl *ebl,
141da0c48c4Sopenharmony_ci				int regno, char *name, size_t namelen,
142da0c48c4Sopenharmony_ci				const char **prefix, const char **setname,
143da0c48c4Sopenharmony_ci				int *bits, int *type);
144da0c48c4Sopenharmony_ci
145da0c48c4Sopenharmony_ci/* Disassembler function.  */
146da0c48c4Sopenharmony_ciint EBLHOOK(disasm) (Ebl *ebl, const uint8_t **startp, const uint8_t *end,
147da0c48c4Sopenharmony_ci		     GElf_Addr addr, const char *fmt, DisasmOutputCB_t outcb,
148da0c48c4Sopenharmony_ci		     DisasmGetSymCB_t symcb, void *outcbarg, void *symcbarg);
149da0c48c4Sopenharmony_ci
150da0c48c4Sopenharmony_ci/* Supply the machine-specific state of CFI before CIE initial programs.
151da0c48c4Sopenharmony_ci   Function returns 0 on success and -1 on error.  */
152da0c48c4Sopenharmony_ciint EBLHOOK(abi_cfi) (Ebl *ebl, Dwarf_CIE *abi_info);
153da0c48c4Sopenharmony_ci
154da0c48c4Sopenharmony_ci/* Fetch process data from live TID and call SETFUNC one or more times.
155da0c48c4Sopenharmony_ci   Method should be present only when EBL_FRAME_NREGS > 0, otherwise the
156da0c48c4Sopenharmony_ci   backend doesn't support unwinding.  */
157da0c48c4Sopenharmony_cibool EBLHOOK(set_initial_registers_tid) (pid_t tid,
158da0c48c4Sopenharmony_ci					 ebl_tid_registers_t *setfunc,
159da0c48c4Sopenharmony_ci					 void *arg);
160da0c48c4Sopenharmony_ci
161da0c48c4Sopenharmony_ci/* Convert *REGNO as is in DWARF to a lower range suitable for
162da0c48c4Sopenharmony_ci   Dwarf_Frame->REGS indexing.  */
163da0c48c4Sopenharmony_cibool EBLHOOK(dwarf_to_regno) (Ebl *ebl, unsigned *regno);
164da0c48c4Sopenharmony_ci
165da0c48c4Sopenharmony_ci/* Optionally modify *PC as fetched from inferior data into valid PC
166da0c48c4Sopenharmony_ci   instruction pointer.  */
167da0c48c4Sopenharmony_civoid EBLHOOK(normalize_pc) (Ebl *ebl, Dwarf_Addr *pc);
168da0c48c4Sopenharmony_ci
169da0c48c4Sopenharmony_ci/* Get previous frame state for an existing frame state.  Method is called only
170da0c48c4Sopenharmony_ci   if unwinder could not find CFI for current PC.  PC is for the
171da0c48c4Sopenharmony_ci   existing frame.  SETFUNC sets register in the previous frame.  GETFUNC gets
172da0c48c4Sopenharmony_ci   register from the existing frame.  Note that GETFUNC vs. SETFUNC act on
173da0c48c4Sopenharmony_ci   a disjunct set of registers.  READFUNC reads memory.  ARG has to be passed
174da0c48c4Sopenharmony_ci   for SETFUNC, GETFUNC and READFUNC.  *SIGNAL_FRAMEP is initialized to false,
175da0c48c4Sopenharmony_ci   it can be set to true if existing frame is a signal frame.  SIGNAL_FRAMEP is
176da0c48c4Sopenharmony_ci   never NULL.  */
177da0c48c4Sopenharmony_cibool EBLHOOK(unwind) (Ebl *ebl, Dwarf_Addr pc, ebl_tid_registers_t *setfunc,
178da0c48c4Sopenharmony_ci		      ebl_tid_registers_get_t *getfunc,
179da0c48c4Sopenharmony_ci		      ebl_pid_memory_read_t *readfunc, void *arg,
180da0c48c4Sopenharmony_ci		      bool *signal_framep);
181da0c48c4Sopenharmony_ci
182da0c48c4Sopenharmony_ci/* Returns true if the value can be resolved to an address in an
183da0c48c4Sopenharmony_ci   allocated section, which will be returned in *ADDR.
184da0c48c4Sopenharmony_ci   (e.g. function descriptor resolving)  */
185da0c48c4Sopenharmony_cibool EBLHOOK(resolve_sym_value) (Ebl *ebl, GElf_Addr *addr);
186da0c48c4Sopenharmony_ci
187da0c48c4Sopenharmony_ci/* Destructor for ELF backend handle.  */
188da0c48c4Sopenharmony_civoid EBLHOOK(destr) (struct ebl *);
189