This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: ld/1467: Orphaned section is put in the odd place
On Sat, Oct 15, 2005 at 01:14:10PM +0930, Alan Modra wrote:
> On Fri, Oct 14, 2005 at 07:57:46AM -0700, H. J. Lu wrote:
> > bfd/
> >
> > 2005-10-14 H.J. Lu <hongjiu.lu@intel.com>
> >
> > PR ld/1467
> > * elf-bfd.h (_bfd_elf_match_sections_by_type): New.
> > (_bfd_generic_match_sections_by_type): New. Defined.
> >
> > * elf.c (_bfd_elf_match_sections_by_type): New.
> >
> > * libbfd-in.h (_bfd_generic_match_sections_by_type): New.
> >
> > * bfd-in2.h: Regenerated.
> > * libbfd.h: Likewise.
> >
> > * libbfd.c (_bfd_generic_match_sections_by_type): New.
> >
> > * targets.c (BFD_JUMP_TABLE_LINK): Initialize
> > _bfd_match_sections_by_type with
> > _bfd_generic_match_sections_by_type.
> > (bfd_target): Add _bfd_match_sections_by_type.
> >
> > ld/
> >
> > 2005-10-14 H.J. Lu <hongjiu.lu@intel.com>
> >
> > PR ld/1467
> > * emultempl/elf32.em: Include "elf-bfd.h".
> > (gld${EMULATION_NAME}_place_orphan): Check section type and
> > don't use section name for ELF input sections.
> >
> > * ld.texinfo: Document orphan section processing.
> >
> > * ldlang.c (lang_output_section_find_by_flags): Match section
> > types by calling bfd_match_sections_by_type.
>
> Looks good to me.
>
It turns out that ELF section info of an output section may not be
set. Gcc uses orphan sections to check HAVE_LD_RO_RW_SECTION_MIXING.
If it isn't set, many libstdc++ tests will fail. There may be latent
isssues with gcc and binutils. This patch will match SHT_NULL to
any types and fixes the libstdc++ failures.
H.J.
----
bfd/
2005-10-15 H.J. Lu <hongjiu.lu@intel.com>
* elf.c (_bfd_elf_match_sections_by_type): SHT_NULL matches
any type.
ld/
2005-10-15 H.J. Lu <hongjiu.lu@intel.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Call
bfd_match_sections_by_type to match section types.
--- binutils/bfd/elf.c.orphan 2005-10-15 07:58:32.000000000 -0700
+++ binutils/bfd/elf.c 2005-10-15 15:43:46.000000000 -0700
@@ -8515,5 +8515,7 @@ _bfd_elf_match_sections_by_type (bfd *ab
|| bbfd->xvec->flavour != bfd_target_elf_flavour)
return TRUE;
- return elf_section_type (asec) == elf_section_type (bsec);
+ return (elf_section_type (asec) == SHT_NULL
+ || elf_section_type (bsec) == SHT_NULL
+ || elf_section_type (asec) == elf_section_type (bsec));
}
--- binutils/ld/emultempl/elf32.em.orphan 2005-10-15 07:58:32.000000000 -0700
+++ binutils/ld/emultempl/elf32.em 2005-10-15 15:42:37.000000000 -0700
@@ -1363,8 +1363,9 @@ gld${EMULATION_NAME}_place_orphan (lang_
if (os != NULL
&& (os->bfd_section == NULL
|| os->bfd_section->flags == 0
- || ((!iself
- || sh_type == elf_section_type (os->bfd_section))
+ || (bfd_match_sections_by_type (output_bfd,
+ os->bfd_section,
+ s->owner, s)
&& ((s->flags ^ os->bfd_section->flags)
& (SEC_LOAD | SEC_ALLOC)) == 0)))
{