diff options
Diffstat (limited to 'meta/recipes-devtools/elfutils/elfutils-0.161/arm_func_value.patch')
| -rw-r--r-- | meta/recipes-devtools/elfutils/elfutils-0.161/arm_func_value.patch | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.161/arm_func_value.patch b/meta/recipes-devtools/elfutils/elfutils-0.161/arm_func_value.patch new file mode 100644 index 0000000000..eeb2063807 --- /dev/null +++ b/meta/recipes-devtools/elfutils/elfutils-0.161/arm_func_value.patch | |||
| @@ -0,0 +1,166 @@ | |||
| 1 | From: Mark Wielaard <mjw@redhat.com> | ||
| 2 | Date: Sun, 15 Jun 2014 11:30:35 +0200 | ||
| 3 | Subject: libebl: Add sym_func_value hook. | ||
| 4 | |||
| 5 | The ARM EABI says that the zero bit of function symbol st_value indicates | ||
| 6 | whether the symbol points to a THUMB or ARM function. Add a new ebl hook | ||
| 7 | to adjust the st_value in such a case so that we get the actual value that | ||
| 8 | the symbol points to. It isn't easily possible to reuse the existing | ||
| 9 | resolve_sym_value for this purpose, so we end up with another hook that | ||
| 10 | can be used from dwfl_module_getsym and elflint. | ||
| 11 | |||
| 12 | Rebase arm_func_value.patch from 0.159 to 0.160 | ||
| 13 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
| 14 | --- | ||
| 15 | backends/arm_init.c | 1 + | ||
| 16 | backends/arm_symbol.c | 8 ++++++++ | ||
| 17 | libdwfl/dwfl_module_getsym.c | 2 +- | ||
| 18 | libebl/Makefile.am | 3 ++- | ||
| 19 | libebl/ebl-hooks.h | 3 +++ | ||
| 20 | libebl/eblsymfuncval.c | 43 +++++++++++++++++++++++++++++++++++++++++++ | ||
| 21 | libebl/libebl.h | 11 +++++++++++ | ||
| 22 | 7 files changed, 69 insertions(+), 2 deletions(-) | ||
| 23 | create mode 100644 libebl/eblsymfuncval.c | ||
| 24 | |||
| 25 | diff --git a/backends/arm_init.c b/backends/arm_init.c | ||
| 26 | index 8b57d3f..2266829 100644 | ||
| 27 | --- a/backends/arm_init.c | ||
| 28 | +++ b/backends/arm_init.c | ||
| 29 | @@ -78,6 +78,7 @@ arm_init (elf, machine, eh, ehlen) | ||
| 30 | eh->return_value_location = arm_return_value_location_hard; | ||
| 31 | HOOK (eh, abi_cfi); | ||
| 32 | HOOK (eh, check_reloc_target_type); | ||
| 33 | + HOOK (eh, sym_func_value); | ||
| 34 | |||
| 35 | /* We only unwind the core integer registers. */ | ||
| 36 | eh->frame_nregs = 16; | ||
| 37 | diff --git a/backends/arm_symbol.c b/backends/arm_symbol.c | ||
| 38 | index cd467ff..49fca55 100644 | ||
| 39 | --- a/backends/arm_symbol.c | ||
| 40 | +++ b/backends/arm_symbol.c | ||
| 41 | @@ -129,3 +129,11 @@ arm_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)), Elf64_Word sh_ty | ||
| 42 | { | ||
| 43 | return sh_type == SHT_ARM_EXIDX; | ||
| 44 | } | ||
| 45 | + | ||
| 46 | +/* ARM EABI says that the low bit indicates whether the function | ||
| 47 | + symbol value is a THUMB function or not. Mask it off. */ | ||
| 48 | +GElf_Addr | ||
| 49 | +arm_sym_func_value (Ebl *ebl __attribute__ ((unused)), GElf_Addr val) | ||
| 50 | +{ | ||
| 51 | + return val & ~(GElf_Addr)1; | ||
| 52 | +} | ||
| 53 | diff --git a/libdwfl/dwfl_module_getsym.c b/libdwfl/dwfl_module_getsym.c | ||
| 54 | index 42d2b67..fb192d7 100644 | ||
| 55 | --- a/libdwfl/dwfl_module_getsym.c | ||
| 56 | +++ b/libdwfl/dwfl_module_getsym.c | ||
| 57 | @@ -119,7 +119,7 @@ __libdwfl_getsym (Dwfl_Module *mod, int ndx, GElf_Sym *sym, GElf_Addr *addr, | ||
| 58 | descriptors). */ | ||
| 59 | |||
| 60 | char *ident; | ||
| 61 | - GElf_Addr st_value = sym->st_value & ebl_func_addr_mask (mod->ebl); | ||
| 62 | + GElf_Addr st_value = ebl_sym_func_value (mod->ebl, sym->st_value); | ||
| 63 | *resolved = false; | ||
| 64 | if (! adjust_st_value && mod->e_type != ET_REL && alloc | ||
| 65 | && (GELF_ST_TYPE (sym->st_info) == STT_FUNC | ||
| 66 | diff --git a/libebl/Makefile.am b/libebl/Makefile.am | ||
| 67 | index ec4477b..889c21b 100644 | ||
| 68 | --- a/libebl/Makefile.am | ||
| 69 | +++ b/libebl/Makefile.am | ||
| 70 | @@ -55,7 +55,8 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \ | ||
| 71 | eblsysvhashentrysize.c eblauxvinfo.c eblcheckobjattr.c \ | ||
| 72 | ebl_check_special_section.c ebl_syscall_abi.c eblabicfi.c \ | ||
| 73 | eblstother.c eblinitreg.c ebldwarftoregno.c eblnormalizepc.c \ | ||
| 74 | - eblunwind.c eblresolvesym.c eblcheckreloctargettype.c | ||
| 75 | + eblunwind.c eblresolvesym.c eblcheckreloctargettype.c \ | ||
| 76 | + eblsymfuncval.c | ||
| 77 | |||
| 78 | libebl_a_SOURCES = $(gen_SOURCES) | ||
| 79 | |||
| 80 | diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h | ||
| 81 | index e1186f8..160a821 100644 | ||
| 82 | --- a/libebl/ebl-hooks.h | ||
| 83 | +++ b/libebl/ebl-hooks.h | ||
| 84 | @@ -191,5 +191,8 @@ bool EBLHOOK(unwind) (Ebl *ebl, Dwarf_Addr pc, ebl_tid_registers_t *setfunc, | ||
| 85 | (e.g. function descriptor resolving) */ | ||
| 86 | bool EBLHOOK(resolve_sym_value) (Ebl *ebl, GElf_Addr *addr); | ||
| 87 | |||
| 88 | +/* Returns the real value of a symbol function address or offset. */ | ||
| 89 | +GElf_Addr EBLHOOK(sym_func_value) (Ebl *ebl, GElf_Addr val); | ||
| 90 | + | ||
| 91 | /* Destructor for ELF backend handle. */ | ||
| 92 | void EBLHOOK(destr) (struct ebl *); | ||
| 93 | diff --git a/libebl/eblsymfuncval.c b/libebl/eblsymfuncval.c | ||
| 94 | new file mode 100644 | ||
| 95 | index 0000000..c0b322f | ||
| 96 | --- /dev/null | ||
| 97 | +++ b/libebl/eblsymfuncval.c | ||
| 98 | @@ -0,0 +1,43 @@ | ||
| 99 | +/* Turn a symbol function value into a real function address or offset. | ||
| 100 | + Copyright (C) 2014 Red Hat, Inc. | ||
| 101 | + This file is part of elfutils. | ||
| 102 | + | ||
| 103 | + This file is free software; you can redistribute it and/or modify | ||
| 104 | + it under the terms of either | ||
| 105 | + | ||
| 106 | + * the GNU Lesser General Public License as published by the Free | ||
| 107 | + Software Foundation; either version 3 of the License, or (at | ||
| 108 | + your option) any later version | ||
| 109 | + | ||
| 110 | + or | ||
| 111 | + | ||
| 112 | + * the GNU General Public License as published by the Free | ||
| 113 | + Software Foundation; either version 2 of the License, or (at | ||
| 114 | + your option) any later version | ||
| 115 | + | ||
| 116 | + or both in parallel, as here. | ||
| 117 | + | ||
| 118 | + elfutils is distributed in the hope that it will be useful, but | ||
| 119 | + WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 120 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 121 | + General Public License for more details. | ||
| 122 | + | ||
| 123 | + You should have received copies of the GNU General Public License and | ||
| 124 | + the GNU Lesser General Public License along with this program. If | ||
| 125 | + not, see <http://www.gnu.org/licenses/>. */ | ||
| 126 | + | ||
| 127 | +#ifdef HAVE_CONFIG_H | ||
| 128 | +# include <config.h> | ||
| 129 | +#endif | ||
| 130 | + | ||
| 131 | +#include <libeblP.h> | ||
| 132 | +#include <assert.h> | ||
| 133 | + | ||
| 134 | +GElf_Addr | ||
| 135 | +ebl_sym_func_value (Ebl *ebl, GElf_Addr val) | ||
| 136 | +{ | ||
| 137 | + if (ebl == NULL || ebl->sym_func_value == NULL) | ||
| 138 | + return val; | ||
| 139 | + | ||
| 140 | + return ebl->sym_func_value (ebl, val); | ||
| 141 | +} | ||
| 142 | diff --git a/libebl/libebl.h b/libebl/libebl.h | ||
| 143 | index bb993bf..40cf635 100644 | ||
| 144 | --- a/libebl/libebl.h | ||
| 145 | +++ b/libebl/libebl.h | ||
| 146 | @@ -459,6 +459,17 @@ extern bool ebl_unwind (Ebl *ebl, Dwarf_Addr pc, ebl_tid_registers_t *setfunc, | ||
| 147 | extern bool ebl_resolve_sym_value (Ebl *ebl, GElf_Addr *addr) | ||
| 148 | __nonnull_attribute__ (2); | ||
| 149 | |||
| 150 | +/* Returns the real value of a symbol function address or offset | ||
| 151 | + (e.g. when the st_value contains some flag bits that need to be | ||
| 152 | + masked off). This is different from ebl_resolve_sym_value which | ||
| 153 | + only works for actual symbol addresses (in non-ET_REL files) that | ||
| 154 | + might resolve to an address in a different section. | ||
| 155 | + ebl_sym_func_value is called to turn the given value into the a | ||
| 156 | + real address or offset (the original value might not be a real | ||
| 157 | + address). This works for both ET_REL when the value is a section | ||
| 158 | + offset or ET_EXEC or ET_DYN symbol values, which are addresses. */ | ||
| 159 | +extern GElf_Addr ebl_sym_func_value (Ebl *ebl, GElf_Addr val); | ||
| 160 | + | ||
| 161 | #ifdef __cplusplus | ||
| 162 | } | ||
| 163 | #endif | ||
| 164 | -- | ||
| 165 | 1.9.1 | ||
| 166 | |||
