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