Subject: new ld got signal 11 in sys/arch/ews4800mips/stand/bootxx_bfs
To: None <tech-toolchain@NetBSD.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: tech-toolchain
Date: 02/05/2006 23:57:53
After updating src on 20060204 to try binutils-2.16.1,
ews4800mips builds on NetBSD/i386 -current fails:

---
# pwd
/usr/src/sys/arch/ews4800mips/stand/bootxx_bfs
# /usr/tools/mipseb/bin/nbmake-ews4800mips
making sure the kern library is up to date...
`libkern.a' is up to date.
/usr/tools/mipseb/bin/mipseb--netbsd-ld -T \
/usr/src/sys/arch/ews4800mips/stand/bootxx_bfs/../common/bootxx.ldscript \
-S -N  -o bootxx_bfs.elf fileread_bfs.o entry.o bootxx.o \
boot_device.o floppy_2d.o floppy_2hd_ibmpc.o \
/usr/src/sys/arch/ews4800mips/stand/bootxx_bfs/obj.ews4800mips/lib/kern/libkern.a
*** Signal 11

Stop.
nbmake: stopped in /usr/src/sys/arch/ews4800mips/stand/bootxx_bfs
# gdb /usr/tools/mipseb/bin/mipseb--netbsd-ld obj.ews4800mips/mipseb--netbsd-l.core
GNU gdb 5.3nb1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386--netbsdelf"...
Core was generated by `mipseb--netbsd-l'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/libexec/ld.elf_so...done.
Loaded symbols for /usr/libexec/ld.elf_so
Reading symbols from /usr/lib/libc.so.12...done.
Loaded symbols for /usr/lib/libc.so.12
#0  0x080a0af5 in elf_fixup_link_order (abfd=0x8111000, o=0x8123570)
    at /usr/src/gnu/dist/binutils/bfd/elflink.c:7641
7641              if (elfsec != -1
(gdb) bt
#0  0x080a0af5 in elf_fixup_link_order (abfd=0x8111000, o=0x8123570)
    at /usr/src/gnu/dist/binutils/bfd/elflink.c:7641
#1  0x080a1b05 in bfd_elf_final_link (abfd=0x8111000, info=0x810bfc0)
    at /usr/src/gnu/dist/binutils/bfd/elflink.c:8134
#2  0x0808845e in _bfd_mips_elf_final_link (abfd=0x8111000, info=0x810bfc0)
    at /usr/src/gnu/dist/binutils/bfd/elfxx-mips.c:9533
#3  0x08059845 in ldwrite () at /usr/src/gnu/dist/binutils/ld/ldwrite.c:554
#4  0x080577f5 in main (argc=14, argv=0xbfbfe63c)
    at /usr/src/gnu/dist/binutils/ld/ldmain.c:467
#5  0x08049686 in ___start ()
(gdb) 
---

elf_fixup_link_order() in src/gnu/dist/binutils/elflink.c:
---
static bfd_boolean
elf_fixup_link_order (bfd *abfd, asection *o)
{
  int seen_linkorder;
  int seen_other;
  int n;
  struct bfd_link_order *p;
  bfd *sub;
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
  int elfsec;
  struct bfd_link_order **sections;
  asection *s;
  bfd_vma offset;
  
  seen_other = 0;
  seen_linkorder = 0;
  for (p = o->link_order_head; p != NULL; p = p->next)
    {
      if (p->type == bfd_indirect_link_order
	  && (bfd_get_flavour ((sub = p->u.indirect.section->owner))
	      == bfd_target_elf_flavour)
	  && elf_elfheader (sub)->e_ident[EI_CLASS] == bed->s->elfclass)
	{
	  s = p->u.indirect.section;
	  elfsec = _bfd_elf_section_from_bfd_section (sub, s);
-->	  if (elfsec != -1
-->	      && elf_elfsections (sub)[elfsec]->sh_flags & SHF_LINK_ORDER)
	    seen_linkorder++;
	  else
	    seen_other++;
	}
      else
	seen_other++;
    }
 :
---

Any clue? Wrong ldscript?
---
Izumi Tsutsui