This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR gas/10531: Strange assembler warning message on section group


Hi,

We can't use bfd_get_section_by_name, subseg_new and subseg_get directly
in dwarf2dbg.c since they don't know ELF section groups.  This patch adds
obj_get_section_by_name, obj_subseg_new and obj_subseg_get.  Tested on
Linux/ia32, Linux/ia64 and Linux/Intel64.  OK to install?

Thanks.


H.J.
----
gas/

2009-08-18  H.J. Lu  <hongjiu.lu@intel.com>

	 PR gas/10531
	 * dwarf2dbg.c (obj_get_section_by_name): New.
	 (obj_subseg_new): Likewise.
	 (obj_subseg_get): Likewise.
	 (emit_fixed_inc_line_addr): Use obj_subseg_get instead of
	 subseg_get.
	 (dwarf2_finish): Use obj_get_section_by_name instead of
	 bfd_get_section_by_name.  Use obj_subseg_new instead of
	 subseg_get.

	 * config/obj-elf.c (obj_elf_get_section_by_name): New.
	 (obj_elf_subseg_new): Likewise.
	 (obj_elf_subseg_get): Likewise.
	 * config/obj-elf.c (obj_get_section_by_name): Likewise.
	 (obj_subseg_new): Likewise.
	 (obj_subseg_get): Likewise.
	 (obj_elf_get_section_by_name): Likewise.
	 (obj_elf_subseg_new): Likewise.
	 (obj_elf_subseg_get): Likewise.

gas/testsuite/

2009-08-18  H.J. Lu  <hongjiu.lu@intel.com>

	 PR gas/10531
	 * gas/elf/group2.d: New.
	 * gas/elf/group2.s: Likewise.
	 * gas/i386/debug1.d: Likewise.
	 * gas/i386/debug1.s: Likewise.

	* gas/elf/elf.exp: Run group2.

	* gas/i386/i386.exp: Run debug1 for both 32bit and 64bit.

--- gas/config/obj-elf.c.dw2	2009-08-17 14:03:39.000000000 -0700
+++ gas/config/obj-elf.c	2009-08-17 15:54:33.000000000 -0700
@@ -550,6 +550,43 @@ get_section (bfd *abfd ATTRIBUTE_UNUSED,
 	      && strcmp (group_name, gname) == 0));
 }
 
+/* Similar to bfd_get_section_by_name.  Don't return a section in a
+   section group.  */
+
+asection *
+obj_elf_get_section_by_name (bfd *abfd, const char *name)
+{
+  return bfd_get_section_by_name_if (abfd, name, get_section, NULL);
+}
+
+/* Similar to subseg_new.  Don't return a section in a section group.  */
+
+segT
+obj_elf_subseg_new (const char *segname, subsegT subseg)
+{
+  segT sec;
+
+  if (bfd_get_section_by_name_if (stdoutput, segname, get_section,
+				  NULL) != NULL)
+    sec = subseg_new (segname, subseg);
+  else
+    sec = subseg_force_new (segname, subseg);
+  return sec;
+}
+
+/* Similar to subseg_get.  Don't return a section in a section group.  */
+
+segT
+obj_elf_subseg_get (const char *segname, int force_new)
+{
+  return subseg_get (segname,
+		     (force_new
+		      || bfd_get_section_by_name_if (stdoutput,
+						     segname,
+						     get_section,
+						     NULL) == NULL));
+}
+
 /* Handle the .section pseudo-op.  This code supports two different
    syntaxes.
 
--- gas/config/obj-elf.h.dw2	2009-02-03 11:30:05.000000000 -0800
+++ gas/config/obj-elf.h	2009-08-17 15:32:10.000000000 -0700
@@ -249,4 +249,19 @@ extern asection *elf_com_section_ptr;
 extern symbolS * elf_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP,
 				   addressT size);
 
+#ifndef obj_get_section_by_name
+#define obj_get_section_by_name obj_elf_get_section_by_name
+#endif
+extern asection *obj_elf_get_section_by_name (bfd *, const char *);
+
+#ifndef obj_subseg_new
+#define obj_subseg_new	obj_elf_subseg_new
+#endif
+extern segT obj_elf_subseg_new (const char *, subsegT);
+
+#ifndef obj_subseg_get
+#define obj_subseg_get	obj_elf_subseg_get
+#endif
+extern segT obj_elf_subseg_get (const char *, subsegT);
+
 #endif /* _OBJ_ELF_H */
