* PATCH: Handle section group for ld -r
@ 2004-04-29 21:01 H. J. Lu
2004-04-30 12:28 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: H. J. Lu @ 2004-04-29 21:01 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 49 bytes --]
This patch fixes section group for ld -r.
H.J.
[-- Attachment #2: bfd-elf-group-1.patch --]
[-- Type: text/plain, Size: 2337 bytes --]
2004-04-29 H.J. Lu <hongjiu.lu@intel.com>
* elf.c (bfd_section_from_shdr): Maintain the section order in
a section group.
(special_sections): Add ".note.GNU-stack".
(elf_fake_sections): Handle section group for relocatable
link..
--- bfd/elf.c.group 2004-04-26 21:11:41.000000000 -0700
+++ bfd/elf.c 2004-04-29 13:44:31.000000000 -0700
@@ -1945,8 +1945,10 @@ bfd_section_from_shdr (bfd *abfd, unsign
hdr->bfd_section->flags
|= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
+ /* We try to keep the same section order as it comes in. */
+ idx += n_elt;
while (--n_elt != 0)
- if ((s = (++idx)->shdr->bfd_section) != NULL
+ if ((s = (--idx)->shdr->bfd_section) != NULL
&& elf_next_in_group (s) != NULL)
{
elf_next_in_group (hdr->bfd_section) = s;
@@ -2054,6 +2056,7 @@ static struct bfd_elf_special_section co
{ ".gnu.version", 12, 0, SHT_GNU_versym, 0 },
{ ".gnu.version_d", 14, 0, SHT_GNU_verdef, 0 },
{ ".gnu.version_r", 14, 0, SHT_GNU_verneed, 0 },
+ { ".note.GNU-stack",15, 0, SHT_PROGBITS, 0 },
{ ".note", 5, -1, SHT_NOTE, 0 },
{ ".rela", 5, -1, SHT_RELA, 0 },
{ ".rel", 4, -1, SHT_REL, 0 },
@@ -2386,7 +2389,31 @@ elf_fake_sections (bfd *abfd, asection *
asect->flags. */
if (this_hdr->sh_type == SHT_NULL)
{
- if ((asect->flags & SEC_ALLOC) != 0
+ if ((asect->flags & SEC_GROUP) != 0)
+ {
+ /* We also need to mark SHF_GROUP here for relocatable
+ link. */
+ struct bfd_link_order *l;
+ asection *elt;
+
+ for (l = asect->link_order_head; l != NULL; l = l->next)
+ if (l->type == bfd_indirect_link_order
+ && (elt = elf_next_in_group (l->u.indirect.section)) != NULL)
+ do
+ {
+ /* The name is not important. Anything will do. */
+ elf_group_name (elt->output_section) = "G";
+ elf_section_flags (elt->output_section) |= SHF_GROUP;
+
+ elt = elf_next_in_group (elt);
+ /* During a relocatable link, the lists are
+ circular. */
+ }
+ while (elt != elf_next_in_group (l->u.indirect.section));
+
+ this_hdr->sh_type = SHT_GROUP;
+ }
+ else if ((asect->flags & SEC_ALLOC) != 0
&& (((asect->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
|| (asect->flags & SEC_NEVER_LOAD) != 0))
this_hdr->sh_type = SHT_NOBITS;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: Handle section group for ld -r
2004-04-29 21:01 PATCH: Handle section group for ld -r H. J. Lu
@ 2004-04-30 12:28 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2004-04-30 12:28 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils
On Thu, Apr 29, 2004 at 01:50:47PM -0700, H. J. Lu wrote:
> This patch fixes section group for ld -r.
I doubt it. :) ld -r and sections groups are difficult to handle
correctly. The problem is what to do with sections that have the same
name as sections belonging to the group. Normally, ld -r would merge
such sections, leading to other sections incorrectly becoming part of
the group. We need to stop that happening, which could be done easily
enough by modifying unique_section_p. I'll take a look at that.
Meanwhile, I guess your patch is OK.
> * elf.c (bfd_section_from_shdr): Maintain the section order in
> a section group.
> (special_sections): Add ".note.GNU-stack".
> (elf_fake_sections): Handle section group for relocatable
> link..
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-04-30 12:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-29 21:01 PATCH: Handle section group for ld -r H. J. Lu
2004-04-30 12:28 ` 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).