[PATCH] readelf: Set begin properly for DW_LLE_GNU_start_end_entry on addrx failure.

Mark Wielaard mark@klomp.org
Tue Jun 5 21:06:00 GMT 2018


When printing the GNU DebugFission location entries we want to print the
start idx as begin, if we cannot find the address index.
A copy/paste error set up end instead of begin in that case causing us
to print garbage (in the unlikely event the .debug_addr table wasn't
found for this entry).

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog | 5 +++++
 src/readelf.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 1bb5696..ec07bb1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
 2018-06-05  Mark Wielaard  <mark@klomp.org>
 
+	* readelf.c (print_debug_loc_section): Set begin to idx when failing
+	to read the start address if DW_LLE_GNU_start_end_entry.
+
+2018-06-05  Mark Wielaard  <mark@klomp.org>
+
 	* readelf.c (handle_sysv_hash): Don't leak lengths array when
 	detecting an invalid chain.
 	(handle_sysv_hash64): Likewise.
diff --git a/src/readelf.c b/src/readelf.c
index ce959b3..eaeb70c 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -9355,7 +9355,7 @@ print_debug_loc_section (Dwfl_Module *dwflmod,
 		goto invalid_data;
 	      get_uleb128 (idx, locp, locendp);
 	      if (get_indexed_addr (cu, idx, &begin) != 0)
-		end = idx; /* ... */
+		begin = idx; /* ... */
 	      if (locp >= locendp)
 		goto invalid_data;
 	      get_uleb128 (idx, locp, locendp);
-- 
1.8.3.1



More information about the Elfutils-devel mailing list