--- gas/dwarf2dbg.c.dw2	2009-07-29 19:45:04.000000000 -0700
+++ gas/dwarf2dbg.c	2009-08-17 15:31:23.000000000 -0700
@@ -46,6 +46,19 @@
 #include "dwarf2dbg.h"
 #include <filenames.h>
 
+
+#ifndef obj_get_section_by_name
+#define obj_get_section_by_name	bfd_get_section_by_name
+#endif
+
+#ifndef obj_subseg_new
+#define obj_subseg_new	subseg_new
+#endif
+
+#ifndef obj_subseg_get
+#define obj_subseg_get	subseg_get
+#endif
+
 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
 /* We need to decide which character to use as a directory separator.
    Just because HAVE_DOS_BASED_FILE_SYSTEM is defined, it does not
@@ -1062,7 +1075,7 @@ emit_fixed_inc_line_addr (int line_delta
     }
 
   exp = symbol_get_value_expression (frag->fr_symbol);
-  line_seg = subseg_get (".debug_line", 0);
+  line_seg = obj_subseg_get (".debug_line", 0);
 
   /* The DW_LNS_fixed_advance_pc opcode has a 2-byte operand so it can
      advance the address by at most 64K.  Linker relaxation (without
@@ -1718,7 +1731,7 @@ dwarf2_finish (void)
   segT info_seg;
   int emit_other_sections = 0;
 
-  info_seg = bfd_get_section_by_name (stdoutput, ".debug_info");
+  info_seg = obj_get_section_by_name (stdoutput, ".debug_info");
   emit_other_sections = info_seg == NULL || !seg_not_empty_p (info_seg);
 
   if (!all_segs && emit_other_sections)
@@ -1730,7 +1743,7 @@ dwarf2_finish (void)
   sizeof_address = DWARF2_ADDR_SIZE (stdoutput);
 
   /* Create and switch to the line number section.  */
-  line_seg = subseg_new (".debug_line", 0);
+  line_seg = obj_subseg_new (".debug_line", 0);
   bfd_set_section_flags (stdoutput, line_seg, SEC_READONLY | SEC_DEBUGGING);
 
   /* For each subsection, chain the debug entries together.  */
@@ -1759,9 +1772,9 @@ dwarf2_finish (void)
 
       gas_assert (all_segs);
 
-      info_seg = subseg_new (".debug_info", 0);
-      abbrev_seg = subseg_new (".debug_abbrev", 0);
-      aranges_seg = subseg_new (".debug_aranges", 0);
+      info_seg = obj_subseg_new (".debug_info", 0);
+      abbrev_seg = obj_subseg_new (".debug_abbrev", 0);
+      aranges_seg = obj_subseg_new (".debug_aranges", 0);
 
       bfd_set_section_flags (stdoutput, info_seg,
 			     SEC_READONLY | SEC_DEBUGGING);
