From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hans-Peter Nilsson To: binutils@sourceware.cygnus.com Subject: (repeat) Patch for buglet in readelf.c - confused by zero-terminationof the .debug_abbrev section Date: Mon, 09 Aug 1999 09:31:00 -0000 Message-id: X-SW-Source: 1999-08/msg00067.html I hope I don't offend anyone by re-posting this; it wasn't commented on and CVS says no such change went in. It's needed now that gcc CVS has the patch mentioned below, and will be included in gcc-2.95.1 ---------- Forwarded message ---------- Date: Wed, 14 Jul 1999 22:24:36 -0400 (EDT) From: Hans-Peter Nilsson To: binutils@sourceware.cygnus.com Cc: krister.walfridsson@precisebiometrics.com, lars.malmborg@precisebiometrics.com Subject: Patch for buglet in readelf.c - confused by zero-termination of the .debug_abbrev section 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 * 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