This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] readelf: Accept version 8 .gdb_index section format. Fix memory leak.
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Mon, 18 Mar 2013 13:55:39 +0100
- Subject: [PATCH] readelf: Accept version 8 .gdb_index section format. Fix memory leak.
Version 8 just indicates that if the .gdb_index was generated by the gold
linker it correctly includes TUs for symbols. http://sourceware.org/PR15021
Also fix memory leak by freeing the return value of format_dwarf_addr.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
src/ChangeLog | 5 +++++
src/readelf.c | 9 ++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 2275c5c..237da49 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-18 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (print_gdb_index_section): Accept version 8. Free
+ format_dwarf_addr results.
+
2013-03-01 Mark Wielaard <mjw@redhat.com>
* findtextrel.c (process_file): Release ELF and close file when not
diff --git a/src/readelf.c b/src/readelf.c
index c04cd20..774318f 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1,5 +1,5 @@
/* Print information from ELF file in human-readable form.
- Copyright (C) 1999-2012 Red Hat, Inc.
+ Copyright (C) 1999-2013 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1999.
@@ -7272,8 +7272,9 @@ print_gdb_index_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
// The only difference between version 4 and version 5 is the
// hash used for generating the table. Version 6 contains symbols
- // for inlined functions, older versions didn't.
- if (vers < 4 || vers > 7)
+ // for inlined functions, older versions didn't. Version 7 adds
+ // symbol kinds.
+ if (vers < 4 || vers > 8)
{
printf (gettext (" unknown version, cannot parse section\n"));
return;
@@ -7387,6 +7388,8 @@ print_gdb_index_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
char *h = format_dwarf_addr (dwflmod, 8, high - 1, high);
printf (" [%4zu] %s..%s, CU index: %5" PRId32 "\n",
n, l, h, idx);
+ free (l);
+ free (h);
n++;
}
--
1.8.1.4