Subject: misc/13927: binutils 2.11 won't work on NetBSD/sparc
To: None <gnats-bugs@gnats.netbsd.org>
From: None <mrauch@netbsd.org>
List: netbsd-bugs
Date: 09/11/2001 12:00:11
>Number: 13927
>Category: misc
>Synopsis: bug in binutils >= 2.11 prevents generating correct shared libraries
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: misc-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Sep 11 05:01:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Michael Rauch
>Release: 1.5
>Organization:
>Environment:
System: NetBSD europa 1.5 NetBSD 1.5 (GENERIC) #1: Wed Nov 29 00:29:52 MET 2000 root@flambard:/usr/src/sys/arch/sparc/compile/GENERIC sparc
>Description:
A bug in binutils >= 2.11 prevents generating correct shared libraries and
causes the dynamic linker to fail while trying to resolve symbols.
binutils 2.11.2 now also uses R_SPARC_UA32 relocations instead of only
R_SPARC_32 relocations. Code in ld mishandles these relocations, making
programs not run anymore:
$ ./prog
./libclass.so: Undefined symbol "" (reloc type = 23, symnum = 9)
>How-To-Repeat:
Install binutils-2.11.2 from ftp.gnu.org, unpack the shell archive below
and compile the two files with
$ g++ -fPIC -shared -o libclass.so class.cpp --save-temps
$ g++ -L. -R. -lclass -o prog prog.cpp --save-temps
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# class.cpp
# prog.cpp
#
echo x - class.cpp
sed 's/^X//' >class.cpp << 'END-of-class.cpp'
X/* class.cpp
X */
X
Xvoid nothing() {
X}
X
END-of-class.cpp
echo x - prog.cpp
sed 's/^X//' >prog.cpp << 'END-of-prog.cpp'
X
Xint main() {
X
X exit(0);
X}
X
X
END-of-prog.cpp
exit
>Fix:
Apply the following patch to binutils 2.11.2, which has also been
sent back to the binutils maintainers:
--- /aux/binutils-2.11.2/bfd/elf32-sparc.c Mon Jun 11 12:04:13 2001
+++ bfd/elf32-sparc.c Mon Sep 10 18:15:11 2001
@@ -1478,7 +1478,7 @@
}
else
{
- if (r_type == R_SPARC_32)
+ if (r_type == R_SPARC_32 || r_type == R_SPARC_UA32)
{
outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
outrel.r_addend = relocation + rel->r_addend;
>Release-Note:
>Audit-Trail:
>Unformatted: