]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
backends: Add ebl_check_reloc_target_type.
authorMark Wielaard <mjw@redhat.com>
Mon, 19 May 2014 14:52:56 +0000 (16:52 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 19 May 2014 20:04:24 +0000 (22:04 +0200)
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>
13 files changed:
backends/ChangeLog
backends/arm_init.c
backends/arm_symbol.c
backends/ia64_init.c
backends/ia64_symbol.c
libebl/ChangeLog
libebl/Makefile.am
libebl/ebl-hooks.h
libebl/eblcheckreloctargettype.c [new file with mode: 0644]
libebl/eblopenbackend.c
libebl/libebl.h
src/ChangeLog
src/elflint.c

index 748d0a06ddc363cd06cb7b5743a68435d508e16d..bc5b8434ffa38a7a6252f8848d197cab6c7ed496 100644 (file)
@@ -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.
index 14b2635669d31671385cc716088e35893209c118..92e6cd51552a3058f89970ac86940acd3a055725 100644 (file)
@@ -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;
index e41ce347c483ce2f5f2054fcd27bee18c73ccf0c..cd467ffc1da8dc92ab43352c0ea5ec26afc54414 100644 (file)
@@ -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;
+}
index ed56efaafae57e5b7531c32e2d6960fe73f6dfc8..91da748da2dd14df47f614b8528abfe2cca1f181 100644 (file)
@@ -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;
 }
index 8d806b026254c25a86c71a828d0efb699799fde2..f928b0b7f75461558c9d1e9c7f373ae1bf0aaa45 100644 (file)
@@ -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;
+}
index fc6bdd569001623cb5a9f1db23a9db0a6fddd741..7198d5ec81a1f9f3718a7e7a3339d6f2a7c8651e 100644 (file)
@@ -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.
index 916af72a7f234ec81dba65426f9ddabb5df4dfcd..ec4477b7b117914c13bd83f94ad9092bed969ff1 100644 (file)
@@ -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)
 
index bfb7f4a937d66d7c3a94d76649e4502393675847..65c62ec67e3461c36ef85fae4f27577c5cc292d1 100644 (file)
@@ -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 (file)
index 0000000..e135f8a
--- /dev/null
@@ -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;
+}
index c19ae1b2c22bfb4d74eaafdcf64cca60a9a6ed62..bd947599dd2b407dc75c76c6f2df60d45800130d 100644 (file)
@@ -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)))
index 50d6baabe5f674fae63258e8294f192e597e8677..d05751fae3e548eff5ef878a1ed1edb01e6170a6 100644 (file)
@@ -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);
index 341787d61f7756c48f128c350a827888cacb93e7..4197ccd9d132191c49bfbdc797e13657a6da27f7 100644 (file)
@@ -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
index 5a500b76eb15492f26ec0b7247462e5a63249981..bf6d044bb1a18b7d33aacfbfba93d3894d5714fa 100644 (file)
@@ -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)