PATCH: PR gas/10531: Strange assembler warning message on section group
H.J. Lu
hjl.tools@gmail.com
Fri Aug 21 04:26:00 GMT 2009
On Thu, Aug 20, 2009 at 2:08 PM, Jim Wilson<wilson@codesourcery.com> wrote:
> On Wed, 2009-08-19 at 18:20 -0700, H.J. Lu wrote:
>> I didn't see the problem with my icc, using the patched
>> assembler. Can you provide main.s compiled by your icc?
>
> I tried your patch. Gas isn't emitting a spurious warning anymore, but
> it is still emitting bogus debug info, which is what I expected.
>
> To see the problem, just put a breakpoint in the function
> out_debug_line. You will see that we hit the breakpoint, even though we
> should not, because the input assembly file already has a fully
> populated debug_line section.
>
> You patch is doing something useful; it is making sure that gas picks up
> up the correct (non-comdat) debug_line section. But it doesn't stop gas
> from emitting the bogus debug info.
>
> Jim
>
Hi Jim,
I think we have been generate bogus debug line info forever when .loc
directive isn't used. Does it patch make any senses?
Thanks.
--
H.J.
----
bfd/
2009-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* section.c: Include "elf-bfd.h".
(bfd_get_section_by_name): Don't use a section in a section
group.
(bfd_make_section_old_way): Likewise.
binutils/testsuite/
2009-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* binutils-all/objdump.W: Remove bogus line debug info.
gas/
2009-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* dwarf2dbg.c (dwarf2_loc_directive_used): New.
(dwarf2_directive_loc): Set dwarf2_loc_directive_used.
(dwarf2_loc_directive_used): Likewise.
(dwarf2_finish): Return if -g isn't passed nor any .loc
directive is used.
* subsegs.c (subseg_get): Don't compare segment name.
gas/testsuite/
2009-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* gas/elf/group2.d: New.
* gas/elf/group2.s: Likewise.
* gas/elf/elf.exp: Run group2.
-------------- next part --------------
bfd/
2009-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* section.c: Include "elf-bfd.h".
(bfd_get_section_by_name): Don't use a section in a section
group.
(bfd_make_section_old_way): Likewise.
binutils/testsuite/
2009-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* binutils-all/objdump.W: Remove bogus line debug info.
gas/
2009-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* dwarf2dbg.c (dwarf2_loc_directive_used): New.
(dwarf2_directive_loc): Set dwarf2_loc_directive_used.
(dwarf2_loc_directive_used): Likewise.
(dwarf2_finish): Return if -g isn't passed nor any .loc
directive is used.
* subsegs.c (subseg_get): Don't compare segment name.
gas/testsuite/
2009-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* gas/elf/group2.d: New.
* gas/elf/group2.s: Likewise.
* gas/elf/elf.exp: Run group2.
Index: binutils/gas/dwarf2dbg.c
===================================================================
--- binutils/gas/dwarf2dbg.c (revision 6552)
+++ binutils/gas/dwarf2dbg.c (working copy)
@@ -188,6 +188,9 @@ static unsigned int dirs_allocated;
doing work when there's nothing to do. */
bfd_boolean dwarf2_loc_directive_seen;
+/* TRUE when any .loc directive is used. */
+static bfd_boolean dwarf2_loc_directive_used;
+
/* TRUE when we're supposed to set the basic block mark whenever a
label is seen. */
bfd_boolean dwarf2_loc_mark_labels;
@@ -688,6 +691,7 @@ dwarf2_directive_loc (int dummy ATTRIBUT
demand_empty_rest_of_line ();
dwarf2_loc_directive_seen = TRUE;
+ dwarf2_loc_directive_used = TRUE;
debug_type = DEBUG_NONE;
}
@@ -706,6 +710,8 @@ dwarf2_directive_loc_mark_labels (int du
dwarf2_loc_mark_labels = value != 0;
demand_empty_rest_of_line ();
}
+
+ dwarf2_loc_directive_used = TRUE;
}
static struct frag *
@@ -1718,6 +1724,11 @@ dwarf2_finish (void)
segT info_seg;
int emit_other_sections = 0;
+ /* Return if -g isn't passed nor any .loc directive is used. */
+ if (!dwarf2_loc_directive_used
+ && (debug_type == DEBUG_UNSPECIFIED || debug_type == DEBUG_NONE))
+ return;
+
info_seg = bfd_get_section_by_name (stdoutput, ".debug_info");
emit_other_sections = info_seg == NULL || !seg_not_empty_p (info_seg);
Index: binutils/gas/testsuite/gas/elf/group2.s
===================================================================
--- binutils/gas/testsuite/gas/elf/group2.s (revision 0)
+++ binutils/gas/testsuite/gas/elf/group2.s (revision 0)
@@ -0,0 +1,10 @@
+ .section .debug_info,"G",%progbits,foo,comdat
+ .byte 0x0
+ .section .debug_line,"G",%progbits,foo,comdat
+ .byte 0x0
+ .section .debug_abbrev,"G",@progbits,foo,comdat
+ .byte 0x0
+ .section .debug_ranges,"G",@progbits,foo,comdat
+ .byte 0x0
+ .section .gnu.linkonce.t.foo, "xaG",@progbits,foo,comdat
+ nop
Index: binutils/gas/testsuite/gas/elf/group2.d
===================================================================
--- binutils/gas/testsuite/gas/elf/group2.d (revision 0)
+++ binutils/gas/testsuite/gas/elf/group2.d (revision 0)
@@ -0,0 +1,14 @@
+#as:
+#readelf: -SWg
+#name: group section with debug sections
+
+
+#...
+COMDAT group section \[ 1\] `foo' \[foo\] contains 5 sections:
+[ ]+\[Index\][ ]+Name
+[ ]+\[.*\][ ]+.debug_info
+[ ]+\[.*\][ ]+.debug_line
+[ ]+\[.*\][ ]+.debug_abbrev
+[ ]+\[.*\][ ]+.debug_ranges
+[ ]+\[.*\][ ]+.gnu.linkonce.t.foo
+#pass
Index: binutils/gas/testsuite/gas/elf/elf.exp
===================================================================
--- binutils/gas/testsuite/gas/elf/elf.exp (revision 6552)
+++ binutils/gas/testsuite/gas/elf/elf.exp (working copy)
@@ -100,6 +100,7 @@ if { ([istarget "*-*-*elf*"]
run_dump_test "group0b"
run_dump_test "group1a"
run_dump_test "group1b"
+ run_dump_test "group2"
case $target_triplet in {
{ alpha*-*-* } { }
{ cr16*-*-* } { }
Index: binutils/gas/subsegs.c
===================================================================
--- binutils/gas/subsegs.c (revision 6552)
+++ binutils/gas/subsegs.c (working copy)
@@ -148,15 +148,6 @@ subseg_get (const char *segname, int for
{
segT secptr;
segment_info_type *seginfo;
- const char *now_seg_name = (now_seg
- ? bfd_get_section_name (stdoutput, now_seg)
- : 0);
-
- if (!force_new
- && now_seg_name
- && (now_seg_name == segname
- || !strcmp (now_seg_name, segname)))
- return now_seg;
if (!force_new)
secptr = bfd_make_section_old_way (stdoutput, segname);
Index: binutils/binutils/testsuite/binutils-all/objdump.W
===================================================================
--- binutils/binutils/testsuite/binutils-all/objdump.W (revision 6552)
+++ binutils/binutils/testsuite/binutils-all/objdump.W (working copy)
@@ -73,36 +73,6 @@ Raw dump of debug contents of section .d
Extended opcode 1: End of Sequence
- Offset: 0x42
- Length: 25
- DWARF Version: 2
- Prologue Length: 19
- Minimum Instruction Length: [1248]
- Initial value of 'is_stmt': 1
- Line Base: -5
- Line Range: 14
- Opcode Base: 13
-
- Opcodes:
- Opcode 1 has 0 args
- Opcode 2 has 1 args
- Opcode 3 has 1 args
- Opcode 4 has 1 args
- Opcode 5 has 1 args
- Opcode 6 has 0 args
- Opcode 7 has 0 args
- Opcode 8 has 0 args
- Opcode 9 has 1 args
- Opcode 10 has 0 args
- Opcode 11 has 0 args
- Opcode 12 has 1 args
-
- The Directory Table is empty.
-
- The File Name Table is empty.
-
- Line Number Statements:
-
Contents of the .zdebug_abbrev section:
Number TAG
Index: binutils/bfd/section.c
===================================================================
--- binutils/bfd/section.c (revision 6552)
+++ binutils/bfd/section.c (working copy)
@@ -138,6 +138,7 @@ SUBSECTION
#include "bfd.h"
#include "libbfd.h"
#include "bfdlink.h"
+#include "elf-bfd.h"
/*
DOCDD
@@ -854,11 +855,31 @@ asection *
bfd_get_section_by_name (bfd *abfd, const char *name)
{
struct section_hash_entry *sh;
+ unsigned long hash;
+ asection *sec;
sh = section_hash_lookup (&abfd->section_htab, name, FALSE, FALSE);
- if (sh != NULL)
+ if (sh == NULL)
+ return NULL;
+
+ /* Only ELF has section group. */
+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
return &sh->section;
+ hash = sh->root.hash;
+ do
+ {
+ sec = &sh->section;
+ /* Don't return a section in a section group. */
+ if (elf_section_data (sec) == NULL
+ || elf_group_name (sec) == NULL)
+ return sec;
+ sh = (struct section_hash_entry *) sh->root.next;
+ }
+ while (sh != NULL
+ && sh->root.hash == hash
+ && strcmp (sh->root.string, name) == 0);
+
return NULL;
}
@@ -1011,7 +1032,43 @@ bfd_make_section_old_way (bfd *abfd, con
if (sh == NULL)
return NULL;
- newsect = &sh->section;
+ /* Only ELF has section group. */
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+ {
+ struct section_hash_entry *old_sh = sh;
+ unsigned long hash = sh->root.hash;
+
+ do
+ {
+ newsect = &sh->section;
+ /* Don't use a section in a section group. */
+ if (elf_section_data (newsect) == NULL
+ || elf_group_name (newsect) == NULL)
+ break;
+ sh = (struct section_hash_entry *) sh->root.next;
+ }
+ while (sh != NULL
+ && sh->root.hash == hash
+ && strcmp (sh->root.string, name) == 0);
+
+ if (sh == NULL)
+ {
+ /* Allocate a new one since existing sections are in
+ section groups. */
+ struct section_hash_entry *new_sh;
+ new_sh = (struct section_hash_entry *)
+ bfd_section_hash_newfunc (NULL, &abfd->section_htab, name);
+ if (new_sh == NULL)
+ return NULL;
+
+ new_sh->root = old_sh->root;
+ old_sh->root.next = &new_sh->root;
+ newsect = &new_sh->section;
+ }
+ }
+ else
+ newsect = &sh->section;
+
if (newsect->name != NULL)
{
/* Section already exists. */
More information about the Binutils
mailing list