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