* PATCH: PR ld/4986: gas emits duplicate .loc directive from gcc 3.4.6
@ 2007-09-01 2:19 H.J. Lu
2007-09-01 3:52 ` Alan Modra
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2007-09-01 2:19 UTC (permalink / raw)
To: binutils
We just need to compare line number when we sort lines. This patch
works for me.
H.J.
----
bfd/
2007-08-31 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4986
* dwarf2.c (new_line_sorts_after): Also compare line number.
ld/testsuite/
2007-08-31 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4986
* ld-x86-64/line.exp: New
* ld-x86-64/undefined.s: Likewise.
--- binutils/bfd/dwarf2.c.dup 2007-08-31 18:03:29.000000000 -0700
+++ binutils/bfd/dwarf2.c 2007-08-31 19:00:21.000000000 -0700
@@ -917,7 +917,8 @@ new_line_sorts_after (struct line_info *
{
return (new_line->address > line->address
|| (new_line->address == line->address
- && new_line->end_sequence < line->end_sequence));
+ && (new_line->line > line->line
+ || new_line->end_sequence < line->end_sequence)));
}
--- binutils/ld/testsuite/ld-x86-64/line.exp.dup 2007-08-31 19:12:22.000000000 -0700
+++ binutils/ld/testsuite/ld-x86-64/line.exp 2007-08-31 19:10:51.000000000 -0700
@@ -0,0 +1,63 @@
+# Test that the linker reports undefined symbol line number correctly.
+#
+# Copyright 2007 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+if { !([istarget "x86_64-*-elf*"]
+ || [istarget "x86_64-*-linux*"]) } {
+ return
+}
+
+set testline "undefined line"
+
+if { ![is_remote host] && [which $CC] == 0 } {
+ verbose "Could not find C compiler!" 1
+ untested $testline
+ return
+}
+
+if ![ld_assemble $as "--64 $srcdir/$subdir/undefined.s" tmpdir/undefined.o] {
+ verbose "Unable to assemble test file!" 1
+ unresolved $testline
+ return
+}
+
+remote_file host delete "tmpdir/undefined"
+
+# Using -e start prevents the SunOS linker from trying to build a
+# shared library.
+send_log "$ld -e start -melf_x86_64 -o tmpdir/undefined tmpdir/undefined.o\n"
+set exec_output [run_host_cmd "$ld" "-e start -melf_x86_64 -o tmpdir/undefined tmpdir/undefined.o"]
+
+send_log "$exec_output\n"
+verbose "$exec_output"
+
+proc checkund { string testname } {
+ global exec_output
+
+ if [string match "*$string*" $exec_output] {
+ pass $testname
+ } else {
+ fail $testname
+ }
+}
+
+set ml "undefined.c:9: undefined reference to `*this_function_is_not_defined'"
+
+checkund $ml $testline
--- binutils/ld/testsuite/ld-x86-64/undefined.s.dup 2007-08-31 19:12:29.000000000 -0700
+++ binutils/ld/testsuite/ld-x86-64/undefined.s 2007-08-31 19:13:14.000000000 -0700
@@ -0,0 +1,154 @@
+ .file "undefined.c"
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .text
+.Ltext0:
+ .p2align 4,,15
+.globl function
+ .type function, @function
+function:
+.LFB2:
+ .file 1 "undefined.c"
+ .loc 1 8 0
+ .loc 1 9 0
+ xorl %eax, %eax
+ jmp this_function_is_not_defined
+.LFE2:
+ .size function, .-function
+ .section .debug_frame,"",@progbits
+.Lframe0:
+ .long .LECIE0-.LSCIE0
+.LSCIE0:
+ .long 0xffffffff
+ .byte 0x1
+ .string ""
+ .uleb128 0x1
+ .sleb128 -8
+ .byte 0x10
+ .byte 0xc
+ .uleb128 0x7
+ .uleb128 0x8
+ .byte 0x90
+ .uleb128 0x1
+ .align 8
+.LECIE0:
+.LSFDE0:
+ .long .LEFDE0-.LASFDE0
+.LASFDE0:
+ .long .Lframe0
+ .quad .LFB2
+ .quad .LFE2-.LFB2
+ .align 8
+.LEFDE0:
+ .text
+.Letext0:
+ .section .debug_info
+ .long 0x4c
+ .value 0x2
+ .long .Ldebug_abbrev0
+ .byte 0x8
+ .uleb128 0x1
+ .long .Ldebug_line0
+ .quad .Letext0
+ .quad .Ltext0
+ .long .LASF0
+ .byte 0x1
+ .long .LASF1
+ .uleb128 0x2
+ .byte 0x1
+ .long .LASF2
+ .byte 0x1
+ .byte 0x8
+ .long 0x48
+ .quad .LFB2
+ .quad .LFE2
+ .byte 0x2
+ .byte 0x77
+ .sleb128 8
+ .uleb128 0x3
+ .string "int"
+ .byte 0x4
+ .byte 0x5
+ .byte 0x0
+ .section .debug_abbrev
+ .uleb128 0x1
+ .uleb128 0x11
+ .byte 0x1
+ .uleb128 0x10
+ .uleb128 0x6
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x25
+ .uleb128 0xe
+ .uleb128 0x13
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0xe
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x2
+ .uleb128 0x2e
+ .byte 0x0
+ .uleb128 0x3f
+ .uleb128 0xc
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x40
+ .uleb128 0xa
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0x24
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .byte 0x0
+ .byte 0x0
+ .byte 0x0
+ .section .debug_pubnames,"",@progbits
+ .long 0x1b
+ .value 0x2
+ .long .Ldebug_info0
+ .long 0x50
+ .long 0x29
+ .string "function"
+ .long 0x0
+ .section .debug_aranges,"",@progbits
+ .long 0x2c
+ .value 0x2
+ .long .Ldebug_info0
+ .byte 0x8
+ .byte 0x0
+ .value 0x0
+ .value 0x0
+ .quad .Ltext0
+ .quad .Letext0-.Ltext0
+ .quad 0x0
+ .quad 0x0
+ .section .debug_str,"MS",@progbits,1
+.LASF0:
+ .string "GNU C 3.4.6"
+.LASF1:
+ .string "undefined.c"
+.LASF2:
+ .string "function"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: PR ld/4986: gas emits duplicate .loc directive from gcc 3.4.6
2007-09-01 2:19 PATCH: PR ld/4986: gas emits duplicate .loc directive from gcc 3.4.6 H.J. Lu
@ 2007-09-01 3:52 ` Alan Modra
2007-09-01 13:04 ` H.J. Lu
0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2007-09-01 3:52 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils
On Fri, Aug 31, 2007 at 07:18:55PM -0700, H.J. Lu wrote:
> bfd/
>
> 2007-08-31 H.J. Lu <hongjiu.lu@intel.com>
>
> PR ld/4986
> * dwarf2.c (new_line_sorts_after): Also compare line number.
>
> ld/testsuite/
>
> 2007-08-31 H.J. Lu <hongjiu.lu@intel.com>
>
> PR ld/4986
> * ld-x86-64/line.exp: New
> * ld-x86-64/undefined.s: Likewise.
OK.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: PR ld/4986: gas emits duplicate .loc directive from gcc 3.4.6
2007-09-01 3:52 ` Alan Modra
@ 2007-09-01 13:04 ` H.J. Lu
2007-09-02 2:32 ` Alan Modra
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2007-09-01 13:04 UTC (permalink / raw)
To: binutils
On Sat, Sep 01, 2007 at 01:22:15PM +0930, Alan Modra wrote:
> On Fri, Aug 31, 2007 at 07:18:55PM -0700, H.J. Lu wrote:
> > bfd/
> >
> > 2007-08-31 H.J. Lu <hongjiu.lu@intel.com>
> >
> > PR ld/4986
> > * dwarf2.c (new_line_sorts_after): Also compare line number.
> >
> > ld/testsuite/
> >
> > 2007-08-31 H.J. Lu <hongjiu.lu@intel.com>
> >
> > PR ld/4986
> > * ld-x86-64/line.exp: New
> > * ld-x86-64/undefined.s: Likewise.
>
> OK.
>
Unforuntately, it doesn't work for Linux/ia64. Basically we
have to remove duplicate .loc entries in linker. This patch
implements it. I tested it on Linux/ia32, Linux/x86-64 and
Linux/ia64 with gcc 3.4.6 and gcc 4.1.2.
H.J.
----
bfd/
2007-09-01 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4986
* dwarf2.c (new_line_sorts_after): Undo the last change.
(add_line_info): Only keep the last entry with the same address
and end sequence.
ld/testsuite/
2007-09-01 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4986
* ld-ia64/line.exp: New.
* ld-ia64/undefined.s: Likewise.
* ld-x86-64/line.exp: Don't check CC.
--- binutils/bfd/dwarf2.c.foo 2007-09-01 05:15:37.000000000 -0700
+++ binutils/bfd/dwarf2.c 2007-09-01 05:49:27.000000000 -0700
@@ -917,8 +917,7 @@ new_line_sorts_after (struct line_info *
{
return (new_line->address > line->address
|| (new_line->address == line->address
- && (new_line->line > line->line
- || new_line->end_sequence < line->end_sequence)));
+ && new_line->end_sequence < line->end_sequence));
}
@@ -968,7 +967,18 @@ add_line_info (struct line_info_table *t
Note: we may receive duplicate entries from 'decode_line_info'. */
- if (!table->last_line
+ if (table->last_line
+ && table->last_line->address == address
+ && table->last_line->end_sequence == end_sequence)
+ {
+ /* We only keep the last entry with the same address and end
+ sequence. See PR ld/4986. */
+ if (table->lcl_head == table->last_line)
+ table->lcl_head = info;
+ info->prev_line = table->last_line->prev_line;
+ table->last_line = info;
+ }
+ else if (!table->last_line
|| new_line_sorts_after (info, table->last_line))
{
/* Normal case: add 'info' to the beginning of the list */
--- binutils/ld/testsuite/ld-ia64/line.exp.foo 2007-09-01 05:50:45.000000000 -0700
+++ binutils/ld/testsuite/ld-ia64/line.exp 2007-09-01 05:26:46.000000000 -0700
@@ -0,0 +1,57 @@
+# Test that the linker reports undefined symbol line number correctly.
+#
+# Copyright 2007 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+if { !([istarget "ia64-*-elf*"]
+ || [istarget "ia64-*-linux*"]) } {
+ return
+}
+
+set testline "undefined line"
+
+if ![ld_assemble $as "-x $srcdir/$subdir/undefined.s" tmpdir/undefined.o] {
+ verbose "Unable to assemble test file!" 1
+ unresolved $testline
+ return
+}
+
+remote_file host delete "tmpdir/undefined"
+
+# Using -e start prevents the SunOS linker from trying to build a
+# shared library.
+send_log "$ld -e start -o tmpdir/undefined tmpdir/undefined.o\n"
+set exec_output [run_host_cmd "$ld" "-e start -o tmpdir/undefined tmpdir/undefined.o"]
+
+send_log "$exec_output\n"
+verbose "$exec_output"
+
+proc checkund { string testname } {
+ global exec_output
+
+ if [string match "*$string*" $exec_output] {
+ pass $testname
+ } else {
+ fail $testname
+ }
+}
+
+set ml "undefined.c:9: undefined reference to `*this_function_is_not_defined'"
+
+checkund $ml $testline
--- binutils/ld/testsuite/ld-ia64/undefined.s.foo 2007-09-01 05:50:37.000000000 -0700
+++ binutils/ld/testsuite/ld-ia64/undefined.s 2007-09-01 05:19:53.000000000 -0700
@@ -0,0 +1,152 @@
+ .file "undefined.c"
+ .pred.safe_across_calls p1-p5,p16-p63
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .text
+.Ltext0:
+ .align 16
+ .global function#
+ .proc function#
+function:
+[.LFB2:]
+ .file 1 "undefined.c"
+ .loc 1 8 0
+ .prologue 12, 32
+ .mii
+ .save ar.pfs, r33
+ alloc r33 = ar.pfs, 0, 3, 0, 0
+ .save rp, r32
+ mov r32 = b0
+ mov r34 = r1
+ .body
+ .loc 1 9 0
+ ;;
+ .mib
+ nop 0
+ nop 0
+ br.call.sptk.many b0 = this_function_is_not_defined#
+ .loc 1 10 0
+ ;;
+ .loc 1 9 0
+ .mmi
+ nop 0
+ mov r1 = r34
+ .loc 1 10 0
+ mov b0 = r32
+ .mib
+ nop 0
+ mov ar.pfs = r33
+ br.ret.sptk.many b0
+.LFE2:
+ .endp function#
+.Letext0:
+ .section .debug_info
+ data4.ua 0x4c
+ data2.ua 0x2
+ data4.ua @secrel(.Ldebug_abbrev0)
+ data1 0x8
+ .uleb128 0x1
+ data4.ua @secrel(.Ldebug_line0)
+ data8.ua .Letext0
+ data8.ua .Ltext0
+ data4.ua @secrel(.LASF0)
+ data1 0x1
+ data4.ua @secrel(.LASF1)
+ .uleb128 0x2
+ data1 0x1
+ data4.ua @secrel(.LASF2)
+ data1 0x1
+ data1 0x8
+ data4.ua 0x48
+ data8.ua .LFB2
+ data8.ua .LFE2
+ data1 0x2
+ data1 0x7c
+ .sleb128 16
+ .uleb128 0x3
+ stringz "int"
+ data1 0x4
+ data1 0x5
+ data1 0x0
+ .section .debug_abbrev
+ .uleb128 0x1
+ .uleb128 0x11
+ data1 0x1
+ .uleb128 0x10
+ .uleb128 0x6
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x25
+ .uleb128 0xe
+ .uleb128 0x13
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0xe
+ data1 0x0
+ data1 0x0
+ .uleb128 0x2
+ .uleb128 0x2e
+ data1 0x0
+ .uleb128 0x3f
+ .uleb128 0xc
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x40
+ .uleb128 0xa
+ data1 0x0
+ data1 0x0
+ .uleb128 0x3
+ .uleb128 0x24
+ data1 0x0
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ data1 0x0
+ data1 0x0
+ data1 0x0
+ .section .debug_pubnames,"",@progbits
+ data4.ua 0x1b
+ data2.ua 0x2
+ data4.ua @secrel(.Ldebug_info0)
+ data4.ua 0x50
+ data4.ua 0x29
+ stringz "function"
+ data4.ua 0x0
+ .section .debug_aranges,"",@progbits
+ data4.ua 0x2c
+ data2.ua 0x2
+ data4.ua @secrel(.Ldebug_info0)
+ data1 0x8
+ data1 0x0
+ data2.ua 0x0
+ data2.ua 0x0
+ data8.ua .Ltext0
+ data8.ua .Letext0-.Ltext0
+ data8.ua 0x0
+ data8.ua 0x0
+ .section .debug_str,"MS",@progbits,1
+.LASF0:
+ stringz "GNU C 4.1.2"
+.LASF1:
+ stringz "undefined.c"
+.LASF2:
+ stringz "function"
--- binutils/ld/testsuite/ld-x86-64/line.exp.foo 2007-08-31 23:09:20.000000000 -0700
+++ binutils/ld/testsuite/ld-x86-64/line.exp 2007-09-01 05:25:00.000000000 -0700
@@ -26,12 +26,6 @@ if { !([istarget "x86_64-*-elf*"]
set testline "undefined line"
-if { ![is_remote host] && [which $CC] == 0 } {
- verbose "Could not find C compiler!" 1
- untested $testline
- return
-}
-
if ![ld_assemble $as "--64 $srcdir/$subdir/undefined.s" tmpdir/undefined.o] {
verbose "Unable to assemble test file!" 1
unresolved $testline
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: PR ld/4986: gas emits duplicate .loc directive from gcc 3.4.6
2007-09-01 13:04 ` H.J. Lu
@ 2007-09-02 2:32 ` Alan Modra
2007-09-02 3:14 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2007-09-02 2:32 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils
On Sat, Sep 01, 2007 at 06:04:14AM -0700, H.J. Lu wrote:
> Basically we
> have to remove duplicate .loc entries in linker.
Eh? I thought the whole point of Daniel's patch was to keep them.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: PR ld/4986: gas emits duplicate .loc directive from gcc 3.4.6
2007-09-02 2:32 ` Alan Modra
@ 2007-09-02 3:14 ` Daniel Jacobowitz
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2007-09-02 3:14 UTC (permalink / raw)
To: H.J. Lu, binutils
On Sun, Sep 02, 2007 at 12:02:26PM +0930, Alan Modra wrote:
> On Sat, Sep 01, 2007 at 06:04:14AM -0700, H.J. Lu wrote:
> > Basically we
> > have to remove duplicate .loc entries in linker.
>
> Eh? I thought the whole point of Daniel's patch was to keep them.
Mine was a gas patch, to output the duplicates - GDB cares about them.
HJ's is for the dwarf2 reader that addr2line and ld's error messages
use.
ld's only ever interested in the code -> location mapping. In that
direction, the duplicates aren't useful; the last one from the input
is the only one we need. The patch looks plausible to me.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-09-02 3:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-01 2:19 PATCH: PR ld/4986: gas emits duplicate .loc directive from gcc 3.4.6 H.J. Lu
2007-09-01 3:52 ` Alan Modra
2007-09-01 13:04 ` H.J. Lu
2007-09-02 2:32 ` Alan Modra
2007-09-02 3:14 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).