PATCH: PR gas/10531: Strange assembler warning message on section group
H.J. Lu
hjl.tools@gmail.com
Tue Aug 18 18:48:00 GMT 2009
On Tue, Aug 18, 2009 at 10:52 AM, Daniel Jacobowitz<drow@false.org> wrote:
> On Tue, Aug 18, 2009 at 10:19:25AM -0700, H.J. Lu wrote:
>> Well, there is only a string to identify a section. For ELF, we also
>> need to check the group name. Do you have a better name for
>> the new function?
>
> Then either fix that (non-string way to represent the section), or
> better explain what you actually need. Do you need "the section named
> .stab that is not in any group"? Maybe that could be called the
> 'default section' for a given name.
>
Here is an updated patch to avoid compare segment name in
subseg_get.
Thanks.
--
H.J.
bfd/
2009-08-18 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.
gas/
2009-08-18 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* subsegs.c (subseg_get): Don't compare segment name.
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.
-------------- next part --------------
bfd/
2009-08-18 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.
gas/
2009-08-18 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10531
* subsegs.c (subseg_get): Don't compare segment name.
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.
Index: gas/testsuite/gas/i386/i386.exp
===================================================================
--- gas/testsuite/gas/i386/i386.exp (revision 6552)
+++ gas/testsuite/gas/i386/i386.exp (working copy)
@@ -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: gas/testsuite/gas/i386/debug1.d
===================================================================
--- gas/testsuite/gas/i386/debug1.d (revision 0)
+++ gas/testsuite/gas/i386/debug1.d (revision 0)
@@ -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
Index: gas/testsuite/gas/i386/debug1.s
===================================================================
--- gas/testsuite/gas/i386/debug1.s (revision 0)
+++ gas/testsuite/gas/i386/debug1.s (revision 0)
@@ -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
Index: gas/testsuite/gas/elf/group2.s
===================================================================
--- gas/testsuite/gas/elf/group2.s (revision 0)
+++ gas/testsuite/gas/elf/group2.s (revision 0)
@@ -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
Index: gas/testsuite/gas/elf/group2.d
===================================================================
--- gas/testsuite/gas/elf/group2.d (revision 0)
+++ gas/testsuite/gas/elf/group2.d (revision 0)
@@ -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
Index: gas/testsuite/gas/elf/elf.exp
===================================================================
--- gas/testsuite/gas/elf/elf.exp (revision 6552)
+++ 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: gas/subsegs.c
===================================================================
--- gas/subsegs.c (revision 6552)
+++ 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: bfd/section.c
===================================================================
--- bfd/section.c (revision 6552)
+++ 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