NetBSD Problem Report #43010

From www@NetBSD.org  Fri Mar 19 11:48:17 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 9FD3E63B86C
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 19 Mar 2010 11:48:17 +0000 (UTC)
Message-Id: <20100319114817.5D1F463B11D@www.NetBSD.org>
Date: Fri, 19 Mar 2010 11:48:17 +0000 (UTC)
From: dennis.c.ferguson@gmail.com
Reply-To: dennis.c.ferguson@gmail.com
To: gnats-bugs@NetBSD.org
Subject: ld error building powerpc64 libposix.so.0.1
X-Send-Pr-Version: www-1.0

>Number:         43010
>Category:       port-powerpc
>Synopsis:       ld error building powerpc64 libposix.so.0.1
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    mrg
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 19 11:50:00 +0000 2010
>Closed-Date:    Mon Mar 22 02:17:47 +0000 2010
>Last-Modified:  Mon Mar 22 02:20:02 +0000 2010
>Originator:     Dennis Ferguson
>Release:        very recent 5.99.24
>Organization:
>Environment:
NetBSD acer.hk.akit-ferguson.com 5.99.24 NetBSD 5.99.24 (GENERIC) #0: Sun Mar 14 17:25:30 HKT 2010  dennis@acer.hk.akit-ferguson.com:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
>Description:
When building a shared libposix.so for macppc64 the following
error is emitted by ld:

#     build  libposix/libposix.so.0.1
rm -f libposix.so.0.1
/usr/src/obj/tooldir.Darwin-10.2.0-i386/bin/powerpc64--netbsd-gcc  -Wl,-nostdlib -B/usr/src/obj/destdir.macppc/usr/lib/ -B/usr/src/obj/destdir.macppc/usr/lib/  -Wl,-x -shared -Wl,-soname,libposix.so.0 -Wl,--warn-shared-textrel -o libposix.so.0.1  -Wl,--whole-archive libposix_pic.a  -Wl,--no-whole-archive     -Wl,-rpath-link,/usr/src/obj/destdir.macppc/lib:/usr/src/obj/destdir.macppc/usr/lib  -L/usr/src/obj/destdir.macppc/lib  -Wl,--fatal-warnings   -L/usr/src/obj/destdir.macppc/usr/lib
/usr/src/obj/tooldir.Darwin-10.2.0-i386/lib/gcc/powerpc64--netbsd/4.1.3/../../../../powerpc64--netbsd/bin/ld: libposix_pic.a(rename.pico)(.text+0xc): unresolvable R_PPC64_REL24 relocation against symbol `.__cerror'
/usr/src/obj/tooldir.Darwin-10.2.0-i386/lib/gcc/powerpc64--netbsd/4.1.3/../../../../powerpc64--netbsd/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

*** Failed target:  libposix.so.0.1

>How-To-Repeat:
Do a:

    MACHINE=macppc64 ./build.sh distribution
>Fix:
I think the problem is with the assembler system call
procedures defined in the cpp macros in
lib/libc/arch/powerpc64/SYS.h.  In particular I think
instructions which branch to arbitrary locations may
need to be followed by a nop to give the loader room
to write the glue instructions needed for long branches
(which aren't needed for system calls in libc, since
the cerror target is in the same module, but are needed
for libposix since cerror is over in libc).

In any case, this patch allows the build to continue:

Index: SYS.h
===================================================================
RCS file: /cvsroot/src/lib/libc/arch/powerpc64/SYS.h,v
retrieving revision 1.1
diff -u -r1.1 SYS.h
--- SYS.h	1 Jul 2006 16:37:20 -0000	1.1
+++ SYS.h	19 Mar 2010 09:07:58 -0000
@@ -19,6 +19,7 @@
 #define _SYSCALL(x,y)		.text				;\
 				.align	2			;\
 			2:	b	PIC_PLT(_C_LABEL(__cerror));\
+				nop				;\
 				_SYSCALL_NOERROR(x,y)		;\
 				bso	2b

@@ -31,7 +32,8 @@

 #define PSEUDO(x,y)		_SYSCALL_NOERROR(x,y)		;\
 				bnslr				;\
-				b	PIC_PLT(_C_LABEL(__cerror))
+				b	PIC_PLT(_C_LABEL(__cerror));\
+				nop

 #define RSYSCALL_NOERROR(x)	PSEUDO_NOERROR(x,x)


>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: port-powerpc-maintainer->mrg
Responsible-Changed-By: mrg@NetBSD.org
Responsible-Changed-When: Sun, 21 Mar 2010 23:45:47 +0000
Responsible-Changed-Why:
i'll take this one.


State-Changed-From-To: open->closed
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Mon, 22 Mar 2010 02:17:47 +0000
State-Changed-Why:
this change seems to be reasonable to me.  applied.  thanks!


From: matthew green <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43010 CVS commit: src/lib/libc/arch/powerpc64
Date: Mon, 22 Mar 2010 02:17:23 +0000

 Module Name:	src
 Committed By:	mrg
 Date:		Mon Mar 22 02:17:23 UTC 2010

 Modified Files:
 	src/lib/libc/arch/powerpc64: SYS.h

 Log Message:
 add a nop to provide enough space for the linker and long calls.
 fixes link errors with 'cerror' and libposix.

 from dennis.c.ferguson@gmail.com in PR#43010.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 src/lib/libc/arch/powerpc64/SYS.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.