blob: f3a0e64a2785a78f38bbf35c5d9ea8764dc4f573 [file] [log] [blame]
Roland McGrathcd60ea82005-11-16 01:57:40 +00001/* Backend hook signatures internal interface for libebl.
Mark Wielaard55cb7df2017-07-20 22:34:29 +02002 Copyright (C) 2000-2011, 2013, 2014, 2016, 2017 Red Hat, Inc.
Mark Wielaardde2ed972012-06-05 17:15:16 +02003 This file is part of elfutils.
Roland McGrathcd60ea82005-11-16 01:57:40 +00004
Mark Wielaardde2ed972012-06-05 17:15:16 +02005 This file is free software; you can redistribute it and/or modify
6 it under the terms of either
Roland McGrathcd60ea82005-11-16 01:57:40 +00007
Mark Wielaardde2ed972012-06-05 17:15:16 +02008 * 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
Ulrich Drepper361df7d2006-04-04 21:38:57 +000021 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
Mark Wielaardde2ed972012-06-05 17:15:16 +020025 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/>. */
Roland McGrathcd60ea82005-11-16 01:57:40 +000028
Roland McGrathcd60ea82005-11-16 01:57:40 +000029/* Return symbolic representation of relocation type. */
30const char *EBLHOOK(reloc_type_name) (int, char *, size_t);
31
32/* Check relocation type. */
33bool EBLHOOK(reloc_type_check) (int);
34
35/* Check if relocation type is for simple absolute relocations. */
36Elf_Type EBLHOOK(reloc_simple_type) (Ebl *, int);
37
38/* Check relocation type use. */
39bool EBLHOOK(reloc_valid_use) (Elf *, int);
40
41/* Return true if the symbol type is that referencing the GOT. */
42bool EBLHOOK(gotpc_reloc_check) (Elf *, int);
43
44/* Return symbolic representation of segment type. */
45const char *EBLHOOK(segment_type_name) (int, char *, size_t);
46
47/* Return symbolic representation of section type. */
48const char *EBLHOOK(section_type_name) (int, char *, size_t);
49
50/* Return section name. */
51const char *EBLHOOK(section_name) (int, int, char *, size_t);
52
53/* Return next machine flag name. */
54const char *EBLHOOK(machine_flag_name) (GElf_Word *);
55
56/* Check whether machine flags are valid. */
57bool EBLHOOK(machine_flag_check) (GElf_Word);
58
Ulrich Drepperaa915fd2007-02-05 07:25:33 +000059/* Check whether SHF_MASKPROC flag bits are valid. */
60bool EBLHOOK(machine_section_flag_check) (GElf_Xword);
61
Roland McGrath13b69602008-04-01 02:30:05 +000062/* Check whether the section with the given index, header, and name
63 is a special machine section that is valid despite a combination
64 of flags or other details that are not generically valid. */
65bool EBLHOOK(check_special_section) (Ebl *, int,
66 const GElf_Shdr *, const char *);
67
Roland McGrathcd60ea82005-11-16 01:57:40 +000068/* Return symbolic representation of symbol type. */
69const char *EBLHOOK(symbol_type_name) (int, char *, size_t);
70
71/* Return symbolic representation of symbol binding. */
72const char *EBLHOOK(symbol_binding_name) (int, char *, size_t);
73
74/* Return symbolic representation of dynamic tag. */
75const char *EBLHOOK(dynamic_tag_name) (int64_t, char *, size_t);
76
77/* Check dynamic tag. */
78bool EBLHOOK(dynamic_tag_check) (int64_t);
79
Roland McGrathcd60ea82005-11-16 01:57:40 +000080/* Return symbolic representation of OS ABI. */
81const char *EBLHOOK(osabi_name) (int, char *, size_t);
82
83/* Name of a note entry type for core files. */
84const char *EBLHOOK(core_note_type_name) (uint32_t, char *, size_t);
85
86/* Name of a note entry type for object files. */
Mark Wielaardbb9d1b42011-04-24 17:53:38 +020087const char *EBLHOOK(object_note_type_name) (const char *, uint32_t,
88 char *, size_t);
Roland McGrathcd60ea82005-11-16 01:57:40 +000089
Roland McGrathcb6d8652007-08-23 08:10:54 +000090/* Describe core note format. */
Roland McGrath0ccbbcd2010-01-04 21:59:07 -080091int EBLHOOK(core_note) (const GElf_Nhdr *, const char *,
92 GElf_Word *, size_t *, const Ebl_Register_Location **,
Roland McGrathcb6d8652007-08-23 08:10:54 +000093 size_t *, const Ebl_Core_Item **);
Roland McGrathcd60ea82005-11-16 01:57:40 +000094
95/* Handle object file note. */
96bool EBLHOOK(object_note) (const char *, uint32_t, uint32_t, const char *);
97
Roland McGrath059c83e2008-02-21 06:19:39 +000098/* Check object attribute. */
99bool EBLHOOK(check_object_attribute) (Ebl *, const char *, int, uint64_t,
100 const char **, const char **);
101
Mark Wielaard028d0ab2014-05-19 16:52:56 +0200102/* Check reloc target section type. */
103bool EBLHOOK(check_reloc_target_type) (Ebl *, Elf64_Word);
104
Roland McGrathcb6d8652007-08-23 08:10:54 +0000105/* Describe auxv element type. */
106int EBLHOOK(auxv_info) (GElf_Xword, const char **, const char **);
107
Roland McGrathcd60ea82005-11-16 01:57:40 +0000108/* Check section name for being that of a debug informatino section. */
109bool EBLHOOK(debugscn_p) (const char *);
110
111/* Check whether given relocation is a copy relocation. */
112bool EBLHOOK(copy_reloc_p) (int);
113
Ulrich Drepper6ca46002006-06-12 22:40:23 +0000114/* Check whether given relocation is a no-op relocation. */
115bool EBLHOOK(none_reloc_p) (int);
116
Ulrich Drepper28ed8952006-07-07 03:43:47 +0000117/* Check whether given relocation is a relative relocation. */
118bool EBLHOOK(relative_reloc_p) (int);
119
Roland McGrathcd60ea82005-11-16 01:57:40 +0000120/* Check whether given symbol's value is ok despite normal checks. */
121bool EBLHOOK(check_special_symbol) (Elf *, GElf_Ehdr *, const GElf_Sym *,
122 const char *, const GElf_Shdr *);
123
Mark Wielaard55cb7df2017-07-20 22:34:29 +0200124/* Check if this is a data marker symbol. e.g. '$d' symbols for ARM. */
125bool EBLHOOK(data_marker_symbol) (const GElf_Sym *sym, const char *sname);
126
Mark Wielaarda062b6b2011-03-10 13:02:32 +0100127/* Check whether only valid bits are set on the st_other symbol flag.
128 Standard ST_VISIBILITY have already been masked off. */
129bool EBLHOOK(check_st_other_bits) (unsigned char st_other);
130
Roland McGrathcd60ea82005-11-16 01:57:40 +0000131/* Check if backend uses a bss PLT in this file. */
Mark Wielaard712c8fa2014-11-22 23:08:48 +0100132bool EBLHOOK(bss_plt_p) (Elf *);
Roland McGrathcd60ea82005-11-16 01:57:40 +0000133
Roland McGrathe47ab762005-11-17 03:16:00 +0000134/* Return location expression to find return value given the
135 DW_AT_type DIE of a DW_TAG_subprogram DIE. */
136int EBLHOOK(return_value_location) (Dwarf_Die *functypedie,
137 const Dwarf_Op **locp);
138
Roland McGrath994b4892005-12-05 22:46:21 +0000139/* Return register name information. */
Roland McGrathc373d852006-10-10 00:25:21 +0000140ssize_t EBLHOOK(register_info) (Ebl *ebl,
Roland McGrath994b4892005-12-05 22:46:21 +0000141 int regno, char *name, size_t namelen,
Roland McGrathc373d852006-10-10 00:25:21 +0000142 const char **prefix, const char **setname,
143 int *bits, int *type);
Roland McGrath994b4892005-12-05 22:46:21 +0000144
Roland McGrath1d8bb252008-08-07 08:39:41 +0000145/* Return system call ABI registers. */
146int EBLHOOK(syscall_abi) (Ebl *ebl, int *sp, int *pc,
147 int *callno, int args[6]);
148
Roland McGrath059c83e2008-02-21 06:19:39 +0000149/* Disassembler function. */
Richard Henderson9a36c922016-06-21 15:10:10 -0700150int EBLHOOK(disasm) (Ebl *ebl, const uint8_t **startp, const uint8_t *end,
Ulrich Drepper3cbdd382008-01-02 17:44:39 +0000151 GElf_Addr addr, const char *fmt, DisasmOutputCB_t outcb,
152 DisasmGetSymCB_t symcb, void *outcbarg, void *symcbarg);
153
Jan Kratochvil0631d1f2012-10-12 20:43:21 +0200154/* Supply the machine-specific state of CFI before CIE initial programs.
155 Function returns 0 on success and -1 on error. */
Roland McGrath3c84db32009-06-24 17:41:40 -0700156int EBLHOOK(abi_cfi) (Ebl *ebl, Dwarf_CIE *abi_info);
Roland McGrath994b4892005-12-05 22:46:21 +0000157
Jan Kratochvil0b867462013-05-30 14:37:38 +0200158/* Fetch process data from live TID and call SETFUNC one or more times.
159 Method should be present only when EBL_FRAME_NREGS > 0, otherwise the
160 backend doesn't support unwinding. */
161bool EBLHOOK(set_initial_registers_tid) (pid_t tid,
162 ebl_tid_registers_t *setfunc,
163 void *arg);
164
Jan Kratochvil5cbf42a2013-12-15 18:56:17 +0100165/* Convert *REGNO as is in DWARF to a lower range suitable for
166 Dwarf_Frame->REGS indexing. */
167bool EBLHOOK(dwarf_to_regno) (Ebl *ebl, unsigned *regno);
168
Jan Kratochvilc6a41482013-12-17 18:49:54 +0100169/* Optionally modify *PC as fetched from inferior data into valid PC
170 instruction pointer. */
171void EBLHOOK(normalize_pc) (Ebl *ebl, Dwarf_Addr *pc);
172
173/* Get previous frame state for an existing frame state. Method is called only
174 if unwinder could not find CFI for current PC. PC is for the
175 existing frame. SETFUNC sets register in the previous frame. GETFUNC gets
176 register from the existing frame. Note that GETFUNC vs. SETFUNC act on
177 a disjunct set of registers. READFUNC reads memory. ARG has to be passed
178 for SETFUNC, GETFUNC and READFUNC. *SIGNAL_FRAMEP is initialized to false,
179 it can be set to true if existing frame is a signal frame. SIGNAL_FRAMEP is
180 never NULL. */
181bool EBLHOOK(unwind) (Ebl *ebl, Dwarf_Addr pc, ebl_tid_registers_t *setfunc,
182 ebl_tid_registers_get_t *getfunc,
183 ebl_pid_memory_read_t *readfunc, void *arg,
184 bool *signal_framep);
185
Mark Wielaard159ac522013-12-18 11:05:54 +0100186/* Returns true if the value can be resolved to an address in an
Mark Wielaardc1c1c062014-06-14 17:15:37 +0200187 allocated section, which will be returned in *ADDR.
Mark Wielaard159ac522013-12-18 11:05:54 +0100188 (e.g. function descriptor resolving) */
189bool EBLHOOK(resolve_sym_value) (Ebl *ebl, GElf_Addr *addr);
190
Roland McGrathcd60ea82005-11-16 01:57:40 +0000191/* Destructor for ELF backend handle. */
192void EBLHOOK(destr) (struct ebl *);