This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
readelf bug exposed with change from 2003-12-29
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: nickc at redhat dot com
- Cc: binutils at sources dot redhat dot com
- Date: Wed, 7 Jan 2004 17:04:59 +0100
- Subject: readelf bug exposed with change from 2003-12-29
Hi. Since this change:
2003-12-29 Nick Clifton <nickc@redhat.com>
* readelf.c (debug_line_pointer_size): Replace with an array
called 'debug_line_pointer_sizes'.
(num_debug_line_pointer_sizes): New variable.
(display_debug_lines): Extract pointer size from the
debug_line_pointer_sizes array.
(display_debug_loc): Likewise.
(prescan_debug_info): Fill in the debug_line_pointer_sizes
array.
I'm getting these errors:
Running /home/hp/binutils/cvs_latest/src/gas/testsuite/gas/cris/cris.exp ...
FAIL: gas/cris/rd-dw2-1
FAIL: gas/cris/rd-dw2-10
FAIL: gas/cris/rd-dw2-11
FAIL: gas/cris/rd-dw2-12
FAIL: gas/cris/rd-dw2-13
FAIL: gas/cris/rd-dw2-14
FAIL: gas/cris/rd-dw2-15
FAIL: gas/cris/rd-dw2-2
FAIL: gas/cris/rd-dw2-3
FAIL: gas/cris/rd-dw2-4
FAIL: gas/cris/rd-dw2-5
FAIL: gas/cris/rd-dw2-6
FAIL: gas/cris/rd-dw2-7
FAIL: gas/cris/rd-dw2-8
FAIL: gas/cris/rd-dw2-9
In gas.log they all look like:
../as-new --em=criself --gdwarf2 -o dump.o /home/hp/binutils/cvs_latest/src/gas/testsuite/gas/cris/addi.s
/dsk/c0t3s2/hptmp2/autobuildbinu/binu/gas/testsuite/../../binutils/readelf -wl dump.o > dump.out
readelf: Error: Not enough comp units for .debug_lines section
FAIL: gas/cris/rd-dw2-1
Looking at readelf.c code nearby the change, sections are
iterated in file order and a function display_debug_section is
called, iterating on an array called debug_displays, calling
some functions for certain section names. The function
prescan_debug_info is called for ".debug_info". That function
needs to be called to initialize pointer sizes before users of
that information, like display_debug_lines (for ".debug_lines")
are called, else the latter functions hork as seen above.
The current scheme seems to rely on the section ".debug_info"
being located before ".debug_lines" in a file, which would be
pure coincidence, breaking here when encountering GAS-generated
debug info. It worked before the patch above which seems to
have removed a fallback to assume pointer size = 4.
Unfortunately I see no small and obvious fix. Reinstating the
fallback would just be a hack.
brgds, H-P