NetBSD Problem Report #38

From gnats  Mon Dec  6 12:45:28 1993
Received: from forte (forte.mathematik.uni-Bremen.de [134.102.232.1]) by sun-lamp.cs.berkeley.edu (8.6.4/8.6.4) with ESMTP id MAA11827 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Mon, 6 Dec 1993 12:44:32 -0800
Message-Id: <199312062043.VAA23772@forte>
Date: Mon, 6 Dec 1993 21:43:25 +0100
From: thomas@mathematik.uni-Bremen.de
Reply-To: thomas@mathematik.uni-Bremen.de
To: gnats-bugs@sun-lamp.cs.berkeley.edu
Subject: Reversed operands in i386/sys/brk.S, and other libc/arch/i386 PIC stuff
X-Send-Pr-Version: 3.01.6

>Number:         38
>Category:       lib
>Synopsis:       Reversed operands in i386/sys/brk.S, and other libc/arch/i386 PIC stuff
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 06 12:50:03 +0000 1993
>Closed-Date:    Tue Dec 07 11:06:15 +0000 1993
>Last-Modified:  
>Originator:     Thomas Eberhardt
>Release:        
>Organization:
CeVis, University of Bremen, Germany
>Environment:

System: NetBSD ed209 0.9a ED209#0 i386

Machine: i386
>Description:
	There are two movl statements in the assembly code for the brk
	function for the i386 architecture that have their operands
	in the wrong order.
	There is also a erroneous PIC_EPILOGUE at the end of
	gen/fixunsdfsi.S.
	Another thing: Shouldn't all the 'jmp cerror's in the various .S
	files be changed to 'jmp PIC_PLT(cerror)' as it is the case in
	sbrk.S?
	And last but not least: Shouldn't the PIC macros in SYS.h be moved
	to machine/asm.h to allow modification of the PROF macro so that it
	would be possible to build a profiled shared C library?
>How-To-Repeat:

>Fix:
*** sys/brk.S-	Thu Oct 21 03:19:26 1993
--- sys/brk.S	Mon Dec  6 01:34:40 1993
***************
*** 55,62 ****
  #ifdef PIC
  	movl	4(%esp),%eax
  	PIC_PROLOGUE
! 	movl	%edx,PIC_GOT(curbrk)	# set up GOT addressing
! 	movl	%ecx,PIC_GOT(minbrk)	#
  	cmpl	%eax,(%ecx)
  	PIC_EPILOGUE
  	jl	ok
--- 55,62 ----
  #ifdef PIC
  	movl	4(%esp),%eax
  	PIC_PROLOGUE
! 	movl	PIC_GOT(curbrk),%edx	# set up GOT addressing
! 	movl	PIC_GOT(minbrk),%ecx	#
  	cmpl	%eax,(%ecx)
  	PIC_EPILOGUE
  	jl	ok
*** gen/fixunsdfsi.S-	Thu Oct 21 03:03:39 1993
--- gen/fixunsdfsi.S	Mon Dec  6 00:51:11 1993
***************
*** 54,60 ****
  	PIC_EPILOGUE
  	fcoml	(%eax)
  #else
! 	fcoml	PIC_GOTOFF(fbiggestsigned)	/* bigger than biggest signed? */
  #endif
  	fstsw	%ax
  	sahf
--- 54,60 ----
  	PIC_EPILOGUE
  	fcoml	(%eax)
  #else
! 	fcoml	fbiggestsigned	/* bigger than biggest signed? */
  #endif
  	fstsw	%ax
  	sahf
***************
*** 71,82 ****
  	PIC_EPILOGUE
  	fsubl	(%eax)
  #else
! 	fsubl	PIC_GOTOFF(fbiggestsigned)	/* reduce for proper conversion */
  #endif
  	fistpl	4(%esp)		/* convert */
  	movl	4(%esp),%eax
  	orl	$0x80000000,%eax	/* restore bias */
- 	PIC_EPILOGUE
  	ret

  fbiggestsigned:	.double	0r2147483648.0
--- 71,81 ----
  	PIC_EPILOGUE
  	fsubl	(%eax)
  #else
! 	fsubl	fbiggestsigned	/* reduce for proper conversion */
  #endif
  	fistpl	4(%esp)		/* convert */
  	movl	4(%esp),%eax
  	orl	$0x80000000,%eax	/* restore bias */
  	ret

  fbiggestsigned:	.double	0r2147483648.0

