summaryrefslogtreecommitdiff
path: root/src/findtextrel.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2010-11-10 19:47:31 -0800
committerRoland McGrath <roland@redhat.com>2010-11-10 19:47:31 -0800
commit77221de070e8978c312d3e6b2c66a28dca4c37bc (patch)
treecd55ac0ef46e823214baa171adceaa731a8da1da /src/findtextrel.c
parentadf84f4a0364e140eaf1994ac3403f29ae719a95 (diff)
downloadelfutils-77221de070e8978c312d3e6b2c66a28dca4c37bc.tar.gz
findtextrel: Don't assume order of sections.
Diffstat (limited to 'src/findtextrel.c')
-rw-r--r--src/findtextrel.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/findtextrel.c b/src/findtextrel.c
index 9d10982f..46b86eb7 100644
--- a/src/findtextrel.c
+++ b/src/findtextrel.c
@@ -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. */