diff options
| author | Mark Wielaard <[email protected]> | 2014-05-26 22:54:38 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2014-05-27 22:00:46 +0200 |
| commit | eb4811dee133864ebbab1a062ac14af1f3ffdc62 (patch) | |
| tree | cd89851954d3eb3ccda6c481298c37f14701665e /src/readelf.c | |
| parent | bd1a0d1293e3cdc2a81370a39df5f55bf08bcbb6 (diff) | |
readelf: Don't print 'for section' when rela section sh_info is zero.
This matches how handle_relocs_rel already printed the header.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src/readelf.c')
| -rw-r--r-- | src/readelf.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/readelf.c b/src/readelf.c index 45b19105..ea14a09b 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -1971,7 +1971,8 @@ handle_relocs_rela (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr) error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); - printf (ngettext ("\ + if (shdr->sh_info != 0) + printf (ngettext ("\ \nRelocation section [%2zu] '%s' for section [%2u] '%s' at offset %#0" PRIx64 " contains %d entry:\n", "\ \nRelocation section [%2zu] '%s' for section [%2u] '%s' at offset %#0" PRIx64 " contains %d entries:\n", @@ -1982,6 +1983,19 @@ handle_relocs_rela (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr) elf_strptr (ebl->elf, shstrndx, destshdr->sh_name), shdr->sh_offset, nentries); + else + /* The .rela.dyn section does not refer to a specific section but + instead of section index zero. Do not try to print a section + name. */ + printf (ngettext ("\ +\nRelocation section [%2u] '%s' at offset %#0" PRIx64 " contains %d entry:\n", + "\ +\nRelocation section [%2u] '%s' at offset %#0" PRIx64 " contains %d entries:\n", + nentries), + (unsigned int) elf_ndxscn (scn), + elf_strptr (ebl->elf, shstrndx, shdr->sh_name), + shdr->sh_offset, + nentries); fputs_unlocked (class == ELFCLASS32 ? gettext ("\ Offset Type Value Addend Name\n") |
