summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2014-05-19 16:52:56 +0200
committerMark Wielaard <mjw@redhat.com>2014-05-19 22:04:24 +0200
commit028d0ab0cc1cb5f96ee48feef966b7d8d56c6a8e (patch)
treea8217d678cede635782d0fe33413a3dc3ae206af
parent85482fc073442a056e0e3663eb454fa76d883271 (diff)
downloadelfutils-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>
-rw-r--r--backends/ChangeLog7
-rw-r--r--backends/arm_init.c1
-rw-r--r--backends/arm_symbol.c9
-rw-r--r--backends/ia64_init.c3
-rw-r--r--backends/ia64_symbol.c9
-rw-r--r--libebl/ChangeLog10
-rw-r--r--libebl/Makefile.am2
-rw-r--r--libebl/ebl-hooks.h5
-rw-r--r--libebl/eblcheckreloctargettype.c46
-rw-r--r--libebl/eblopenbackend.c11
-rw-r--r--libebl/libebl.h3
-rw-r--r--src/ChangeLog4
-rw-r--r--src/elflint.c3
13 files changed, 105 insertions, 8 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 748d0a06..bc5b8434 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,10 @@
+2014-05-19 Mark Wielaard <mjw@redhat.com>
+
+ * arm_init.c (arm_init): Hook check_reloc_target_type.
+ * arm_symbol.c (arm_check_reloc_target_type): New function.
+ * ia64_init.c (ia64_init): Hook check_reloc_target_type.
+ * ia64_symbol.c (ia64_check_reloc_target_type): New function.
+
2014-04-22 Kurt Roeckx <kurt@roeckx.be>
* i386_initreg.c: Make Linux only.
diff --git a/backends/arm_init.c b/backends/arm_init.c
index 14b26356..92e6cd51 100644
--- a/backends/arm_init.c
+++ b/backends/arm_init.c
@@ -63,6 +63,7 @@ arm_init (elf, machine, eh, ehlen)
HOOK (eh, check_object_attribute);
HOOK (eh, return_value_location);
HOOK (eh, abi_cfi);
+ HOOK (eh, check_reloc_target_type);
/* We only unwind the core integer registers. */
eh->frame_nregs = 16;
diff --git a/backends/arm_symbol.c b/backends/arm_symbol.c
index e41ce347..cd467ffc 100644
--- a/backends/arm_symbol.c
+++ b/backends/arm_symbol.c
@@ -1,5 +1,5 @@
/* Arm specific symbolic name handling.
- Copyright (C) 2002-2009 Red Hat, Inc.
+ Copyright (C) 2002-2009, 2014 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -122,3 +122,10 @@ arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
return ELF_T_NUM;
}
}
+
+/* The SHT_ARM_EXIDX section type is a valid target for relocation. */
+bool
+arm_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)), Elf64_Word sh_type)
+{
+ return sh_type == SHT_ARM_EXIDX;
+}
diff --git a/backends/ia64_init.c b/backends/ia64_init.c
index ed56efaa..91da748d 100644
--- a/backends/ia64_init.c
+++ b/backends/ia64_init.c
@@ -1,5 +1,5 @@
/* Initialization of IA-64 specific backend library.
- Copyright (C) 2002, 2003, 2005, 2006, 2007 Red Hat, Inc.
+ Copyright (C) 2002, 2003, 2005, 2006, 2007, 2014 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -61,6 +61,7 @@ ia64_init (elf, machine, eh, ehlen)
HOOK (eh, machine_section_flag_check);
HOOK (eh, register_info);
HOOK (eh, return_value_location);
+ HOOK (eh, check_reloc_target_type);
return MODVERSION;
}
diff --git a/backends/ia64_symbol.c b/backends/ia64_symbol.c
index 8d806b02..f928b0b7 100644
--- a/backends/ia64_symbol.c
+++ b/backends/ia64_symbol.c
@@ -1,5 +1,5 @@
/* IA-64 specific symbolic name handling.
- Copyright (C) 2002-2009 Red Hat, Inc.
+ Copyright (C) 2002-2009, 2014 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -148,3 +148,10 @@ ia64_reloc_simple_type (Ebl *ebl, int type)
return ELF_T_NUM;
}
+
+/* The SHT_IA_64_UNWIND section type is a valid target for relocation. */
+bool
+ia64_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)), Elf64_Word sh_type)
+{
+ return sh_type == SHT_IA_64_UNWIND;
+}
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);
diff --git a/src/ChangeLog b/src/ChangeLog
index 341787d6..4197ccd9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2014-05-19 Mark Wielaard <mjw@redhat.com>
+
+ * elflint.c (check_reloc_shdr): Check ebl_check_reloc_target_type.
+
2014-05-01 Mark Wielaard <mjw@redhat.com>
* readelf.c (find_no_debuginfo): Call dwfl_standard_find_debuginfo
diff --git a/src/elflint.c b/src/elflint.c
index 5a500b76..bf6d044b 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -1216,8 +1216,7 @@ check_reloc_shdr (Ebl *ebl, const GElf_Ehdr *ehdr, const GElf_Shdr *shdr,
destshdr_memp);
if (*destshdrp != NULL)
{
- if((*destshdrp)->sh_type != SHT_PROGBITS
- && (*destshdrp)->sh_type != SHT_NOBITS)
+ if(! ebl_check_reloc_target_type (ebl, (*destshdrp)->sh_type))
{
reldyn = is_rel_dyn (ebl, ehdr, idx, shdr, true);
if (!reldyn)