------------------------------------------------------------------------------

I'm not sure if the following is really needed:

*** ./SYS.h-	Sun Nov  7 09:18:40 1993
--- ./SYS.h	Mon Dec  6 01:26:02 1993
***************
*** 60,69 ****
  #define PIC_GOTOFF(x)	x
  #endif

! #define	SYSCALL(x)	2: jmp cerror; ENTRY(x); lea SYS_/**/x,%eax; LCALL(7,0); jb 2b
  #define	RSYSCALL(x)	SYSCALL(x); ret
  #define	PSEUDO(x,y)	ENTRY(x); lea SYS_/**/y, %eax; ; LCALL(7,0); ret
! #define	CALL(x,y)	call _/**/y; addl $4*x,%esp
  /* gas fucks up offset -- although we don't currently need it, do for BCS */
  #define	LCALL(x,y)	.byte 0x9a ; .long y; .word x

--- 60,69 ----
  #define PIC_GOTOFF(x)	x
  #endif

! #define	SYSCALL(x)	2: jmp PIC_PLT(cerror); ENTRY(x); lea SYS_/**/x,%eax; LCALL(7,0); jb 2b
  #define	RSYSCALL(x)	SYSCALL(x); ret
  #define	PSEUDO(x,y)	ENTRY(x); lea SYS_/**/y, %eax; ; LCALL(7,0); ret
! #define	CALL(x,y)	call PIC_PLT(_/**/y); addl $4*x,%esp
  /* gas fucks up offset -- although we don't currently need it, do for BCS */
  #define	LCALL(x,y)	.byte 0x9a ; .long y; .word x

*** ./sys/exect.S-	Thu Oct 21 03:19:28 1993
--- ./sys/exect.S	Mon Dec  6 01:05:34 1993
***************
*** 53,56 ****
  	pushl	%edx
  	popf
  	LCALL(7,0)
! 	jmp	cerror		/* exect(file, argv, env); */
--- 53,56 ----
  	pushl	%edx
  	popf
  	LCALL(7,0)
! 	jmp	PIC_PLT(cerror)	/* exect(file, argv, env); */
*** ./sys/ptrace.S-	Thu Oct 21 03:19:33 1993
--- ./sys/ptrace.S	Mon Dec  6 01:06:02 1993
***************
*** 59,62 ****
  	jb	err
  	ret
  err:
! 	jmp	cerror
--- 59,62 ----
  	jb	err
  	ret
  err:
! 	jmp	PIC_PLT(cerror)
*** ./sys/sigprocmask.S-	Thu Oct 21 03:19:39 1993
--- ./sys/sigprocmask.S	Mon Dec  6 01:19:17 1993
***************
*** 45,51 ****
  #include "SYS.h"

  err:
! 	jmp	cerror

  ENTRY(sigprocmask)
  	movl	8(%esp),%ecx		# fetch new sigset pointer
--- 45,51 ----
  #include "SYS.h"

  err:
! 	jmp	PIC_PLT(cerror)

  ENTRY(sigprocmask)
  	movl	8(%esp),%ecx		# fetch new sigset pointer
*** ./sys/sigsuspend.S-	Thu Oct 21 03:19:41 1993
--- ./sys/sigsuspend.S	Mon Dec  6 01:19:28 1993
***************
*** 45,51 ****
  #include "SYS.h"

  err:
! 	jmp	cerror

  ENTRY(sigsuspend)
  	movl	4(%esp),%eax		# fetch mask arg
--- 45,51 ----
  #include "SYS.h"

  err:
! 	jmp	PIC_PLT(cerror)

  ENTRY(sigsuspend)
  	movl	4(%esp),%eax		# fetch mask arg
*** ./sys/syscall.S-	Thu Oct 21 03:19:43 1993
--- ./sys/syscall.S	Mon Dec  6 01:19:39 1993
***************
*** 53,56 ****
  	jb	1f
  	ret
  1:
! 	jmp	cerror
--- 53,56 ----
  	jb	1f
  	ret
  1:
! 	jmp	PIC_PLT(cerror)
>Release-Note:
>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: jtc
State-Changed-When: Tue Dec  7 11:06:15 1993
State-Changed-Why:
Fixes checked in by pk.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.