This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Patch for buglet in readelf.c - confused by zero-termination of the.debug_abbrev section
- To: binutils@sourceware.cygnus.com
- Subject: Patch for buglet in readelf.c - confused by zero-termination of the.debug_abbrev section
- From: Hans-Peter Nilsson <hp@bitrange.com>
- Date: Wed, 14 Jul 1999 22:24:36 -0400 (EDT)
- cc: krister.walfridsson@precisebiometrics.com, lars.malmborg@precisebiometrics.com
Hi!
There's a bug in readelf.c in handling the standard
zero-termination of the .debug_abbrev section for each
compilation unit (that current releases of gcc do not emit,
thus not triggering the bug). See the dwarf2 standard,
section 7.5.3, at the end, and it's obvious from the figure
in Appendix 2).
The buglet signals the caller that there are more abbrevs, but
it will return NULL on the second round, confusing the caller
display_debug_abbrev into displaying the same section twice.
I believe no problems are introduced by making it also accept
standard-compliant input :-) I've sent a matching patch for gcc.
Note that read_abbrevs in bfd/dwarf2.c and dwarf2_read_abbrevs in
gdb/dwarf2read.c does not have a bug here - that function has a
workaround for the *non*-termination of the .debug_abbrev section.
Thu Jul 15 22:44:21 1999 Hans-Peter Nilsson <hp@bitrange.com>
* readelf.c (process_abbrev_section): Handle standard-conforming
single zero at the end of the section.
RCS file: /cvs/binutils/binutils/binutils/readelf.c,v
retrieving revision 1.18
diff -p -c -r1.18 readelf.c
*** readelf.c 1999/07/11 20:02:26 1.18
--- readelf.c 1999/07/15 01:30:22
*************** process_abbrev_section (start, end)
*** 4787,4794 ****
entry = read_leb128 (start, & bytes_read, 0);
start += bytes_read;
if (entry == 0)
! return start;
tag = read_leb128 (start, & bytes_read, 0);
start += bytes_read;
--- 4787,4797 ----
entry = read_leb128 (start, & bytes_read, 0);
start += bytes_read;
+ /* A single zero is supposed to end the section according
+ to the standard. If there's more, then signal that to
+ the caller. */
if (entry == 0)
! return start == end ? NULL : start;
tag = read_leb128 (start, & bytes_read, 0);
start += bytes_read;
brgds, H-P