]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Restore short-circuit on bad reloc type.
authorRoland McGrath <roland@redhat.com>
Wed, 30 Jun 2010 07:47:58 +0000 (00:47 -0700)
committerRoland McGrath <roland@redhat.com>
Wed, 30 Jun 2010 07:47:58 +0000 (00:47 -0700)
libdwfl/ChangeLog
libdwfl/relocate.c

index 34d7c002bc01061ed527cb4958a005e0b909e4ca..dcc91503b208e2251ce24d4f17e840ef3f0b13d0 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-30  Roland McGrath  <roland@redhat.com>
+
+       * relocate.c (relocate_section): Check for bad reloc type before
+       looking up symndx.
+
 2010-06-29  Roland McGrath  <roland@redhat.com>
 
        * derelocate.c (check_module): Don't call dwfl_module_getdwarf.
index b89de37efd8dd9c088d93435e5067c692ca5a04b..30b206e3b155f2179c1ddd2f60fc1576fd8be26c 100644 (file)
@@ -346,6 +346,26 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr,
         So we just pretend it's OK without further relocation.  */
       return DWFL_E_NOERROR;
 
+    /* These are the types we can relocate.  */
+    size_t size = 4;
+    for (const int *tp = reloc_symtab->rel8_types; *tp != 0; ++tp)
+      if (*tp == rtype)
+       {
+         size = 8;
+         break;
+       }
+    if (size == 4)
+      {
+       const int *tp = reloc_symtab->rel4_types;
+       while (*tp != 0 && *tp != rtype)
+         ++tp;
+       if (unlikely (*tp == 0))
+         return DWFL_E_BADRELTYPE;
+      }
+
+    if (offset + size > tdata->d_size)
+      return DWFL_E_BADRELOFF;
+
     /* First, resolve the symbol to an absolute value.  */
     GElf_Addr value;
 
@@ -378,26 +398,6 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr,
        value = sym.st_value;
       }
 
-    /* These are the types we can relocate.  */
-    size_t size = 4;
-    for (const int *tp = reloc_symtab->rel8_types; *tp != 0; ++tp)
-      if (*tp == rtype)
-       {
-         size = 8;
-         break;
-       }
-    if (size == 4)
-      {
-       const int *tp = reloc_symtab->rel4_types;
-       while (*tp != 0 && *tp != rtype)
-         ++tp;
-       if (unlikely (*tp == 0))
-         return DWFL_E_BADRELTYPE;
-      }
-
-    if (offset + size > tdata->d_size)
-      return DWFL_E_BADRELOFF;
-
     BYTE_ORDER_DUMMY (bo, ehdr->e_ident);
 
     /* XXX check for overflow? */