NetBSD Problem Report #47464
From chris@groessler.org Fri Jan 18 02:30:43 2013
Return-Path: <chris@groessler.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
by www.NetBSD.org (Postfix) with ESMTP id 2A28263E933
for <gnats-bugs@gnats.NetBSD.org>; Fri, 18 Jan 2013 02:30:43 +0000 (UTC)
Message-Id: <20130118012800.0071E544AF@muc-twinppc.groessler.org>
Date: Fri, 18 Jan 2013 02:27:59 +0100 (CET)
From: chris@groessler.org
Reply-To: chris@groessler.org
To: gnats-bugs@NetBSD.org
Subject: Undefined symbol _SDA_BASE_ or _SDA2_BASE_ with old programs
X-Send-Pr-Version: 3.95
>Number: 47464
>Category: port-macppc
>Synopsis: cannot run older programs (around 2005/2006 time frame) due to undefined symbols _SDA_BASE_ and _SDA2_BASE_
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-macppc-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jan 18 02:35:00 +0000 2013
>Closed-Date: Fri Jul 21 10:59:03 +0000 2017
>Last-Modified: Fri Jul 21 10:59:03 +0000 2017
>Originator: Christian Groessler
>Release: NetBSD 6.99.16
>Organization:
>Environment:
System: NetBSD muc-twinppc 6.99.16 NetBSD 6.99.16 (TWINPPC.MP) #0: Tue Jan 15 17:53:39 CET 2013 chris@muc-twinppc:/local/netbsd-src/obj/sys/arch/macppc/compile/TWINPPC.MP macppc
Architecture: powerpc
Machine: macppc
>Description:
I have some programs compiled back in 2005/2006 which don't run anymore in the current version.
I haven't used NetBSD/macppc in the recent years, so I cannot tell when the problem first appeared.
$ ls -l
total 104
-rwxr-xr-x 1 chris chris 31872 May 12 2005 ldpcos.nbppc*
-rwxr-xr-x 1 chris chris 20028 Oct 18 2006 m20*
$ ./m20
Undefined symbol "_SDA_BASE_" referenced from COPY relocation in ./m20
$ ldd m20
m20:
-lc.12 => /usr/lib/libc.so.12
$ file m20
m20: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 3.0, stripped
$ ./ldpcos.nbppc
Undefined symbol "_SDA2_BASE_" referenced from COPY relocation in ./ldpcos.nbppc
$ ldd ldpcos.nbppc
ldpcos.nbppc:
-lc.12 => /usr/lib/libc.so.12
$ file ldpcos.nbppc
ldpcos.nbppc: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 2.0, stripped
>How-To-Repeat:
Sample executables are on ftp://ftp.groessler.org/pub/chris/tmp/sda-base.tgz
>Fix:
>Release-Note:
>Audit-Trail:
From: Christian Groessler <chris@groessler.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-macppc/47464
Date: Sat, 7 Jan 2017 03:40:02 +0100
This ticket can potentially be closed.
I don't remember the exact version of NetBSD on which I
compiled the programs. From the time stamps of the files
it was on May-12-2005 and Oct-18-2006.
It's quite probable that I was using -current back then, which
in my opinion renders the ticket invalid.
Still, this version
NetBSD power.groessler.org 4.0_STABLE NetBSD 4.0_STABLE (POWER) #0: Sat
Feb 9 21:04:49 CET 2008
chris@power.groessler.org:/local/netbsdsrc-4/src/sys/arch/macppc/compile/POWER
macppc
can run both programs. They fail on current -current
NetBSD muc-twinppc 7.99.53 NetBSD 7.99.53 (TWINPPC.MP) #0: Sat Dec 31
09:13:19 CET 2016
chris@muc-twinppc:/local/netbsd-src/obj/sys/arch/macppc/compile/TWINPPC.MP
macppc
When I compile the programs (not the same sources as
back then since there were some changes to them in the
meanwhile) on the 4.0_STABLE installation, they still can
be run on the -current version.
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-macppc/47464
Date: Sat, 7 Jan 2017 22:37:14 +0000
On Sat, Jan 07, 2017 at 02:45:01AM +0000, Christian Groessler wrote:
> This ticket can potentially be closed.
>
> I don't remember the exact version of NetBSD on which I
> compiled the programs. From the time stamps of the files
> it was on May-12-2005 and Oct-18-2006.
>
> It's quite probable that I was using -current back then, which
> in my opinion renders the ticket invalid.
Only if it steps on something that was intentionally removed from
-current. Which isn't clear. Probably, nobody remembers for sure about
ppc things that went on in 2005/2006.
> Still, this version
>
> NetBSD power.groessler.org 4.0_STABLE NetBSD 4.0_STABLE (POWER) #0: Sat
> Feb 9 21:04:49 CET 2008
> chris@power.groessler.org:/local/netbsdsrc-4/src/sys/arch/macppc/compile/POWER
> macppc
>
> can run both programs. They fail on current -current
>
> NetBSD muc-twinppc 7.99.53 NetBSD 7.99.53 (TWINPPC.MP) #0: Sat Dec 31
> 09:13:19 CET 2016
> chris@muc-twinppc:/local/netbsd-src/obj/sys/arch/macppc/compile/TWINPPC.MP
> macppc
>
>
> When I compile the programs (not the same sources as
> back then since there were some changes to them in the
> meanwhile) on the 4.0_STABLE installation, they still can
> be run on the -current version.
Since of the binaries says it's from 2.0, and the other from 3.0, it
would be interesting to check if something freshly compiled on -3
(rather than -4) now fails, but I assume it would be a nuisance to
actually do that check...
--
David A. Holland
dholland@netbsd.org
From: Christian Groessler <chris@groessler.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-macppc/47464
Date: Tue, 10 Jan 2017 14:40:53 +0100
I missed the 2.0 and 3.0 version information while writing my previous
message.
Yes, I think that should be checked.
After all, I brought up the issue, so I somehow feel I should do the tests
with the old versions (unless someone else jumps in).
I have a G3 PowerMac sitting around, which just needs a new harddisk.
I can use that machine for the tests.
I've looked at the old versions, there are 2.0, 2.0.2, 2.0.3, 2.1 versions
of the "2" line, and 3.0, 3.0.1, 3.0.2, 3.0.3, 3.1, 3.1.1 versions of
the "3"
line.
Summing up to potentially 10 versions to test. I'll just test the "borders",
specifically 2.0, 2.1, 3.0, 3.1.1.
Will report back...
regards,
chris
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-macppc/47464
Date: Tue, 10 Jan 2017 18:36:52 +0000
On Tue, Jan 10, 2017 at 01:45:01PM +0000, Christian Groessler wrote:
> I missed the 2.0 and 3.0 version information while writing my previous
> message.
I missed it in your message too; didn't notice until I'd downloaded
the files and was prodding them with tools. So, no worries...
> Summing up to potentially 10 versions to test. I'll just test the
> "borders", specifically 2.0, 2.1, 3.0, 3.1.1.
Since both binaries show a similar problem it's probably sufficient to
test 3.1.1.
also it would be helpful to figure out where these _SDA* symbols come
from on -3. I haven't a clue about ppc internals. :-/
--
David A. Holland
dholland@netbsd.org
From: Christian Groessler <chris@groessler.org>
To: gnats-bugs@NetBSD.org, port-macppc-maintainer@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: port-macppc/47464
Date: Thu, 12 Jan 2017 14:25:21 +0100
On 01/10/17 19:40, David Holland wrote:
> Since both binaries show a similar problem it's probably sufficient to
> test 3.1.1.
I've installed 3.1 since I couldn't find a 3.1.1 iso image.
But there is a problem. If I compile the program on 3.1 it doesn't run
on -current.
You can get the program from
ftp://ftp.groessler.org./pub/chris/olivetti_m20/imgtools/m20floppy-0.61.tar.gz
.
Set CFLAGS in the Makefile for NetBSD/ppc like this:
CFLAGS = -O2 -DUNIX -DNETBSD -D__32BIT__ -DCPG_BIG_ENDIAN -Wall
-Wstrict-prototypes
--- on 3.1 ---
$ uname -a
NetBSD power3 3.1 NetBSD 3.1 (GENERIC) #0: Tue Oct 31 05:09:13 UTC 2006
builds@b1.netbsd.org:/home/builds/ab/netbsd-3-1-RELEASE/macppc/200610302053Z-obj/home/builds/ab/netbsd-3-1-RELEASE/src/sys/arch/macppc/compile/GENERIC
macppc
$ pwd
/usr/chris/tmp/m20floppy-0.61
$ make
....
$ ./m20
m20 v0.61
Copyright 2000,2001,2004,2006 Christian Groessler <chris@groessler.org>
usage: ./m20 <image file> <option>
option can be one of
ls - list files on image
lsl - verbosely list files on image
cat - show file from image
get - get file from image
mget - get multiple files from image
put - put file onto image
mput - put multiple files onto image
rm - delete files from image
new - create a new empty image
version - display program version
$ scp m20 muc-twinppc:/tmp
----------
running it on "muc-twinppc" (the -current system):
--- -current ----
[muc-twinppc:/tmp]$ uname -a
NetBSD muc-twinppc 7.99.53 NetBSD 7.99.53 (TWINPPC.MP) #0: Sat Dec 31
09:13:19 CET 2016
chris@muc-twinppc:/local/netbsd-src/obj/sys/arch/macppc/compile/TWINPPC.MP
macppc
[muc-twinppc:/tmp]$ ./m20
Undefined symbol "_SDA_BASE_" referenced from COPY relocation in ./m20
[muc-twinppc:/tmp]$
------------------
regards,
chris
From: Christian Groessler <chris@groessler.org>
To: gnats-bugs@NetBSD.org, port-macppc-maintainer@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: port-macppc/47464
Date: Mon, 24 Apr 2017 14:33:58 +0200
I've now tried with 2.0.
Problem happens with a simple "hello world" program, too. Probably also
on 3.1 (I hadn't tested that then).
--- on 2.0 ---
$ uname -a
NetBSD power3 2.0 NetBSD 2.0 (GENERIC) #0: Wed Dec 1 14:03:55 UTC 2004
builds@build:/big/builds/ab/netbsd-2-0-RELEASE/macppc/200411300000Z-obj/big/builds/ab/netbsd-2-0-RELEASE/src/sys/arch/macppc/compile/GENERIC
macppc
$ cat hello.c
#include <stdio.h>
int main(void)
{
printf("hello.c\n");
return(0);
}
$ cc -o hello hello.c
$ ./hello
hello.c
$
---------
my -current system is still from dec-31-2016:
--- -current ----
$ ./hello
Undefined symbol "_SDA2_BASE_" referenced from COPY relocation in ./hello
$
----------------
regards,
chris
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-macppc/47464: cannot run older programs (around 2005/2006
time frame) due to undefined symbols _SDA_BASE_ and _SDA2_BASE_
Date: Tue, 25 Apr 2017 21:01:57 +0300
On Mon, Apr 24, 2017 at 14:33:58 +0200, Christian Groessler wrote:
> I've now tried with 2.0.
>
> Problem happens with a simple "hello world" program, too. Probably also on
> 3.1 (I hadn't tested that then).
>
> --- on 2.0 ---
> $ uname -a
> NetBSD power3 2.0 NetBSD 2.0 (GENERIC) #0: Wed Dec 1 14:03:55 UTC 2004 builds@build:/big/builds/ab/netbsd-2-0-RELEASE/macppc/200411300000Z-obj/big/builds/ab/netbsd-2-0-RELEASE/src/sys/arch/macppc/compile/GENERIC
> macppc
> $ cat hello.c
> #include <stdio.h>
>
> int main(void)
> {
> printf("hello.c\n");
> return(0);
> }
> $ cc -o hello hello.c
> $ ./hello
> hello.c
> $
> ---------
>
> my -current system is still from dec-31-2016:
>
> --- -current ----
> $ ./hello
> Undefined symbol "_SDA2_BASE_" referenced from COPY relocation in ./hello
> $
> ----------------
This is probably a fallout from binutils upgrade. The following
binutils bug looks like it might be related:
https://sourceware.org/bugzilla/show_bug.cgi?id=16952
PowerPC LD requests bug report. Issue related to EABI symbols _SDA_BASE_, _SDA2_BASE_
_SDA_BASE_ is the "base" address for .sdata, "small" data, section.
The whole .sdata section can be addressed with a 16-bit signed offset
from _SDA_BASE_ (ditto for _SDA2_BASE_ for .sdata2, which I'm going to
omit from now on).
For COPY relocs linker and libraries guide explains
https://docs.oracle.com/cd/E19120-01/open.solaris/819-0690/chapter4-84604/index.html
| Suppose the link-editor is used to create a dynamic executable, and
| a reference to a data item is found to reside in one of the
| dependent shared objects. Space is allocated in the dynamic
| executable's .bss, equivalent in size to the data item found in the
| shared object. This space is also assigned the same symbolic name as
| defined in the shared object. Along with this data allocation, the
| link-editor generates a special copy relocation record that
| instructs the runtime linker to copy the data from the shared object
| to the allocated space within the dynamic executable.
|
| Because the symbol assigned to this space is global, it is used to
| satisfy any references from any shared objects. The dynamic
| executable inherits the data item. Any other objects within the
| process that make reference to this item are bound to this copy. The
| original data from which the copy is made effectively becomes
| unused.
So from my limited understanding the problem is that it doesn't even
make sense for the main executable to have COPY relocs for _SDA_BASE_.
Old binaries built with buggy binutils do have such bogus relocs
though. They used to be satisfied by ld.so from _SDA_BASE_ of the
first dynamic library the main program depends on. On a newer system
the dynamic libs don't have _SDA_BASE_, hence the error you see.
E.g. copy the old libc.so.12 onto your current system and run
$ ./hello
Undefined symbol "_SDA_BASE_" referenced from COPY relocation in ./hello
$ LD_LIBRARY_PATH=$PWD ./hello # with old ./libc.so.12
hello, world
I'm not sure what a good fix for this would be. May be a ppc-specific
hack in ld.so that detects bogus COPY relocs for _SDA_BASE_ and treats
them specially?
-uwe
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-macppc/47464: cannot run older programs (around 2005/2006
time frame) due to undefined symbols _SDA_BASE_ and _SDA2_BASE_
Date: Wed, 26 Apr 2017 11:29:47 +0300
On Tue, Apr 25, 2017 at 21:01:57 +0300, Valery Ushakov wrote:
> I'm not sure what a good fix for this would be. May be a ppc-specific
> hack in ld.so that detects bogus COPY relocs for _SDA_BASE_ and treats
> them specially?
Looking at it a bit closer... _SDA_BASE_ has zero size so a COPY
reloc for it is a no-op anyway.
--- reloc.c.~1.109.~ 2016-08-29 20:26:41.000000000 +0300
+++ reloc.c 2017-04-26 11:10:07.643925379 +0300
@@ -73,6 +73,16 @@ _rtld_do_copy_relocation(const Obj_Entry
const Elf_Sym *srcsym = NULL;
Obj_Entry *srcobj;
+#if defined(__powerpc__) && !defined(__LP64)
+ if (strcmp(name, "_SDA_BASE_") == 0
+ || strcmp(name, "_SDA2_BASE_") == 0)
+ {
+ rdbg(("COPY %s %s --> old bug, ignored\n",
+ dstobj->path, name));
+ return 0;
+ }
+#endif
+
for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next) {
srcsym = _rtld_symlook_obj(name, hash, srcobj, 0,
_rtld_fetch_ventry(dstobj, ELF_R_SYM(rela->r_info)));
-uwe
From: "Valeriy E. Ushakov" <uwe@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47464 CVS commit: src/libexec/ld.elf_so
Date: Thu, 27 Apr 2017 08:37:15 +0000
Module Name: src
Committed By: uwe
Date: Thu Apr 27 08:37:15 UTC 2017
Modified Files:
src/libexec/ld.elf_so: reloc.c
Log Message:
PR port-macppc/47464 - Old binutils generated bogus zero-sized COPY
relocations for _SDA_BASE_ and _SDA2_BASE_ that happened to work by
accident. They no longer happen to work when old binaries are run on
newer systems. Explicitly ignore these bogus relocations.
To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/libexec/ld.elf_so/reloc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Christian Groessler <chris@groessler.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-macppc/47464
Date: Thu, 4 May 2017 23:49:40 +0200
Is fixed with Valery's latest change,
This ticket can be closed.
regards,
chris
State-Changed-From-To: open->pending-pullups
State-Changed-By: uwe@NetBSD.org
State-Changed-When: Fri, 05 May 2017 21:31:36 +0000
State-Changed-Why:
Pullups to -6 and -7 pending.
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47464 CVS commit: [netbsd-7] src/libexec/ld.elf_so
Date: Sun, 9 Jul 2017 04:35:00 +0000
Module Name: src
Committed By: snj
Date: Sun Jul 9 04:35:00 UTC 2017
Modified Files:
src/libexec/ld.elf_so [netbsd-7]: reloc.c
Log Message:
Pull up following revision(s) (requested by uwe in ticket #1411):
libexec/ld.elf_so/reloc.c: revision 1.110
PR port-macppc/47464 - Old binutils generated bogus zero-sized COPY
relocations for _SDA_BASE_ and _SDA2_BASE_ that happened to work by
accident. They no longer happen to work when old binaries are run on
newer systems. Explicitly ignore these bogus relocations.
To generate a diff of this commit:
cvs rdiff -u -r1.106.18.1 -r1.106.18.2 src/libexec/ld.elf_so/reloc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47464 CVS commit: [netbsd-6] src/libexec/ld.elf_so
Date: Fri, 21 Jul 2017 03:53:08 +0000
Module Name: src
Committed By: snj
Date: Fri Jul 21 03:53:08 UTC 2017
Modified Files:
src/libexec/ld.elf_so [netbsd-6]: reloc.c
Log Message:
Pull up following revision(s) (requested by uwe in ticket #1450):
libexec/ld.elf_so/reloc.c: revision 1.110
PR port-macppc/47464 - Old binutils generated bogus zero-sized COPY
relocations for _SDA_BASE_ and _SDA2_BASE_ that happened to work by
accident. They no longer happen to work when old binaries are run on
newer systems. Explicitly ignore these bogus relocations.
To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.106.2.1 src/libexec/ld.elf_so/reloc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: uwe@NetBSD.org
State-Changed-When: Fri, 21 Jul 2017 10:59:03 +0000
State-Changed-Why:
Pullups done.
>Unformatted:
-current from around Jan-15-2013
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.