* [patch] Put SHT_GROUP sections first.
@ 2004-11-24 17:03 Paul Brook
2004-11-24 17:17 ` H. J. Lu
2004-11-24 22:33 ` Alan Modra
0 siblings, 2 replies; 4+ messages in thread
From: Paul Brook @ 2004-11-24 17:03 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 595 bytes --]
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.
[-- Attachment #2: patch.group_shdr --]
[-- Type: text/x-diff, Size: 3318 bytes --]
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Put SHT_GROUP sections first.
2004-11-24 17:03 [patch] Put SHT_GROUP sections first Paul Brook
@ 2004-11-24 17:17 ` H. J. Lu
2004-11-24 17:55 ` Paul Brook
2004-11-24 22:33 ` Alan Modra
1 sibling, 1 reply; 4+ messages in thread
From: H. J. Lu @ 2004-11-24 17:17 UTC (permalink / raw)
To: Paul Brook; +Cc: binutils
On Wed, Nov 24, 2004 at 05:02:37PM +0000, Paul Brook wrote:
> ELF sections of type SHT_GROUP must be placed in the section header table
> before sections that are members of the group they describe.
Icc does that. But I think ld can handle either case now. Did you see a
problem with the current behavior?
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Put SHT_GROUP sections first.
2004-11-24 17:17 ` H. J. Lu
@ 2004-11-24 17:55 ` Paul Brook
0 siblings, 0 replies; 4+ messages in thread
From: Paul Brook @ 2004-11-24 17:55 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils
On Wednesday 24 November 2004 17:17, H. J. Lu wrote:
> On Wed, Nov 24, 2004 at 05:02:37PM +0000, Paul Brook wrote:
> > ELF sections of type SHT_GROUP must be placed in the section header table
> > before sections that are members of the group they describe.
>
> Icc does that. But I think ld can handle either case now. Did you see a
> problem with the current behavior?
Yes, it causes a third party armlink to segfault.
It's also an explicit requirement of the SysV ABI.
Paul
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Put SHT_GROUP sections first.
2004-11-24 17:03 [patch] Put SHT_GROUP sections first Paul Brook
2004-11-24 17:17 ` H. J. Lu
@ 2004-11-24 22:33 ` Alan Modra
1 sibling, 0 replies; 4+ messages in thread
From: Alan Modra @ 2004-11-24 22:33 UTC (permalink / raw)
To: Paul Brook; +Cc: binutils
On Wed, Nov 24, 2004 at 05:02:37PM +0000, Paul Brook wrote:
> ELF sections of type SHT_GROUP must be placed in the section header table
> before sections that are members of the group they describe.
That's true according to the ELF gABI. However, as HJ said, ld can
handle them in any order. Patch OK.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-11-24 22:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-24 17:03 [patch] Put SHT_GROUP sections first Paul Brook
2004-11-24 17:17 ` H. J. Lu
2004-11-24 17:55 ` Paul Brook
2004-11-24 22:33 ` Alan Modra
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).