diff options
author | Mark Wielaard <mjw@redhat.com> | 2014-05-19 16:52:56 +0200 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2014-05-19 22:04:24 +0200 |
commit | 028d0ab0cc1cb5f96ee48feef966b7d8d56c6a8e (patch) | |
tree | a8217d678cede635782d0fe33413a3dc3ae206af /libebl | |
parent | 85482fc073442a056e0e3663eb454fa76d883271 (diff) | |
download | elfutils-028d0ab0cc1cb5f96ee48feef966b7d8d56c6a8e.tar.gz |
backends: Add ebl_check_reloc_target_type.
And implement for arm and ia64. Both have special section types that
are valid targets for a reloc. Both refer to unwind data. elflint now
just calls ebl_check_reloc_target_type instead of hard coding the
expected section types.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libebl')
-rw-r--r-- | libebl/ChangeLog | 10 | ||||
-rw-r--r-- | libebl/Makefile.am | 2 | ||||
-rw-r--r-- | libebl/ebl-hooks.h | 5 | ||||
-rw-r--r-- | libebl/eblcheckreloctargettype.c | 46 | ||||
-rw-r--r-- | libebl/eblopenbackend.c | 11 | ||||
-rw-r--r-- | libebl/libebl.h | 3 |
6 files changed, 74 insertions, 3 deletions
diff --git a/libebl/ChangeLog b/libebl/ChangeLog index fc6bdd56..7198d5ec 100644 --- a/libebl/ChangeLog +++ b/libebl/ChangeLog @@ -1,3 +1,13 @@ +2014-05-19 Mark Wielaard <mjw@redhat.com> + + * Makefile.am (gen_SOURCES): Add eblcheckreloctargettype.c. + * eblcheckreloctargettype.c: New file. + * ebl-hooks.h (check_reloc_target_type): New hook. + * eblopenbackend.c (default_check_reloc_target_type): New function. + (fill_defaults): Assign default_check_reloc_target_type to + check_reloc_target_type. + * libebl.h (ebl_check_reloc_target_type): New function definition. + 2013-12-18 Mark Wielaard <mjw@redhat.com> * Makefile.am (gen_SOURCES): Add eblresolvesym.c. diff --git a/libebl/Makefile.am b/libebl/Makefile.am index 916af72a..ec4477b7 100644 --- a/libebl/Makefile.am +++ b/libebl/Makefile.am @@ -55,7 +55,7 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \ eblsysvhashentrysize.c eblauxvinfo.c eblcheckobjattr.c \ ebl_check_special_section.c ebl_syscall_abi.c eblabicfi.c \ eblstother.c eblinitreg.c ebldwarftoregno.c eblnormalizepc.c \ - eblunwind.c eblresolvesym.c + eblunwind.c eblresolvesym.c eblcheckreloctargettype.c libebl_a_SOURCES = $(gen_SOURCES) diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h index bfb7f4a9..65c62ec6 100644 --- a/libebl/ebl-hooks.h +++ b/libebl/ebl-hooks.h @@ -1,5 +1,5 @@ /* Backend hook signatures internal interface for libebl. - Copyright (C) 2000-2011, 2013 Red Hat, Inc. + Copyright (C) 2000-2011, 2013, 2014 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -105,6 +105,9 @@ bool EBLHOOK(object_note) (const char *, uint32_t, uint32_t, const char *); bool EBLHOOK(check_object_attribute) (Ebl *, const char *, int, uint64_t, const char **, const char **); +/* Check reloc target section type. */ +bool EBLHOOK(check_reloc_target_type) (Ebl *, Elf64_Word); + /* Describe auxv element type. */ int EBLHOOK(auxv_info) (GElf_Xword, const char **, const char **); diff --git a/libebl/eblcheckreloctargettype.c b/libebl/eblcheckreloctargettype.c new file mode 100644 index 00000000..e135f8a3 --- /dev/null +++ b/libebl/eblcheckreloctargettype.c @@ -0,0 +1,46 @@ +/* Check whether a section type is a valid target for relocation. + Copyright (C) 2014 Red Hat, Inc. + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify + it under the terms of either + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version + + or both in parallel, as here. + + elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see <http://www.gnu.org/licenses/>. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <libeblP.h> + + +bool +ebl_check_reloc_target_type (Ebl *ebl, Elf64_Word sh_type) +{ + if (ebl->check_reloc_target_type (ebl, sh_type)) + return true; + + if (sh_type == SHT_PROGBITS || sh_type == SHT_NOBITS) + return true; + + return false; +} diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c index c19ae1b2..bd947599 100644 --- a/libebl/eblopenbackend.c +++ b/libebl/eblopenbackend.c @@ -1,5 +1,5 @@ /* Generate ELF backend handle. - Copyright (C) 2000-2013 Red Hat, Inc. + Copyright (C) 2000-2014 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -200,6 +200,7 @@ static bool default_check_object_attribute (Ebl *ebl, const char *vendor, int tag, uint64_t value, const char **tag_name, const char **value_name); +static bool default_check_reloc_target_type (Ebl *ebl, Elf64_Word sh_type); static int default_abi_cfi (Ebl *ebl, Dwarf_CIE *abi_info); @@ -241,6 +242,7 @@ fill_defaults (Ebl *result) result->register_info = default_register_info; result->syscall_abi = default_syscall_abi; result->check_object_attribute = default_check_object_attribute; + result->check_reloc_target_type = default_check_reloc_target_type; result->disasm = NULL; result->abi_cfi = default_abi_cfi; result->destr = default_destr; @@ -747,6 +749,13 @@ default_check_object_attribute (Ebl *ebl __attribute__ ((unused)), return false; } +static bool +default_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)), + Elf64_Word sh_type __attribute__ ((unused))) +{ + return false; +} + static int default_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info __attribute__ ((unused))) diff --git a/libebl/libebl.h b/libebl/libebl.h index 50d6baab..d05751fa 100644 --- a/libebl/libebl.h +++ b/libebl/libebl.h @@ -179,6 +179,9 @@ extern bool ebl_check_object_attribute (Ebl *ebl, const char *vendor, const char **tag_name, const char **value_name); +/* Check whether a section type is a valid reloc target. */ +extern bool ebl_check_reloc_target_type (Ebl *ebl, Elf64_Word sh_type); + /* Check section name for being that of a debug informatino section. */ extern bool ebl_debugscn_p (Ebl *ebl, const char *name); |