125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Backend hook signatures internal interface for libebl.
203333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   Copyright (C) 2000-2011, 2013, 2014 Red Hat, Inc.
303333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   This file is part of elfutils.
425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
503333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   This file is free software; you can redistribute it and/or modify
603333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   it under the terms of either
725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
803333823c75a1c1887e923828113a1b0fd12020cElliott Hughes     * the GNU Lesser General Public License as published by the Free
903333823c75a1c1887e923828113a1b0fd12020cElliott Hughes       Software Foundation; either version 3 of the License, or (at
1003333823c75a1c1887e923828113a1b0fd12020cElliott Hughes       your option) any later version
1103333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
1203333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   or
1303333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
1403333823c75a1c1887e923828113a1b0fd12020cElliott Hughes     * the GNU General Public License as published by the Free
1503333823c75a1c1887e923828113a1b0fd12020cElliott Hughes       Software Foundation; either version 2 of the License, or (at
1603333823c75a1c1887e923828113a1b0fd12020cElliott Hughes       your option) any later version
1703333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
1803333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   or both in parallel, as here.
1903333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
2003333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   elfutils is distributed in the hope that it will be useful, but
2125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   WITHOUT ANY WARRANTY; without even the implied warranty of
2225b3c049e70834cf33790a28643ab058b507b35cBen Cheng   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2325b3c049e70834cf33790a28643ab058b507b35cBen Cheng   General Public License for more details.
2425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
2503333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   You should have received copies of the GNU General Public License and
2603333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   the GNU Lesser General Public License along with this program.  If
2703333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   not, see <http://www.gnu.org/licenses/>.  */
2825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
2925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return symbol representaton of object file type.  */
3025b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(object_type_name) (int, char *, size_t);
3125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
3225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return symbolic representation of relocation type.  */
3325b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(reloc_type_name) (int, char *, size_t);
3425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
3525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check relocation type.  */
3625b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(reloc_type_check) (int);
3725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
3825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check if relocation type is for simple absolute relocations.  */
3925b3c049e70834cf33790a28643ab058b507b35cBen ChengElf_Type EBLHOOK(reloc_simple_type) (Ebl *, int);
4025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
4125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check relocation type use.  */
4225b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(reloc_valid_use) (Elf *, int);
4325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
4425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return true if the symbol type is that referencing the GOT.  */
4525b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(gotpc_reloc_check) (Elf *, int);
4625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
4725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return symbolic representation of segment type.  */
4825b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(segment_type_name) (int, char *, size_t);
4925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
5025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return symbolic representation of section type.  */
5125b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(section_type_name) (int, char *, size_t);
5225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
5325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return section name.  */
5425b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(section_name) (int, int, char *, size_t);
5525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
5625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return next machine flag name.  */
5725b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(machine_flag_name) (GElf_Word *);
5825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
5925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check whether machine flags are valid.  */
6025b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(machine_flag_check) (GElf_Word);
6125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
6225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check whether SHF_MASKPROC flag bits are valid.  */
6325b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(machine_section_flag_check) (GElf_Xword);
6425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
6525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check whether the section with the given index, header, and name
6625b3c049e70834cf33790a28643ab058b507b35cBen Cheng   is a special machine section that is valid despite a combination
6725b3c049e70834cf33790a28643ab058b507b35cBen Cheng   of flags or other details that are not generically valid.  */
6825b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(check_special_section) (Ebl *, int,
6925b3c049e70834cf33790a28643ab058b507b35cBen Cheng				     const GElf_Shdr *, const char *);
7025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
7125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return symbolic representation of symbol type.  */
7225b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(symbol_type_name) (int, char *, size_t);
7325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
7425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return symbolic representation of symbol binding.  */
7525b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(symbol_binding_name) (int, char *, size_t);
7625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
7725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return symbolic representation of dynamic tag.  */
7825b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(dynamic_tag_name) (int64_t, char *, size_t);
7925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
8025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check dynamic tag.  */
8125b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(dynamic_tag_check) (int64_t);
8225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
8325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Combine section header flags values.  */
8425b3c049e70834cf33790a28643ab058b507b35cBen ChengGElf_Word EBLHOOK(sh_flags_combine) (GElf_Word, GElf_Word);
8525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
8625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return symbolic representation of OS ABI.  */
8725b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(osabi_name) (int, char *, size_t);
8825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
8925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Name of a note entry type for core files.  */
9025b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(core_note_type_name) (uint32_t, char *, size_t);
9125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
9225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Name of a note entry type for object files.  */
9325b3c049e70834cf33790a28643ab058b507b35cBen Chengconst char *EBLHOOK(object_note_type_name) (const char *, uint32_t,
9425b3c049e70834cf33790a28643ab058b507b35cBen Cheng					    char *, size_t);
9525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
9625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Describe core note format.  */
9725b3c049e70834cf33790a28643ab058b507b35cBen Chengint EBLHOOK(core_note) (const GElf_Nhdr *, const char *,
9825b3c049e70834cf33790a28643ab058b507b35cBen Cheng			GElf_Word *, size_t *, const Ebl_Register_Location **,
9925b3c049e70834cf33790a28643ab058b507b35cBen Cheng			size_t *, const Ebl_Core_Item **);
10025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
10125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Handle object file note.  */
10225b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(object_note) (const char *, uint32_t, uint32_t, const char *);
10325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
10425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check object attribute.  */
10525b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(check_object_attribute) (Ebl *, const char *, int, uint64_t,
10625b3c049e70834cf33790a28643ab058b507b35cBen Cheng				      const char **, const char **);
10725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
10803333823c75a1c1887e923828113a1b0fd12020cElliott Hughes/* Check reloc target section type.  */
10903333823c75a1c1887e923828113a1b0fd12020cElliott Hughesbool EBLHOOK(check_reloc_target_type) (Ebl *, Elf64_Word);
11003333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
11125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Describe auxv element type.  */
11225b3c049e70834cf33790a28643ab058b507b35cBen Chengint EBLHOOK(auxv_info) (GElf_Xword, const char **, const char **);
11325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
11425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check section name for being that of a debug informatino section.  */
11525b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(debugscn_p) (const char *);
11625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
11725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check whether given relocation is a copy relocation.  */
11825b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(copy_reloc_p) (int);
11925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
12025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check whether given relocation is a no-op relocation.  */
12125b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(none_reloc_p) (int);
12225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
12325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check whether given relocation is a relative relocation.  */
12425b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(relative_reloc_p) (int);
12525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
12625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check whether given symbol's value is ok despite normal checks.  */
12725b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(check_special_symbol) (Elf *, GElf_Ehdr *, const GElf_Sym *,
12825b3c049e70834cf33790a28643ab058b507b35cBen Cheng			      const char *, const GElf_Shdr *);
12925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
13025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check whether only valid bits are set on the st_other symbol flag.
13125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   Standard ST_VISIBILITY have already been masked off.  */
13225b3c049e70834cf33790a28643ab058b507b35cBen Chengbool EBLHOOK(check_st_other_bits) (unsigned char st_other);
13325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
13425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Check if backend uses a bss PLT in this file.  */
13503333823c75a1c1887e923828113a1b0fd12020cElliott Hughesbool EBLHOOK(bss_plt_p) (Elf *);
13625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
13725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return location expression to find return value given the
13825b3c049e70834cf33790a28643ab058b507b35cBen Cheng   DW_AT_type DIE of a DW_TAG_subprogram DIE.  */
13925b3c049e70834cf33790a28643ab058b507b35cBen Chengint EBLHOOK(return_value_location) (Dwarf_Die *functypedie,
14025b3c049e70834cf33790a28643ab058b507b35cBen Cheng				    const Dwarf_Op **locp);
14125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
14225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return register name information.  */
14325b3c049e70834cf33790a28643ab058b507b35cBen Chengssize_t EBLHOOK(register_info) (Ebl *ebl,
14425b3c049e70834cf33790a28643ab058b507b35cBen Cheng				int regno, char *name, size_t namelen,
14525b3c049e70834cf33790a28643ab058b507b35cBen Cheng				const char **prefix, const char **setname,
14625b3c049e70834cf33790a28643ab058b507b35cBen Cheng				int *bits, int *type);
14725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
14825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Return system call ABI registers.  */
14925b3c049e70834cf33790a28643ab058b507b35cBen Chengint EBLHOOK(syscall_abi) (Ebl *ebl, int *sp, int *pc,
15025b3c049e70834cf33790a28643ab058b507b35cBen Cheng			  int *callno, int args[6]);
15125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
15225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Disassembler function.  */
15325b3c049e70834cf33790a28643ab058b507b35cBen Chengint EBLHOOK(disasm) (const uint8_t **startp, const uint8_t *end,
15425b3c049e70834cf33790a28643ab058b507b35cBen Cheng		     GElf_Addr addr, const char *fmt, DisasmOutputCB_t outcb,
15525b3c049e70834cf33790a28643ab058b507b35cBen Cheng		     DisasmGetSymCB_t symcb, void *outcbarg, void *symcbarg);
15625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
15703333823c75a1c1887e923828113a1b0fd12020cElliott Hughes/* Supply the machine-specific state of CFI before CIE initial programs.
15803333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   Function returns 0 on success and -1 on error.  */
15925b3c049e70834cf33790a28643ab058b507b35cBen Chengint EBLHOOK(abi_cfi) (Ebl *ebl, Dwarf_CIE *abi_info);
16025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
16103333823c75a1c1887e923828113a1b0fd12020cElliott Hughes/* Fetch process data from live TID and call SETFUNC one or more times.
16203333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   Method should be present only when EBL_FRAME_NREGS > 0, otherwise the
16303333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   backend doesn't support unwinding.  */
16403333823c75a1c1887e923828113a1b0fd12020cElliott Hughesbool EBLHOOK(set_initial_registers_tid) (pid_t tid,
16503333823c75a1c1887e923828113a1b0fd12020cElliott Hughes					 ebl_tid_registers_t *setfunc,
16603333823c75a1c1887e923828113a1b0fd12020cElliott Hughes					 void *arg);
16703333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
16803333823c75a1c1887e923828113a1b0fd12020cElliott Hughes/* Convert *REGNO as is in DWARF to a lower range suitable for
16903333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   Dwarf_Frame->REGS indexing.  */
17003333823c75a1c1887e923828113a1b0fd12020cElliott Hughesbool EBLHOOK(dwarf_to_regno) (Ebl *ebl, unsigned *regno);
17103333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
17203333823c75a1c1887e923828113a1b0fd12020cElliott Hughes/* Optionally modify *PC as fetched from inferior data into valid PC
17303333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   instruction pointer.  */
17403333823c75a1c1887e923828113a1b0fd12020cElliott Hughesvoid EBLHOOK(normalize_pc) (Ebl *ebl, Dwarf_Addr *pc);
17503333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
17603333823c75a1c1887e923828113a1b0fd12020cElliott Hughes/* Get previous frame state for an existing frame state.  Method is called only
17703333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   if unwinder could not find CFI for current PC.  PC is for the
17803333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   existing frame.  SETFUNC sets register in the previous frame.  GETFUNC gets
17903333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   register from the existing frame.  Note that GETFUNC vs. SETFUNC act on
18003333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   a disjunct set of registers.  READFUNC reads memory.  ARG has to be passed
18103333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   for SETFUNC, GETFUNC and READFUNC.  *SIGNAL_FRAMEP is initialized to false,
18203333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   it can be set to true if existing frame is a signal frame.  SIGNAL_FRAMEP is
18303333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   never NULL.  */
18403333823c75a1c1887e923828113a1b0fd12020cElliott Hughesbool EBLHOOK(unwind) (Ebl *ebl, Dwarf_Addr pc, ebl_tid_registers_t *setfunc,
18503333823c75a1c1887e923828113a1b0fd12020cElliott Hughes		      ebl_tid_registers_get_t *getfunc,
18603333823c75a1c1887e923828113a1b0fd12020cElliott Hughes		      ebl_pid_memory_read_t *readfunc, void *arg,
18703333823c75a1c1887e923828113a1b0fd12020cElliott Hughes		      bool *signal_framep);
18803333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
18903333823c75a1c1887e923828113a1b0fd12020cElliott Hughes/* Returns true if the value can be resolved to an address in an
19003333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   allocated section, which will be returned in *ADDR.
19103333823c75a1c1887e923828113a1b0fd12020cElliott Hughes   (e.g. function descriptor resolving)  */
19203333823c75a1c1887e923828113a1b0fd12020cElliott Hughesbool EBLHOOK(resolve_sym_value) (Ebl *ebl, GElf_Addr *addr);
19303333823c75a1c1887e923828113a1b0fd12020cElliott Hughes
19425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Destructor for ELF backend handle.  */
19525b3c049e70834cf33790a28643ab058b507b35cBen Chengvoid EBLHOOK(destr) (struct ebl *);
196