1da0c48c4Sopenharmony_ci/* Internal definitions for interface for libebl. 2da0c48c4Sopenharmony_ci Copyright (C) 2000-2009, 2013, 2014 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#ifndef _LIBEBLP_H 30da0c48c4Sopenharmony_ci#define _LIBEBLP_H 1 31da0c48c4Sopenharmony_ci 32da0c48c4Sopenharmony_ci#include <gelf.h> 33da0c48c4Sopenharmony_ci#include <libasm.h> 34da0c48c4Sopenharmony_ci#include <libebl.h> 35da0c48c4Sopenharmony_ci 36da0c48c4Sopenharmony_ci 37da0c48c4Sopenharmony_ci/* Backend handle. */ 38da0c48c4Sopenharmony_cistruct ebl 39da0c48c4Sopenharmony_ci{ 40da0c48c4Sopenharmony_ci /* Emulation name. */ 41da0c48c4Sopenharmony_ci const char *emulation; 42da0c48c4Sopenharmony_ci 43da0c48c4Sopenharmony_ci /* ELF machine, class, and data encoding. */ 44da0c48c4Sopenharmony_ci uint_fast16_t machine; 45da0c48c4Sopenharmony_ci uint_fast8_t class; 46da0c48c4Sopenharmony_ci uint_fast8_t data; 47da0c48c4Sopenharmony_ci 48da0c48c4Sopenharmony_ci /* The libelf handle (if known). */ 49da0c48c4Sopenharmony_ci Elf *elf; 50da0c48c4Sopenharmony_ci 51da0c48c4Sopenharmony_ci /* See ebl-hooks.h for the declarations of the hook functions. */ 52da0c48c4Sopenharmony_ci# define EBLHOOK(name) (*name) 53da0c48c4Sopenharmony_ci# include "ebl-hooks.h" 54da0c48c4Sopenharmony_ci# undef EBLHOOK 55da0c48c4Sopenharmony_ci 56da0c48c4Sopenharmony_ci /* Size of entry in Sysv-style hash table. */ 57da0c48c4Sopenharmony_ci int sysvhash_entrysize; 58da0c48c4Sopenharmony_ci 59da0c48c4Sopenharmony_ci /* Number of registers to allocate for ebl_set_initial_registers_tid. 60da0c48c4Sopenharmony_ci Ebl architecture can unwind iff FRAME_NREGS > 0. */ 61da0c48c4Sopenharmony_ci size_t frame_nregs; 62da0c48c4Sopenharmony_ci 63da0c48c4Sopenharmony_ci /* Offset to apply to the value of the return_address_register, as 64da0c48c4Sopenharmony_ci fetched from a Dwarf CFI. This is used by some backends, where 65da0c48c4Sopenharmony_ci the return_address_register actually contains the call 66da0c48c4Sopenharmony_ci address. */ 67da0c48c4Sopenharmony_ci int ra_offset; 68da0c48c4Sopenharmony_ci 69da0c48c4Sopenharmony_ci /* Mask to use to turn a function value into a real function address 70da0c48c4Sopenharmony_ci in case the architecture adds some extra non-address bits to it. 71da0c48c4Sopenharmony_ci If not initialized (0) then ebl_func_addr_mask will return ~0, 72da0c48c4Sopenharmony_ci otherwise it should be the actual mask to use. */ 73da0c48c4Sopenharmony_ci GElf_Addr func_addr_mask; 74da0c48c4Sopenharmony_ci 75da0c48c4Sopenharmony_ci /* Function descriptor load address and table as used by 76da0c48c4Sopenharmony_ci ebl_resolve_sym_value if available for this arch. */ 77da0c48c4Sopenharmony_ci GElf_Addr fd_addr; 78da0c48c4Sopenharmony_ci Elf_Data *fd_data; 79da0c48c4Sopenharmony_ci}; 80da0c48c4Sopenharmony_ci 81da0c48c4Sopenharmony_ci 82da0c48c4Sopenharmony_ci/* Type of the initialization functions in the backend modules. 83da0c48c4Sopenharmony_ci The init function returns the given Ebl * or NULL if it couldn't 84da0c48c4Sopenharmony_ci initialize for the given Elf or machine. */ 85da0c48c4Sopenharmony_citypedef Ebl *(*ebl_bhinit_t) (Elf *, GElf_Half, Ebl *); 86da0c48c4Sopenharmony_ci 87da0c48c4Sopenharmony_ci 88da0c48c4Sopenharmony_ci/* LEB128 constant helper macros. */ 89da0c48c4Sopenharmony_ci#define ULEB128_7(x) (BUILD_BUG_ON_ZERO ((x) >= (1U << 7)) + (x)) 90da0c48c4Sopenharmony_ci 91da0c48c4Sopenharmony_ci#define BUILD_BUG_ON_ZERO(x) (sizeof (char [(x) ? -1 : 1]) - 1) 92da0c48c4Sopenharmony_ci 93da0c48c4Sopenharmony_ci#endif /* libeblP.h */ 94