This is the mail archive of the binutils@sources.redhat.com 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] Put SHT_GROUP sections first.


ELF sections of type SHT_GROUP must be placed in the section header table 
before sections that are members of the group they describe.

It appears that when we assign section indices elf_sec_group has not yet been 
initialized, so I just put SHT_GROUP sections before all other sections.

Tested on i686-linux --enable-targets=all.
Ok?

Paul

2004-11-24  Paul Brook  <paul@codesourcery.com>

bfd/
 * elf.c (assign_section_numbers): Number SHT_GROUP sections first.
gas/testsuite/
 * gas/elf/group0a.d: Adjust expected secion ordering.
 * gas/elf/group1a.d: Ditto.
 * gas/elf/section4.d: Ditto.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.253
diff -u -p -r1.253 elf.c
--- bfd/elf.c	15 Nov 2004 23:21:23 -0000	1.253
+++ bfd/elf.c	24 Nov 2004 14:46:03 -0000
@@ -2725,18 +2725,35 @@ assign_section_numbers (bfd *abfd)
   unsigned int section_number, secn;
   Elf_Internal_Shdr **i_shdrp;
   bfd_size_type amt;
+  struct bfd_elf_section_data *d;
 
   section_number = 1;
 
   _bfd_elf_strtab_clear_all_refs (elf_shstrtab (abfd));
 
+  /* Put SHT_GROUP sections first.  */
   for (sec = abfd->sections; sec; sec = sec->next)
     {
-      struct bfd_elf_section_data *d = elf_section_data (sec);
+      d = elf_section_data (sec);
 
-      if (section_number == SHN_LORESERVE)
-	section_number += SHN_HIRESERVE + 1 - SHN_LORESERVE;
-      d->this_idx = section_number++;
+      if (d->this_hdr.sh_type == SHT_GROUP)
+	{
+	  if (section_number == SHN_LORESERVE)
+	    section_number += SHN_HIRESERVE + 1 - SHN_LORESERVE;
+	  d->this_idx = section_number++;
+	}
+    }
+
+  for (sec = abfd->sections; sec; sec = sec->next)
+    {
+      d = elf_section_data (sec);
+
+      if (d->this_hdr.sh_type != SHT_GROUP)
+	{
+	  if (section_number == SHN_LORESERVE)
+	    section_number += SHN_HIRESERVE + 1 - SHN_LORESERVE;
+	  d->this_idx = section_number++;
+	}
       _bfd_elf_strtab_addref (elf_shstrtab (abfd), d->this_hdr.sh_name);
       if ((sec->flags & SEC_RELOC) == 0)
 	d->rel_idx = 0;
Index: gas/testsuite/gas/elf/group0a.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/elf/group0a.d,v
retrieving revision 1.1
diff -u -p -r1.1 group0a.d
--- gas/testsuite/gas/elf/group0a.d	27 Apr 2004 03:59:09 -0000	1.1
+++ gas/testsuite/gas/elf/group0a.d	24 Nov 2004 14:46:05 -0000
@@ -3,7 +3,8 @@
 #source: group0.s
 
 #...
+[ 	]*\[.*\][ 	]+\.foo_group[ 	]+GROUP.*
+#...
 [ 	]*\[.*\][ 	]+\.foo[ 	]+PROGBITS.*[ 	]+AXG[ 	]+.*
 [ 	]*\[.*\][ 	]+\.bar[ 	]+PROGBITS.*[ 	]+AG[ 	]+.*
-[ 	]*\[.*\][ 	]+\.foo_group[ 	]+GROUP.*
 #pass
Index: gas/testsuite/gas/elf/group1a.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/elf/group1a.d,v
retrieving revision 1.1
diff -u -p -r1.1 group1a.d
--- gas/testsuite/gas/elf/group1a.d	30 Apr 2004 16:47:46 -0000	1.1
+++ gas/testsuite/gas/elf/group1a.d	24 Nov 2004 14:46:05 -0000
@@ -3,8 +3,9 @@
 #source: group1.s
 
 #...
+[ 	]*\[.*\][ 	]+\.foo_group[ 	]+GROUP.*
+#...
 [ 	]*\[.*\][ 	]+\.text[ 	]+PROGBITS.*[ 	]+AX[ 	]+.*
 #...
 [ 	]*\[.*\][ 	]+\.text[ 	]+PROGBITS.*[ 	]+AXG[ 	]+.*
-[ 	]*\[.*\][ 	]+\.foo_group[ 	]+GROUP.*
 #pass
Index: gas/testsuite/gas/elf/section4.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/elf/section4.d,v
retrieving revision 1.1
diff -u -p -r1.1 section4.d
--- gas/testsuite/gas/elf/section4.d	11 May 2004 15:53:47 -0000	1.1
+++ gas/testsuite/gas/elf/section4.d	24 Nov 2004 14:46:05 -0000
@@ -2,11 +2,11 @@
 #name: label arithmetic with multiple same-name sections
 
 #...
+[ 	]*\[.*\][ 	]+foo[ 	]+GROUP.*
+#...
 [ 	]*\[.*\][ 	]+\.text[ 	]+PROGBITS.*
 #...
 [ 	]*\[.*\][ 	]+\.data[ 	]+PROGBITS.*
 #...
 [ 	]*\[.*\][ 	]+\.text[ 	]+PROGBITS.*
-#...
-[ 	]*\[.*\][ 	]+foo[ 	]+GROUP.*
 #pass

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