This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] Fix findtextrel to use DT_SYMTAB when present
- From: Mike Hommey <mh at glandium dot org>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Wed, 10 Nov 2010 19:15:05 +0100
- Subject: [PATCH] Fix findtextrel to use DT_SYMTAB when present
findtextrel skips going through all sections when it encounters the
SHT_DYNAMIC section, and that section indicates text relocations
through DT_TEXTREL or DF_TEXTREL. But in most cases, the DT_SYMTAB
section appears after the SHT_DYNAMIC section, in which case
findtextrel never takes advantage of that section. This fixes it.
---
src/findtextrel.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/findtextrel.c b/src/findtextrel.c
index 9d10982..88276c2 100644
--- a/src/findtextrel.c
+++ b/src/findtextrel.c
@@ -207,6 +207,7 @@ noop (void *arg __attribute__ ((unused)))
static int
process_file (const char *fname, bool more_than_one)
{
+ int have_textrel = 0;
int result = 0;
void *knownsrcs = NULL;
@@ -297,17 +298,18 @@ 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 = 1;
}
}
else if (shdr->sh_type == SHT_SYMTAB)
symscn = scn;
}
- 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. */
--
1.7.2.3