]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
findtextrel: Don't assume order of sections.
authorRoland McGrath <roland@redhat.com>
Thu, 11 Nov 2010 03:47:31 +0000 (19:47 -0800)
committerRoland McGrath <roland@redhat.com>
Thu, 11 Nov 2010 03:47:31 +0000 (19:47 -0800)
src/ChangeLog
src/findtextrel.c

index 716e7313f4cccd3167af518eb6d8a4e5e229160a..7a151927ad7bee8338fbc44fe817b4f21a8d83e9 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-10  Roland McGrath  <roland@redhat.com>
+
+       * findtextrel.c (process_file): Don't assume order of sections.
+       Reported by Mike Hommey <mh@glandium.org>.
+
 2010-07-26  Roland McGrath  <roland@redhat.com>
 
        * readelf.c (print_ops): Handle DW_OP_GNU_implicit_pointer.
index 9d10982f1a07b99afe4f3fdd67534c14aeb29e2d..46b86eb7127a6429a5a8ecae8986b6878b9433be 100644 (file)
@@ -1,5 +1,5 @@
 /* Locate source files or functions which caused text relocations.
-   Copyright (C) 2005, 2006, 2007, 2009 Red Hat, Inc.
+   Copyright (C) 2005-2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2005.
 
@@ -262,6 +262,8 @@ process_file (const char *fname, bool more_than_one)
      the symbol table.  */
   Elf_Scn *symscn = NULL;
   Elf_Scn *scn = NULL;
+  bool seen_dynamic = false;
+  bool have_textrel = false;
   while ((scn = elf_nextscn (elf, scn)) != NULL)
     {
       /* Handle the section if it is a symbol table.  */
@@ -297,17 +299,27 @@ process_file (const char *fname, bool more_than_one)
              if (dyn->d_tag == DT_TEXTREL
                  || (dyn->d_tag == DT_FLAGS
                      && (dyn->d_un.d_val & DF_TEXTREL) != 0))
-               goto have_textrel;
+               have_textrel = true;
            }
+
+         seen_dynamic = true;
+         if (symscn != NULL)
+           break;
        }
       else if (shdr->sh_type == SHT_SYMTAB)
-       symscn = scn;
+       {
+         symscn = scn;
+         if (seen_dynamic)
+           break;
+       }
     }
 
-  error (0, 0, gettext ("no text relocations reported in '%s'"), fname);
-  return 1;
+  if (!have_textrel)
+    {
+      error (0, 0, gettext ("no text relocations reported in '%s'"), fname);
+      return 1;
+    }
 
- have_textrel:;
   int fd2 = -1;
   Elf *elf2 = NULL;
   /* Get the address ranges for the loaded segments.  */