This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch] Add discriminator support to gas .loc directive
- From: Cary Coutant <ccoutant at google dot com>
- To: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- Cc: Nick Clifton <nickc at redhat dot com>, Binutils <binutils at sourceware dot org>
- Date: Tue, 30 Jun 2009 13:38:31 -0700
- Subject: Re: [patch] Add discriminator support to gas .loc directive
- References: <c17be2b30904201838nbb02752r9372787844a1634e@mail.gmail.com> <49ED7B85.7060606@redhat.com> <c17be2b30904211027w3e8359aen7cdf268cfee5b7f1@mail.gmail.com> <c17be2b30904211146u2f4c8ed2m967ca5d95d665318@mail.gmail.com> <49F16BFA.3040201@redhat.com> <c17be2b30904241133v1dc5a2a4s9484dda8bf5c1674@mail.gmail.com> <4A49F5A4.3040209@gmail.com>
> ?Now that GCC HEAD has begun actually generating this form of directives, we
> are seeing a lot of these errors on Cygwin:
>
> libtool: link: /gnu/gcc/obj-patched3/./gcc/gcj
> -B/gnu/gcc/obj-patched3/i686-pc-cygwin/libjava/ -B/gnu/gcc/obj-patched3/./gcc/
> -B/opt/gcc-tools/i686-pc-cygwin/bin/ -B/opt/gcc-tools/i686-pc-cygwin/lib/
> -isystem /opt/gcc-tools/i686-pc-cygwin/include -isystem
> /opt/gcc-tools/i686-pc-cygwin/sys-include -ffloat-store -fomit-frame-pointer
> -Usun -g -O2 -o .libs/jv-convert.exe --main=gnu.gcj.convert.Convert
> -shared-libgcc ?-L/gnu/gcc/obj-patched3/i686-pc-cygwin/libjava/.libs
> -L/gnu/gcc/obj-patched3/i686-pc-cygwin/libjava ./.libs/libgcj.a -ldl
> -L/opt/gcc-tools/lib/gcc/i686-pc-cygwin/4.5.0
> /opt/gcc-tools/bin/ld: Dwarf Error: mangled line number section.
>
> ?This turns out to be because you overlooked to add support for the new
> DW_LNE_ extended opcode in the decoding loop at
> bfd/dwarf2.c:decode_line_info()#1334.
>
> ?Could you take a quick look at it for us and suggest a fix please?
Sorry about that!
The quickest fix is to have decode_line_info just ignore the
discriminator. A proposed patch for that is below; I ran the binutils
testsuite with a discriminator-generating compiler, but I don't see
any failures with or without this fix -- there don't seem to be any
tests for addr2line. Could you give this patch a try and see if it
works for you?
I could also fix decode_line_info to track the discriminator, but
providing that extra information to the clients of bfd would probably
involve extra interfaces that don't seem to be in demand, so I'll
leave that for a future extension.
It would be nice if the line table reader would silently ignore
opcodes it doesn't understand (as the DWARF spec suggests), but it
seems to be a deliberate decision here to complain, so I'll leave that
as is.
-cary
bfd/ChangeLog:
* dwarf2.c (decode_line_info): Ignore DW_LNE_set_discriminator.
Index: dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.120
diff -u -p -r1.120 dwarf2.c
--- dwarf2.c 16 Mar 2009 12:41:26 -0000 1.120
+++ dwarf2.c 30 Jun 2009 20:19:10 -0000
@@ -1405,6 +1405,10 @@ decode_line_info (struct comp_unit *unit
line_ptr += bytes_read;
table->num_files++;
break;
+ case DW_LNE_set_discriminator:
+ (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ break;
default:
(*_bfd_error_handler) (_("Dwarf Error: mangled line number section."));
bfd_set_error (bfd_error_bad_value);