From 77221de070e8978c312d3e6b2c66a28dca4c37bc Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 10 Nov 2010 19:47:31 -0800 Subject: [PATCH] findtextrel: Don't assume order of sections. --- src/ChangeLog | 5 +++++ src/findtextrel.c | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 716e7313f..7a151927a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-11-10 Roland McGrath + + * findtextrel.c (process_file): Don't assume order of sections. + Reported by Mike Hommey . + 2010-07-26 Roland McGrath * readelf.c (print_ops): Handle DW_OP_GNU_implicit_pointer. diff --git a/src/findtextrel.c b/src/findtextrel.c index 9d10982f1..46b86eb71 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 , 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. */ -- 2.47.2