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