Subject: toolchain/31853: ld core dumps
To: None <toolchain-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <ianzag@megasignal.com>
List: netbsd-bugs
Date: 10/18/2005 11:12:00
>Number:         31853
>Category:       toolchain
>Synopsis:       ld core dumps
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 18 11:12:00 +0000 2005
>Originator:     Ian Zagorskih
>Release:        NetBSD-current
>Organization:
NGEDC
>Environment:
NetBSD IANZAG 3.99.9 NetBSD 3.99.9 (GENERIC.MPACPI) #0: Wed Oct  5 01:49:07 NOVST 2005  toor@NBSD1:/usr/build/obj/i386/sys/arch/i386/compile/GENERIC.MPACPI i386

>Description:
ld crashes with core when I'm trying to "re-link" executable :)

$ cc --version
cc (GCC) 3.3.3 (NetBSD nb3 20040520)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cc -o foo /bin/cp
/bin/cp(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/crtbegin.o(.data+0x0): first defined here
/bin/cp(.init+0x0): In function `_init':
: multiple definition of `_init'
/usr/lib/crti.o(.init+0x0): first defined here
/bin/cp(.text+0x0): In function `_start':
: multiple definition of `__start'
/usr/lib/crt0.o(.text+0x0): first defined here
/bin/cp(.data+0x4): multiple definition of `__progname'
/usr/lib/crt0.o(.data.rel.local+0x0): first defined here
/bin/cp(.text+0x0): In function `_start':
: multiple definition of `_start'
/usr/lib/crt0.o(.text+0x0): first defined here
/bin/cp(.fini+0x0): In function `_fini':
: multiple definition of `_fini'
/usr/lib/crti.o(.fini+0x0): first defined here
/bin/cp(.text+0x18): In function `___start':
: multiple definition of `___start'
/usr/lib/crt0.o(.text+0x18): first defined here
/bin/cp(*ABS*+0x804b51c): multiple definition of `_GLOBAL_OFFSET_TABLE_'
/usr/lib/crt0.o(.got.plt+0x0): first defined here
/bin/cp(.data+0x0): multiple definition of `__ps_strings'
/usr/lib/crt0.o(.data+0x0): first defined here
/bin/cp(.text+0xf4): In function `_rtld_setup':
: multiple definition of `_rtld_setup'
/usr/lib/crt0.o(.text+0xf4): first defined here
/usr/lib/crt0.o(.dynamic+0x0): multiple definition of `_DYNAMIC'
cc: Internal error: Segmentation fault (program ld)
Please submit a full bug report.
See <URL:http://www.netbsd.org/Misc/send-pr.html> for instructions.

$ ls -l
total 2276
-rw-r--r--  1 ianzag  users    18340 Oct 18 18:03 foo
-rw-------  1 ianzag  users  1128176 Oct 18 18:03 ld.core

$ gdb /usr/bin/ld ld.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"...(no debugging symbols found)...
Core was generated by `ld'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/libexec/ld.elf_so...(no debugging symbols found)...
done.
Loaded symbols for /usr/libexec/ld.elf_so
Reading symbols from /usr/lib/libintl.so.0...(no debugging symbols found)...
done.
Loaded symbols for /usr/lib/libintl.so.0
Reading symbols from /usr/lib/libbfd.so.7...(no debugging symbols found)...
done.
Loaded symbols for /usr/lib/libbfd.so.7
Reading symbols from /usr/lib/libc.so.12...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libc.so.12
#0  0xbbbcc8da in bfd_getl32 () from /usr/lib/libbfd.so.7
(gdb) bt
#0  0xbbbcc8da in bfd_getl32 () from /usr/lib/libbfd.so.7
#1  0xbbbb9615 in bfd_elf32_swap_reloc_in () from /usr/lib/libbfd.so.7
#2  0xbbba6b7f in bfd_elf_size_dynamic_sections () from /usr/lib/libbfd.so.7
#3  0xbbba9866 in bfd_elf_final_link () from /usr/lib/libbfd.so.7
#4  0x0805935e in ldwrite ()
#5  0x0805710c in main ()
#6  0x0804a3e6 in ___start ()

Well, I know, I'm doing some obviosuly stupid thing trying to "re-link" an existing ELF executable, but is it a right way to report errors for ld?

PS: Cannot say it's a serious or annoying bug, just doing what was told i.e. "Please submit a full bug report." :)

>How-To-Repeat:
$ cc -o foo /bin/cp
>Fix: