NetBSD Problem Report #46724

From genadmin@idlefortress.accessaxis.com  Thu Jul 19 18:44:45 2012
Return-Path: <genadmin@idlefortress.accessaxis.com>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 0865F63B85F
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 19 Jul 2012 18:44:45 +0000 (UTC)
Message-Id: <20120719172522.60CA12402B8@idlefortress.accessaxis.com>
Date: Thu, 19 Jul 2012 11:25:22 -0600 (MDT)
From: genadmin@idlefortress.accessaxis.com
Reply-To: inittab@unixdev.net
To: gnats-bugs@gnats.NetBSD.org
Subject: Cannot compute sizeof short on NetBSD/sparc64 6.0_BETA2
X-Send-Pr-Version: 3.95

>Number:         46724
>Category:       port-sparc64
>Synopsis:       Cannot compute sizeof short on NetBSD/sparc64 6.0_BETA2
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 19 18:45:00 +0000 2012
>Closed-Date:    Mon Aug 13 18:25:58 +0000 2012
>Last-Modified:  Mon Aug 13 18:25:58 +0000 2012
>Originator:     Greg Schenzel
>Release:        NetBSD 6.0_BETA2
>Organization:
unixdev.net
>Environment:
System: NetBSD idlefortress.accessaxis.com 6.0_BETA2 NetBSD 6.0_BETA2 (GKERNEL) #0: Sat Jun 9 20:08:32 MDT 2012 root@netbsd.accessaxis.com:/usr/src/sys/arch/sparc64/compile/GKERNEL sparc64
Architecture: sparc64
Machine: sparc64
Hardware: Sun Netra X1
>Description:

When attempting to compute the sizeof short on NetBSD/sparc64 6.0_BETA2, a fatal error is received. See below for sample conftest.c from pure-ftpd and ktruss output from the conftest binary.

>How-To-Repeat:

1. Create conftest.c as below:

/* confdefs.h.  */
#define PACKAGE_NAME "pure-ftpd"
#define PACKAGE_TARNAME "pure-ftpd"
#define PACKAGE_VERSION "1.0.35"
#define PACKAGE_STRING "pure-ftpd 1.0.35"
#define PACKAGE_BUGREPORT "bugs at pureftpd dot org"
#define PACKAGE "pure-ftpd"
#define VERSION "1.0.35"
#define _GNU_SOURCE 1
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define __EXTENSIONS__ 1
#define _POSIX_PTHREAD_SEMANTICS 1
#define _TANDEM_SOURCE 1
#define STDC_HEADERS 1
#define TIME_WITH_SYS_TIME 1
#define HAVE_DIRENT_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_STRING_H 1
#define HAVE_STRINGS_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_STATVFS_H 1
#define HAVE_SYS_UIO_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_RESOURCE_H 1
#define HAVE_GETOPT_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#define HAVE_NETINET_IN_SYSTM_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_SYS_FILE_H 1
#define HAVE_SYS_MOUNT_H 1
#define HAVE_FCNTL_H 1
#define HAVE_SYS_FCNTL_H 1
#define HAVE_SYS_PTRACE_H 1
#define HAVE_SECURITY_PAM_APPL_H 1
#define HAVE_SECURITY_PAM_MODULES_H 1
#define HAVE_SGTTY_H 1
#define HAVE_LOCALE_H 1
#define HAVE_STDARG_H 1
#define HAVE_UTIME_H 1
#define HAVE_OPENSSL_SSL_H 1
#define HAVE_ICONV_H 1
#define HAVE_POSIX_TERMIOS
#define WORDS_BIGENDIAN 1
#define RETSIGTYPE void
#define HAVE_STRUCT_TM_TM_ZONE 1
#define HAVE_TM_ZONE 1
#define STRUCT_TM_TM_GMTOFF
#define HAVE_SCALAR_TIMEZONE
/* end confdefs.h.  */
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
#  include <stdlib.h>
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
#  include <memory.h>
# endif
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
   typedef short ac__type_sizeof_;
static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); }
static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); }
#include <stdio.h>
#include <stdlib.h>
int
main ()
{

  FILE *f = fopen ("conftest.val", "w");
  if (! f)
    return 1;
  if (((long int) (sizeof (ac__type_sizeof_))) < 0)
    {
      long int i = longval ();
      if (i != ((long int) (sizeof (ac__type_sizeof_))))
      return 1;
      fprintf (f, "%ld\n", i);
    }
  else
    {
      unsigned long int i = ulongval ();
      if (i != ((long int) (sizeof (ac__type_sizeof_))))
      return 1;
      fprintf (f, "%lu\n", i);
    }
  return ferror (f) || fclose (f) != 0;

  ;
  return 0;
}

2. Compile the program: gcc -o conftest -O2 -DLDAP_DEPRECATED -I/usr/include -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector-all -Winit-self -Wwrite-strings -Wdiv-by-zero -DLDAP_DEPRECATED -I/usr/include -D_FORTIFY_SOURCE=2 -L/usr/lib -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib -pie -z relro -z now conftest.c

3. Run the program: ./conftest
Fatal error

4. Running under ktruss shows: ktruss -t A ./conftest
Fatal error
 22756      1 ktruss   fcntl(0x4, 0x3, 0)          = 1, 3
 22756      1 ktruss   emul(netbsd)
 22756      1 ktruss   fcntl(0x4, 0x4, 0x1)        = 0, 4
 22756      1 conftest execve("./conftest", 0xffffffffffffb790, 0xffffffffffffb7a0) JUSTRETURN
 22756      1 conftest emul(netbsd)
 22756      1 conftest mmap(0, 0x8000, 0x3, 0x1002, 0xffffffffffffffff, 0, 0) = 0x40206000
 22756      1 conftest open("/etc/ld.so.conf", 0, 0) Err#2 ENOENT
 22756      1 conftest open("/usr/lib/libc.so.12", 0, 0x7f7f7f7f7f7f7f7f) = 3
 22756      1 conftest __fstat50(0x3, 0xffffffffffffaca8) = 0, -21336
 22756      1 conftest mmap(0, 0x2000, 0x1, 0x1, 0x3, 0, 0) = 0x40210000
 22756      1 conftest munmap(0x40210000, 0x2000)  = 0, 8192
 22756      1 conftest mmap(0, 0x250000, 0x5, 0x14000002, 0x3, 0, 0) = 0x40500000
 22756      1 conftest mmap(0x40728000, 0x18000, 0x7, 0x12, 0x3, 0, 0x128000) = 0x40728000
 22756      1 conftest mmap(0x40740000, 0x10000, 0x7, 0x1012, 0xffffffffffffffff, 0, 0) = 0x40740000
 22756      1 conftest mprotect(0x40628000, 0x100000, 0) = 0, 1048576
 22756      1 conftest close(0x3)                  = 0, 3
 22756      1 conftest mprotect(0x100000, 0x2000, 0x7) = 0, 8192
 22756      1 conftest mprotect(0x100000, 0x2000, 0x5) = 0, 8192
 22756      1 conftest write(0x2, 0xffffffffffffb338, 0xb) = 11, -19656
       "Fatal error"
 22756      1 conftest write(0x2, 0x40311298, 0x1) = 1, 1076957848
       "\n"
 22756      1 conftest exit(0x1)


>Fix:
No fix is currently known.

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc64/46724: Cannot compute sizeof short on NetBSD/sparc64 6.0_BETA2
Date: Thu, 19 Jul 2012 21:59:49 +0200

 Remove the -pie option.

 Martin

From: inittab@unixdev.net
To: gnats-bugs@NetBSD.org
Cc: 
Subject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IFJlOiBwb3J0LXNwYXJjNjQvNDY3
 MjQ6IENhbm5vdCBjb21wdXRlIHNpemVvZiBzaG9ydCBvbiBOZXRCU0Qvc3BhcmM2NCA2LjBfQkVU
 QTINClNlbnQ6IEp1bCAxOSwgMjAxMiAxMjo0NSBQTQ0KDQpUaGFuayB5b3UgdmVyeSBtdWNoIGZv
 ciB5b3VyIHByb2JsZW0gcmVwb3J0Lg0KSXQgaGFzIHRoZSBpbnRlcm5hbCBpZGVudGlmaWNhdGlv
 biBgcG9ydC1zcGFyYzY0LzQ2NzI0Jy4NClRoZSBpbmRpdmlkdWFsIGFzc2lnbmVkIHRvIGxvb2sg
 YXQgeW91cg0KcmVwb3J0IGlzOiBwb3J0LXNwYXJjNjQtbWFpbnRhaW5lci4gDQoNCj5DYXRlZ29y
 eTogICAgICAgcG9ydC1zcGFyYzY0DQo+UmVzcG9uc2libGU6ICAgIHBvcnQtc3BhcmM2NC1tYWlu
 dGFpbmVyDQo+U3lub3BzaXM6ICAgICAgIENhbm5vdCBjb21wdXRlIHNpemVvZiBzaG9ydCBvbiBO
 ZXRCU0Qvc3BhcmM2NCA2LjBfQkVUQTINCj5BcnJpdmFsLURhdGU6ICAgVGh1IEp1bCAxOSAxODo0
 NTowMCArMDAwMCAyMDEyDQoNCg0KU2VudCB2aWEgQmxhY2tCZXJyeSBieSBBVCZU

From: Martin Husemann <martin@duskware.de>
To: Greg Schenzel <inittab@unixdev.net>
Cc: gnats-bugs@NetBSD.org
Subject: Re: port-sparc64/46724: Cannot compute sizeof short on NetBSD/sparc64 6.0_BETA2
Date: Fri, 20 Jul 2012 09:04:15 +0200

 On Thu, Jul 19, 2012 at 04:08:47PM -0600, Greg Schenzel wrote:
 > If autoconf detects that the linker accepts -pie then it uses it. Are
 > there issues with position independent executables on NetBSD/sparc64?

 Yes, apparently it broke with the last binutils or gcc update.

 > Does this need to be addressed with the autoconf developers and/or the
 > net/pure-ftpd package maintainers as well?

 No, we will fix it.

 Martin

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc64/46724: Cannot compute sizeof short on NetBSD/sparc64 6.0_BETA2
Date: Sat, 21 Jul 2012 00:13:25 +0200

 Newer binutils generate a OLO10 relocation in the -pie case, which needs
 special handling in ld.elf_so.

 I'll fix it.

 Martin

Responsible-Changed-From-To: port-sparc64-maintainer->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Fri, 20 Jul 2012 22:17:05 +0000
Responsible-Changed-Why:
I am working on a fix.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46724 CVS commit: src/libexec/ld.elf_so/arch/sparc64
Date: Sun, 22 Jul 2012 09:21:03 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Jul 22 09:21:03 UTC 2012

 Modified Files:
 	src/libexec/ld.elf_so/arch/sparc64: mdreloc.c

 Log Message:
 Add special handling needed for OLO10 relocations.
 First part of fixing PR port-sparc64/46724.


 To generate a diff of this commit:
 cvs rdiff -u -r1.52 -r1.53 src/libexec/ld.elf_so/arch/sparc64/mdreloc.c

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

From: "Julian Coleman" <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46724 CVS commit: [netbsd-6] src/libexec/ld.elf_so
Date: Wed, 8 Aug 2012 06:24:51 +0000

 Module Name:	src
 Committed By:	jdc
 Date:		Wed Aug  8 06:24:51 UTC 2012

 Modified Files:
 	src/libexec/ld.elf_so [netbsd-6]: headers.c
 	src/libexec/ld.elf_so/arch/sparc64 [netbsd-6]: mdreloc.c

 Log Message:
 Pull up revisions:
   src/libexec/ld.elf_so/headers.c revision 1.42
   src/libexec/ld.elf_so/arch/sparc64/mdreloc.c revision 1.53
 (requested by martin in ticket #447).

 Remove a debug assert that does not hold for PIE (e.g. phdr = 0x40, but
 obj has not been mapped at 0, so obj->phdr is 0x100040).
 OK: skrll

 Add special handling needed for OLO10 relocations.
 First part of fixing PR port-sparc64/46724.


 To generate a diff of this commit:
 cvs rdiff -u -r1.41 -r1.41.4.1 src/libexec/ld.elf_so/headers.c
 cvs rdiff -u -r1.52 -r1.52.6.1 src/libexec/ld.elf_so/arch/sparc64/mdreloc.c

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

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46724 CVS commit: src/lib/csu/sparc64
Date: Fri, 10 Aug 2012 16:37:31 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Fri Aug 10 16:37:31 UTC 2012

 Modified Files:
 	src/lib/csu/sparc64: Makefile crt0.c

 Log Message:
 Slightly simplify and make position independend.
 Part of fixing PR port-sparc64/46724.


 To generate a diff of this commit:
 cvs rdiff -u -r1.8 -r1.9 src/lib/csu/sparc64/Makefile
 cvs rdiff -u -r1.26 -r1.27 src/lib/csu/sparc64/crt0.c

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

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46724 CVS commit: [netbsd-6] src
Date: Mon, 13 Aug 2012 17:09:50 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Mon Aug 13 17:09:50 UTC 2012

 Modified Files:
 	src/external/gpl3/gcc/dist/gcc/config [netbsd-6]: netbsd-elf.h
 	src/lib/csu/sparc64 [netbsd-6]: Makefile crt0.c
 	src/lib/csu/sparc_elf [netbsd-6]: Makefile crt0.c

 Log Message:
 Pull up following revision(s) (requested by martin in ticket #475):
 	lib/csu/sparc_elf/Makefile: revision 1.7
 	external/gpl3/gcc/dist/gcc/config/netbsd-elf.h: revision 1.4
 	lib/csu/sparc64/Makefile: revision 1.9
 	lib/csu/sparc_elf/crt0.c: revision 1.15
 	lib/csu/sparc64/crt0.c: revision 1.27
 Make this position independend (for -pie executables)
 Slightly simplify and make position independend.
 Part of fixing PR port-sparc64/46724.
 pay attention to -pie: link crt{begin,end}S.o.
 this fixes -fpie on sparc and sparc64, and probably others.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.2.4.1 \
     src/external/gpl3/gcc/dist/gcc/config/netbsd-elf.h
 cvs rdiff -u -r1.8 -r1.8.4.1 src/lib/csu/sparc64/Makefile
 cvs rdiff -u -r1.26 -r1.26.6.1 src/lib/csu/sparc64/crt0.c
 cvs rdiff -u -r1.6 -r1.6.44.1 src/lib/csu/sparc_elf/Makefile
 cvs rdiff -u -r1.14 -r1.14.6.1 src/lib/csu/sparc_elf/crt0.c

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

State-Changed-From-To: open->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Mon, 13 Aug 2012 18:25:58 +0000
State-Changed-Why:
Fixed and pulled up to netbd-6.
Thanks for the report!


>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.