summaryrefslogtreecommitdiffstats
path: root/src/findtextrel.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2014-12-19 00:06:26 +0100
committerMark Wielaard <[email protected]>2014-12-19 00:06:26 +0100
commitbd0434b61e0317718eb159fe7b5dc9ea870a0b79 (patch)
tree825a373c2233a59b5156b219013e32f8f241aacc /src/findtextrel.c
parente18bf66ce8070f96195880e83a50c9d98006b832 (diff)
parent898ed261444cdd817c2d9b3656209a291eb5e807 (diff)
Merge branch 'master' into portable
Diffstat (limited to 'src/findtextrel.c')
-rw-r--r--src/findtextrel.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/findtextrel.c b/src/findtextrel.c
index 9913b82c..d7de202b 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-2010, 2012 Red Hat, Inc.
+ Copyright (C) 2005-2010, 2012, 2014 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <[email protected]>, 2005.
@@ -324,14 +324,20 @@ process_file (const char *fname, bool more_than_one)
if (segments == NULL)
error (1, errno, gettext ("while reading ELF file"));
- for (int i = 0; i < ehdr->e_phnum; ++i)
+ size_t phnum;
+ if (elf_getphdrnum (elf, &phnum) != 0)
+ error (1, 0, gettext ("cannot get program header count: %s"),
+ elf_errmsg (-1));
+
+
+ for (size_t i = 0; i < phnum; ++i)
{
GElf_Phdr phdr_mem;
GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
if (phdr == NULL)
{
error (0, 0,
- gettext ("cannot get program header index at offset %d: %s"),
+ gettext ("cannot get program header index at offset %zd: %s"),
i, elf_errmsg (-1));
result = 1;
goto next;
@@ -349,7 +355,7 @@ process_file (const char *fname, bool more_than_one)
if (segments == NULL)
{
error (0, 0, gettext ("\
-cannot get program header index at offset %d: %s"),
+cannot get program header index at offset %zd: %s"),
i, elf_errmsg (-1));
result = 1;
goto next;