@@ -1776,7 +1789,7 @@ dwarf2_finish (void)
 	ranges_seg = NULL;
       else
 	{
-	  ranges_seg = subseg_new (".debug_ranges", 0);
+	  ranges_seg = obj_subseg_new (".debug_ranges", 0);
 	  bfd_set_section_flags (stdoutput, ranges_seg,
 				 SEC_READONLY | SEC_DEBUGGING);
 	  record_alignment (ranges_seg, ffs (2 * sizeof_address) - 1);
--- gas/testsuite/gas/elf/elf.exp.dw2	2009-08-17 16:02:32.000000000 -0700
+++ gas/testsuite/gas/elf/elf.exp	2009-08-17 15:41:32.000000000 -0700
@@ -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*-*-* } { }
--- gas/testsuite/gas/elf/group2.d.dw2	2009-08-17 15:41:27.000000000 -0700
+++ gas/testsuite/gas/elf/group2.d	2009-08-17 15:21:32.000000000 -0700
@@ -0,0 +1,16 @@
+#readelf: -SWg
+#name: group section with debug sections
+
+
+#...
+[ 	]*\[.*\][ 	]+foo[ 	]+GROUP.*
+#...
+[ 	]*\[.*\][ 	]+\.debug_info[ 	]+PROGBITS.*[ 	]+G[ 	]+.*
+[ 	]*\[.*\][ 	]+\.debug_line[ 	]+PROGBITS.*[ 	]+G[ 	]+.*
+[ 	]*\[.*\][ 	]+\.debug_line[ 	]+PROGBITS.*[ 	]+.*
+#...
+COMDAT group section \[    1\] `foo' \[foo\] contains 2 sections:
+[ 	]+\[Index\][ 	]+Name
+[ 	]+\[.*\][ 	]+.debug_info
+[ 	]+\[.*\][ 	]+.debug_line
+#pass
--- gas/testsuite/gas/elf/group2.s.dw2	2009-08-17 15:41:27.000000000 -0700
+++ gas/testsuite/gas/elf/group2.s	2009-08-17 15:22:25.000000000 -0700
@@ -0,0 +1,6 @@
+	.section .debug_info
+	.byte 0x0
+	.section .debug_info,"G",%progbits,foo,comdat
+	.byte 0x0
+	.section .debug_line,"G",%progbits,foo,comdat
+	.byte 0x0
--- gas/testsuite/gas/i386/debug1.d.dw2	2009-08-17 14:13:05.000000000 -0700
+++ gas/testsuite/gas/i386/debug1.d	2009-08-17 15:47:50.000000000 -0700
@@ -0,0 +1,19 @@
+#as: -g
+#readelf: -SWg
+#name: group section with debug sections
+
+
+#...
+[ 	]*\[.*\][ 	]+foo[ 	]+GROUP.*
+#...
+[ 	]*\[.*\][ 	]+\.debug_info[ 	]+PROGBITS.*[ 	]+G[ 	]+.*
+[ 	]*\[.*\][ 	]+\.debug_line[ 	]+PROGBITS.*[ 	]+G[ 	]+.*
+[ 	]*\[.*\][ 	]+\.debug_line[ 	]+PROGBITS.*[ 	]+.*
+#...
+[ 	]*\[.*\][ 	]+\.debug_info[ 	]+PROGBITS.*[ 	]+.*
+#...
+COMDAT group section \[    1\] `foo' \[foo\] contains 2 sections:
+[ 	]+\[Index\][ 	]+Name
+[ 	]+\[.*\][ 	]+.debug_info
+[ 	]+\[.*\][ 	]+.debug_line
+#pass
--- gas/testsuite/gas/i386/debug1.s.dw2	2009-08-17 14:13:08.000000000 -0700
+++ gas/testsuite/gas/i386/debug1.s	2009-08-17 15:40:48.000000000 -0700
@@ -0,0 +1,11 @@
+	.section .debug_info,"G",%progbits,foo,comdat
+	.byte 0x0
+	.section .debug_line,"G",%progbits,foo,comdat
+	.byte 0x0
+	.section .debug_info,"G",@progbits,foo,comdat
+	.byte 0x0
+	.section .debug_line,"G",@progbits,foo,comdat
+	.byte 0x0
+	.text
+	nop
+	nop
--- gas/testsuite/gas/i386/i386.exp.dw2	2009-07-29 19:45:07.000000000 -0700
+++ gas/testsuite/gas/i386/i386.exp	2009-08-17 15:58:49.000000000 -0700
@@ -190,6 +190,7 @@ if [expr ([istarget "i*86-*-*"] ||  [ist
 	run_list_test "inval-equ-2" "-al"
 	run_dump_test "ifunc"
 	run_list_test "l1om-inval" "-march=l1om --32"
+	run_dump_test "debug1"
     }
 
     # This is a PE specific test.
@@ -348,6 +349,7 @@ if [expr ([istarget "i*86-*-*"] || [ista
 	run_dump_test "mixed-mode-reloc64"
 	run_dump_test "x86-64-ifunc"
 	run_dump_test "l1om"
+	run_dump_test "debug1"
     }
 
     set ASFLAGS "$old_ASFLAGS"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]