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]

Fix mislinking of .MIPS.content* and .MIPS.events*


The "SGI-compatible" linker scripts contain:

  .MIPS.events.data ${RELOCATING-0} :
    {
       *(.MIPS.events.data${RELOCATING+ .MIPS.events.gnu.linkonce.d*})
    }
  .MIPS.content.data ${RELOCATING-0} :
    {
       *(.MIPS.content.data${RELOCATING+ .MIPS.content.gnu.linkonce.d*})
    }

etc.  There are several problems here:

  (1) The output for .data can contain many input sections besides
      .data and .gnu.linkonce.d*.  Their .MIPS.event* and .MIPS.content*
      sections won't be included.

  (2) If a .MIPS.event.foo or .MIPS.content.foo input section isn't caught
      by one of the explicit .MIPS.event* or .MIPS.content* output sections,
      it will end up being placed as an orphan.  This causes an assertion
      failure in _bfd_mips_elf_final_write_processing() if the output
      section that includes .foo isn't itself called .foo:

	case SHT_MIPS_CONTENT:
	  BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
	  name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
	  BFD_ASSERT (name != NULL
		      && strncmp (name, ".MIPS.content",
				  sizeof ".MIPS.content" - 1) == 0);
	  sec = bfd_get_section_by_name (abfd,
					 name + sizeof ".MIPS.content" - 1);
	  BFD_ASSERT (sec != NULL);
	  (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
	  break;

  (3) The linker doesn't really know how to combine .MIPS.event*
      and .MIPS.content* sections properly anyway.

Now gcc is more aggressive than the native compiler in using special
sections like .data.rel.local.  And if gcc is using the native
assembler, these sections will get their own .MIPS.content*
description.  This means that the combination of (1) and (2)
will cause an irix bootstrap failure if:

  (a) the compiler used to bootstrap gcc is a version of gcc
      that used the native assembler and linker and

  (b) the compiler being bootstrapped uses GNU as and ld.

In this case, the files in libiberty.a will include sections like
.MIPS.content.data.rel.local, which GNU ld mishandles.

Given (3), I think the correct fix is just to discard these sections.
OK to install?

Richard


	* emulparams/elf32bmipn32-defs.sh (OTHER_SECTIONS): Discard
	.MIPS.content* and .MIPS.events* sections.

Index: ld/emulparams/elf32bmipn32-defs.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32bmipn32-defs.sh,v
retrieving revision 1.5
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.5 elf32bmipn32-defs.sh
*** ld/emulparams/elf32bmipn32-defs.sh	13 Oct 2003 19:48:39 -0000	1.5
--- ld/emulparams/elf32bmipn32-defs.sh	14 Feb 2004 10:12:40 -0000
*************** DATA_START_SYMBOLS='_fdata = . ;'
*** 51,80 ****
  OTHER_BSS_SYMBOLS='_fbss = .;'
  
  INITIAL_READONLY_SECTIONS=".MIPS.options : { *(.MIPS.options) }"
! OTHER_SECTIONS="
!   .MIPS.events.text ${RELOCATING-0} :
!     {
!        *(.MIPS.events.text${RELOCATING+ .MIPS.events.gnu.linkonce.t*})
!     }
!   .MIPS.content.text ${RELOCATING-0} : 
!     {
!        *(.MIPS.content.text${RELOCATING+ .MIPS.content.gnu.linkonce.t*})
!     }
!   .MIPS.events.data ${RELOCATING-0} :
!     {
!        *(.MIPS.events.data${RELOCATING+ .MIPS.events.gnu.linkonce.d*})
!     }
!   .MIPS.content.data ${RELOCATING-0} :
!     {
!        *(.MIPS.content.data${RELOCATING+ .MIPS.content.gnu.linkonce.d*})
!     }
!   .MIPS.events.rodata ${RELOCATING-0} :
!     {
!        *(.MIPS.events.rodata${RELOCATING+ .MIPS.events.gnu.linkonce.r*})
!     }
!   .MIPS.content.rodata ${RELOCATING-0} :
!     {
!        *(.MIPS.content.rodata${RELOCATING+ .MIPS.content.gnu.linkonce.r*})
!     }"
  
  TEXT_DYNAMIC=
--- 51,58 ----
  OTHER_BSS_SYMBOLS='_fbss = .;'
  
  INITIAL_READONLY_SECTIONS=".MIPS.options : { *(.MIPS.options) }"
! # Discard any .MIPS.content* or .MIPS.event* sections.  The linker
! # doesn't know how to adjust them.
! OTHER_SECTIONS="/DISCARD/ : { *(.MIPS.content*) *(.MIPS.events*) }"
  
  TEXT_DYNAMIC=


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