Dwarf reader error from ld

Ian Lance Taylor ian@zembu.com
Thu Jan 13 10:17:00 GMT 2000


   Date: Thu, 13 Jan 2000 08:48:24 -0600
   From: Eric DeVolder <devolder@evsx.com>

   (By the way, there is a code error here in
   that the call to bfd_error_handler() is using the variable 'unit' before it is
   assigned a value, thus the garbage printed for compilation unit in the above
   error message.)

That bug was fixed a while ago, and the fix is in the development
sources at http://sourceware.cygnus.com/binutils .

   Contents of section .debug_info:
    0000 92000000 00000000 02000000 00000000  ................
    0010 00000801 2e2e2f2e 2e2f6763 632f6763  ....../../gcc/gc
    0020 632f6c69 62676363 322e6300 2f757372  c/libgcc2.c./usr
    0030 2f6c6f63 616c2f64 65766f6c 6465722f  /local/devolder/
    0040 63726f73 73676363 2f6f626a 2d65332d  crossgcc/obj-e3-
    0050 656c662f 67636300 474e5520 4320322e  elf/gcc.GNU C 2.
    0060 39352e32 20313939 39313032 34202872  95.2 19991024 (r
    0070 656c6561 73652900 0102015f 5f6d756c  elease)....__mul
    0080 64693300 01250100 00000000 00000000  di3..%..........
    0090 00000000 00000001 5500               ........U.

   >From what I have learned, I would expect the first seven bytes of the
   .debug_info section to contain:

   0x02 0x00  (version, little endian)
   0xXX 0xXX 0xXX 0xXX (abbrev table offset)
   0x08 (addr size)

No.  The start of the .debug_info section is the size of the following
comp_unit.  In your case, that size appears to be 8 bytes, little
endian (in the above example, 0x92).  After the 8 byte size, you can
see the two byte version (2), and then an 8 byte offset in the abbrev
table (0).  Next comes the 1 byte address size (8).

This is why I said that you need to arrange to pass 8 as the last
parameter to _bfd_dwarf2_find_nearest_line.  I find it odd that there
is no way to know from looking at the DWARF2 debugging information
that 8 is the correct value rather than 4.

   >    As far as I can tell, the source file looks okay [snippet of gcc -S
   >    below]. Admittedly, I'm not very familiar with Dwarf2, so i an be
   >    thrashed if this is the problem...
   >
   > Do you override find_nearest_line in your BFD backend?  If you don't,
   > the linker will think it should be reading 4 byte addresses from the
   > DWARF debugging info.  You are giving it 8 byte addresses, so that
   > won't work.  You can pass the last argument of
   > _bfd_dwarf2_find_nearest_line as 8 to tell it to use 8 byte addresses.

   No. I looked at this function, but there is no argument that says what addr
   size is. Perhaps this is because I'm still on 2.9.1.

Yes.  The parameter was added 1999-07-02 for Irix 6 support.

On this list, I normally assume that people are working with the
development sources.  If you are adding support for a new target, I
very strongly urge you to use the development sources.  Adding support
to 2.9.1 will just force you to port that work later if you want it to
be added to the development version.

Another way to fix your problem would be to change gcc to define
DWARF_OFFSET_SIZE to be 4, or, indeed, to not define it at all, since
4 is the default in dwarf2out.c.  It would be a large program indeed
which required DWARF_OFFSET_SIZE to be larger than 4.

Ian


More information about the Binutils mailing list