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