This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] readelf: Accept version 8 .gdb_index section format. Fix memory leak.


On Mon, 2013-03-18 at 14:05 +0100, Jan Kratochvil wrote:
> > @@ -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)
> 
> Here could be copy-pasted the difference of version 8 from your mail above.

Added.

> > +      free (l);
> > +      free (h);
> >        n++;
> 
> This is really very unrelated (->separate) patch.

Grin. It is just a 3 line patch. But yeah, OK.
Separated and pushed in two commits.

Thanks,

Mark
>From a73fecc109e400fd9f538bf25a73ccf9cdf1d598 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Mon, 18 Mar 2013 13:54:50 +0100
Subject: [PATCH 1/2] readelf: Accept version 8 .gdb_index section format.

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

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 src/ChangeLog | 4 ++++
 src/readelf.c | 8 +++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 2275c5c..0781177 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2013-03-18  Mark Wielaard  <mjw@redhat.com>
+
+	* readelf.c (print_gdb_index_section): Accept version 8.
+
 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..9c7880d 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,10 @@ 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.  Version 8 just indicates that it correctly includes
+  // TUs for symbols.
+  if (vers < 4 || vers > 8)
     {
       printf (gettext ("  unknown version, cannot parse section\n"));
       return;
-- 
1.8.1.4

>From 10cd97eecabe080a7fc39965a2b98c2f024c0ab0 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Tue, 19 Mar 2013 11:43:49 +0100
Subject: [PATCH 2/2] readelf: print_gdb_index_section fix memory leak.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 src/ChangeLog | 4 ++++
 src/readelf.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index 0781177..a641d33 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2013-03-19  Mark Wielaard  <mjw@redhat.com>
+
+	* readelf.c (print_gdb_index_section): Free format_dwarf_addr results.
+
 2013-03-18  Mark Wielaard  <mjw@redhat.com>
 
 	* readelf.c (print_gdb_index_section): Accept version 8.
diff --git a/src/readelf.c b/src/readelf.c
index 9c7880d..1412bed 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7389,6 +7389,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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]