* sysdeps/i386/bp-asm.h (PCOFF): New constant.

(POP_ERRNO_LOCATION_RETURN): Fold insns. 
* sysdeps/i386/bits/setjmp.h (JB_SIZE): New constant. 
(PUSH_SIGNAL_MASK): New macro. 
* sysdeps/i386/__longjmp.S (__longjmp): Wrap symbol in BP_SYM (). 
LEAVE is unnecessary.  Check bounds of jmp_buf. 
* sysdeps/i386/elf/setjmp.S: Call PUSH_SIGNAL_MASK.  Wrap symbols 
in BP_SYM ().  Check bounds of jmp_buf.  Don't call LEAVE until 
immediately before tail-call. 
* sysdeps/i386/setjmp.S: Likewise. 
* sysdeps/i386/bsd-_setjmp.S: Likewise. 
* sysdeps/i386/bsd-setjmp.S: Likewise.
2000-06-29  Greg McGary  <greg@mcgary.org>

	* sysdeps/i386/bp-asm.h (PCOFF): New constant.
	(POP_ERRNO_LOCATION_RETURN): Fold insns.
	* sysdeps/i386/bits/setjmp.h (JB_SIZE): New constant.
	(PUSH_SIGNAL_MASK): New macro.
	* sysdeps/i386/__longjmp.S (__longjmp): Wrap symbol in BP_SYM ().
	LEAVE is unnecessary.  Check bounds of jmp_buf.
	* sysdeps/i386/elf/setjmp.S: Call PUSH_SIGNAL_MASK.  Wrap symbols
	in BP_SYM ().  Check bounds of jmp_buf.  Don't call LEAVE until
	immediately before tail-call.
	* sysdeps/i386/setjmp.S: Likewise.
	* sysdeps/i386/bsd-_setjmp.S: Likewise.
	* sysdeps/i386/bsd-setjmp.S: Likewise.
This commit is contained in:
Greg McGary 2000-06-29 22:55:31 +00:00
parent d3d89ab3a8
commit e5f88e0ca0
8 changed files with 121 additions and 70 deletions

View File

@ -1,3 +1,18 @@
2000-06-29 Greg McGary <greg@mcgary.org>
* sysdeps/i386/bp-asm.h (PCOFF): New constant.
(POP_ERRNO_LOCATION_RETURN): Fold insns.
* sysdeps/i386/bits/setjmp.h (JB_SIZE): New constant.
(PUSH_SIGNAL_MASK): New macro.
* sysdeps/i386/__longjmp.S (__longjmp): Wrap symbol in BP_SYM ().
LEAVE is unnecessary. Check bounds of jmp_buf.
* sysdeps/i386/elf/setjmp.S: Call PUSH_SIGNAL_MASK. Wrap symbols
in BP_SYM (). Check bounds of jmp_buf. Don't call LEAVE until
immediately before tail-call.
* sysdeps/i386/setjmp.S: Likewise.
* sysdeps/i386/bsd-_setjmp.S: Likewise.
* sysdeps/i386/bsd-setjmp.S: Likewise.
2000-06-29 Jakub Jelinek <jakub@redhat.com> 2000-06-29 Jakub Jelinek <jakub@redhat.com>
* sysdeps/sparc/fpu/fclrexcpt.c: Use SHLIB_COMPAT, compat_symbol and * sysdeps/sparc/fpu/fclrexcpt.c: Use SHLIB_COMPAT, compat_symbol and
@ -209,7 +224,6 @@
2000-06-26 Greg McGary <greg@mcgary.org> 2000-06-26 Greg McGary <greg@mcgary.org>
* sysdeps/i386/bp-asm.h (POP_ERRNO_LOCATION_RETURN): Fold insns.
* sysdeps/unix/i386/sysdep.S (syscall_error): Push & pop space * sysdeps/unix/i386/sysdep.S (syscall_error): Push & pop space
for BP return value & push implicit struct-return pointer to for BP return value & push implicit struct-return pointer to
__errno_location. __errno_location.

View File

@ -21,17 +21,19 @@
#define _ASM #define _ASM
#define _SETJMP_H #define _SETJMP_H
#include <bits/setjmp.h> #include <bits/setjmp.h>
#include <asm-syntax.h>
#include <bp-sym.h>
#include <bp-asm.h> #include <bp-asm.h>
#define PARMS LINKAGE /* no space for saved regs */ #define PARMS LINKAGE /* no space for saved regs */
#define JBUF PARMS #define JBUF PARMS
#define VAL JBUF+PTR_SIZE #define VAL JBUF+PTR_SIZE
ENTRY (__longjmp) ENTRY (BP_SYM (__longjmp))
ENTER ENTER
movl JBUF(%esp), %ecx /* User's jmp_buf in %ecx. */ movl JBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
LEAVE CHECK_BOUNDS_BOTH_WIDE (%ecx, JBUF(%esp), $JB_SIZE)
movl VAL(%esp), %eax /* Second argument is return value. */ movl VAL(%esp), %eax /* Second argument is return value. */
/* Save the return address now. */ /* Save the return address now. */
@ -44,4 +46,4 @@ ENTRY (__longjmp)
movl (JB_SP*4)(%ecx), %esp movl (JB_SP*4)(%ecx), %esp
/* Jump to saved PC. */ /* Jump to saved PC. */
jmp *%edx jmp *%edx
END (__longjmp) END (BP_SYM (__longjmp))

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1997, 1998 Free Software Foundation, Inc. /* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -29,9 +29,31 @@
# define JB_BP 3 # define JB_BP 3
# define JB_SP 4 # define JB_SP 4
# define JB_PC 5 # define JB_PC 5
# define JB_SIZE 24
#endif #endif
#ifndef _ASM #ifdef _ASM
/* We internally convert all setjmp (buf) calls to sigsetjmp (buf, mask),
so we must shift with the call frame to insert the mask argument. */
# if __BOUNDED_POINTERS__
# define PUSH_SIGNAL_MASK(MASK) \
popl %eax; /* return address */ \
popl %ecx; /* jmp_buf value */ \
popl %edx; /* jmp_buf low bound */ \
pushl 0(%esp); /* jmp_buf high bound */ \
movel $MASK, 4(%esp); \
pushl %edx; \
pushl %ecx; \
pushl %eax
# else
# define PUSH_SIGNAL_MASK(MASK) \
popl %eax; /* return address */ \
popl %ecx; /* jmp_buf */ \
pushl $MASK; \
pushl %ecx; \
pushl %eax
# endif
#else
typedef int __jmp_buf[6]; typedef int __jmp_buf[6];
#endif #endif

View File

@ -43,6 +43,8 @@
/* Stack space overhead of procedure-call linkage: return address and /* Stack space overhead of procedure-call linkage: return address and
frame pointer. */ frame pointer. */
# define LINKAGE 8 # define LINKAGE 8
/* Stack offset of return address after calling ENTER. */
# define PCOFF 4
/* Int 5 is the "bound range" exception also raised by the "bound" /* Int 5 is the "bound range" exception also raised by the "bound"
instruction. */ instruction. */
@ -106,8 +108,7 @@
argument, but we must pop the space for the BP itself. We also argument, but we must pop the space for the BP itself. We also
dereference the return value in order to dig out the pointer value. */ dereference the return value in order to dig out the pointer value. */
# define POP_ERRNO_LOCATION_RETURN \ # define POP_ERRNO_LOCATION_RETURN \
movl (%esp), %eax; \ popl %eax; \
addl $4, %esp; \
addl $8, %esp addl $8, %esp
# else /* !__BOUNDED_POINTERS__ */ # else /* !__BOUNDED_POINTERS__ */
@ -123,6 +124,8 @@
# define LEAVE # define LEAVE
/* Stack space overhead of procedure-call linkage: return address only. */ /* Stack space overhead of procedure-call linkage: return address only. */
# define LINKAGE 4 # define LINKAGE 4
/* Stack offset of return address after calling ENTER. */
# define PCOFF 0
# define CHECK_BOUNDS_LOW(VAL_REG, BP_MEM) # define CHECK_BOUNDS_LOW(VAL_REG, BP_MEM)
# define CHECK_BOUNDS_HIGH(VAL_REG, BP_MEM, Jcc) # define CHECK_BOUNDS_HIGH(VAL_REG, BP_MEM, Jcc)

View File

@ -1,5 +1,5 @@
/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. i386 version. /* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. i386 version.
Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -22,13 +22,14 @@
in setjmp doesn't clobber the state restored by longjmp. */ in setjmp doesn't clobber the state restored by longjmp. */
#include <sysdep.h> #include <sysdep.h>
#define _ASM
#define _SETJMP_H
#include <bits/setjmp.h>
#include "bp-sym.h"
#include "bp-asm.h"
ENTRY (_setjmp) ENTRY (BP_SYM (_setjmp))
popl %eax /* Pop return PC. */ PUSH_SIGNAL_MASK (0)
popl %ecx /* Pop jmp_buf argument. */
pushl $0 /* Push second argument of zero. */
pushl %ecx /* Push back first argument. */
pushl %eax /* Push back return PC. */
#ifdef PIC #ifdef PIC
/* We cannot use the PLT, because it requires that %ebx be set, but /* We cannot use the PLT, because it requires that %ebx be set, but
we can't save and restore our caller's value. Instead, we do an we can't save and restore our caller's value. Instead, we do an
@ -37,9 +38,9 @@ ENTRY (_setjmp)
call here call here
here: popl %ecx here: popl %ecx
addl $_GLOBAL_OFFSET_TABLE_+[.-here], %ecx addl $_GLOBAL_OFFSET_TABLE_+[.-here], %ecx
movl C_SYMBOL_NAME(__sigsetjmp@GOT)(%ecx), %ecx movl C_SYMBOL_NAME (BP_SYM (__sigsetjmp)@GOT)(%ecx), %ecx
jmp *%ecx jmp *%ecx
#else #else
jmp __sigsetjmp jmp BP_SYM (__sigsetjmp)
#endif #endif
END (_setjmp) END (BP_SYM (_setjmp))

View File

@ -1,5 +1,5 @@
/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. i386 version. /* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. i386 version.
Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -22,13 +22,14 @@
in setjmp doesn't clobber the state restored by longjmp. */ in setjmp doesn't clobber the state restored by longjmp. */
#include <sysdep.h> #include <sysdep.h>
#define _ASM
#define _SETJMP_H
#include <bits/setjmp.h>
#include "bp-sym.h"
#include "bp-asm.h"
ENTRY (setjmp) ENTRY (BP_SYM (setjmp))
popl %eax /* Pop return PC. */ PUSH_SIGNAL_MASK (1)
popl %ecx /* Pop jmp_buf argument. */
pushl $1 /* Push second argument of one. */
pushl %ecx /* Push back first argument. */
pushl %eax /* Push back return PC. */
#ifdef PIC #ifdef PIC
/* We cannot use the PLT, because it requires that %ebx be set, but /* We cannot use the PLT, because it requires that %ebx be set, but
we can't save and restore our caller's value. Instead, we do an we can't save and restore our caller's value. Instead, we do an
@ -37,9 +38,9 @@ ENTRY (setjmp)
call here call here
here: popl %ecx here: popl %ecx
addl $_GLOBAL_OFFSET_TABLE_+[.-here], %ecx addl $_GLOBAL_OFFSET_TABLE_+[.-here], %ecx
movl C_SYMBOL_NAME(__sigsetjmp@GOT)(%ecx), %ecx movl C_SYMBOL_NAME (BP_SYM (__sigsetjmp)@GOT)(%ecx), %ecx
jmp *%ecx jmp *%ecx
#else #else
jmp __sigsetjmp jmp BP_SYM (__sigsetjmp)
#endif #endif
END (setjmp) END (BP_SYM (setjmp))

View File

@ -21,50 +21,49 @@
#define _ASM #define _ASM
#define _SETJMP_H #define _SETJMP_H
#include <bits/setjmp.h> #include <bits/setjmp.h>
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE /* no space for saved regs */
#define JBUF PARMS
#define SGMSK JBUF+PRT_SIZE
/* We include the BSD entry points here as well but we make /* We include the BSD entry points here as well but we make
them weak. */ them weak. */
ENTRY (setjmp) ENTRY (BP_SYM (setjmp))
.weak C_SYMBOL_NAME (setjmp) .weak C_SYMBOL_NAME (BP_SYM (setjmp))
popl %eax /* Pop return PC. */ PUSH_SIGNAL_MASK (1)
popl %ecx /* Pop jmp_buf argument. */
pushl $1 /* Push second argument of zero. */
pushl %ecx /* Push back first argument. */
pushl %eax /* Push back return PC. */
/* Note that we have to use a non-exported symbol in the next /* Note that we have to use a non-exported symbol in the next
jump since otherwise gas will emit it as a jump through the jump since otherwise gas will emit it as a jump through the
PLT which is what we cannot use here. */ PLT which is what we cannot use here. */
jmp .Linternal_sigsetjmp jmp .Linternal_sigsetjmp
END (setjmp) END (BP_SYM (setjmp))
/* Binary compatibility entry point. */ /* Binary compatibility entry point. */
ENTRY (_setjmp) ENTRY (BP_SYM (_setjmp))
.weak C_SYMBOL_NAME (_setjmp) .weak C_SYMBOL_NAME (BP_SYM (_setjmp))
ENTRY (__setjmp) ENTRY (BP_SYM (__setjmp))
popl %eax /* Pop return address. */ PUSH_SIGNAL_MASK (0)
popl %ecx /* Pop jmp_buf. */ /* FALL THROUGH */
pushl $0 /* Push zero argument. */
pushl %ecx /* Push jmp_buf. */ #define PARMS LINKAGE /* no space for saved regs */
pushl %eax /* Push back return address. */ #define JMPBUF PARMS
#define SIGMSK JMPBUF+PTR_SIZE
ENTRY (BP_SYM (__sigsetjmp))
.Linternal_sigsetjmp = BP_SYM (__sigsetjmp)
ENTER
movl JMPBUF(%esp), %eax
CHECK_BOUNDS_BOTH_WIDE (%eax, JMPBUF(%esp), $JB_SIZE)
ENTRY (__sigsetjmp)
.Linternal_sigsetjmp = __sigsetjmp
movl 4(%esp), %eax /* User's jmp_buf in %eax. */
/* Save registers. */ /* Save registers. */
movl %ebx, (JB_BX*4)(%eax) movl %ebx, (JB_BX*4)(%eax)
movl %esi, (JB_SI*4)(%eax) movl %esi, (JB_SI*4)(%eax)
movl %edi, (JB_DI*4)(%eax) movl %edi, (JB_DI*4)(%eax)
movl %ebp, (JB_BP*4)(%eax) movl %ebp, (JB_BP*4)(%eax)
leal JBUF(%esp), %ecx /* Save SP as it will be after we return. */ leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
movl %ecx, (JB_SP*4)(%eax) movl %ecx, (JB_SP*4)(%eax)
movl 0(%esp), %ecx /* Save PC we are returning to now. */ movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
movl %ecx, (JB_PC*4)(%eax) movl %ecx, (JB_PC*4)(%eax)
LEAVE /* pop frame pointer to prepare for tail-call. */
/* Make a tail call to __sigjmp_save; it takes the same args. */ /* Make a tail call to __sigjmp_save; it takes the same args. */
#ifdef PIC #ifdef PIC
/* We cannot use the PLT, because it requires that %ebx be set, but /* We cannot use the PLT, because it requires that %ebx be set, but
@ -74,9 +73,9 @@ ENTRY (__sigsetjmp)
call here call here
here: popl %ecx here: popl %ecx
addl $_GLOBAL_OFFSET_TABLE_+[.-here], %ecx addl $_GLOBAL_OFFSET_TABLE_+[.-here], %ecx
movl C_SYMBOL_NAME(__sigjmp_save@GOT)(%ecx), %ecx movl C_SYMBOL_NAME (BP_SYM (__sigjmp_save)@GOT)(%ecx), %ecx
jmp *%ecx jmp *%ecx
#else #else
jmp __sigjmp_save jmp BP_SYM (__sigjmp_save)
#endif #endif
END (__sigsetjmp) END (BP_SYM (__sigsetjmp))

View File

@ -1,5 +1,5 @@
/* setjmp for i386. /* setjmp for i386.
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -19,29 +19,38 @@
#include <sysdep.h> #include <sysdep.h>
#define _ASM #define _ASM
#define _SETJMP_H
#include <bits/setjmp.h> #include <bits/setjmp.h>
#include <asm-syntax.h> #include <asm-syntax.h>
#include "bp-sym.h"
#include "bp-asm.h"
/* Binary compatibility entry point. */ /* Binary compatibility entry point. */
ENTRY (__setjmp) ENTRY (BP_SYM (__setjmp))
popl %eax /* Pop return address. */ PUSH_SIGNAL_MASK (0)
popl %ecx /* Pop jmp_buf. */ /* FALL THROUGH */
pushl $0 /* Push zero argument. */
pushl %ecx /* Push jmp_buf. */ #define PARMS LINKAGE /* no space for saved regs */
pushl %eax /* Push back return address. */ #define JMPBUF PARMS
#define SIGMSK JMPBUF+PTR_SIZE
ENTRY (BP_SYM (__sigsetjmp))
ENTER
movl JMPBUF(%esp), %eax
CHECK_BOUNDS_BOTH_WIDE (%eax, JMPBUF(%esp), $JB_SIZE)
ENTRY (__sigsetjmp)
movl 4(%esp), %eax /* User's jmp_buf in %eax. */
/* Save registers. */ /* Save registers. */
movl %ebx, (JB_BX*4)(%eax) movl %ebx, (JB_BX*4)(%eax)
movl %esi, (JB_SI*4)(%eax) movl %esi, (JB_SI*4)(%eax)
movl %edi, (JB_DI*4)(%eax) movl %edi, (JB_DI*4)(%eax)
movl %ebp, (JB_BP*4)(%eax) movl %ebp, (JB_BP*4)(%eax)
leal 4(%esp), %ecx /* Save SP as it will be after we return. */ leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
movl %ecx, (JB_SP*4)(%eax) movl %ecx, (JB_SP*4)(%eax)
movl 0(%esp), %ecx /* Save PC we are returning to now. */ movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
movl %ecx, (JB_PC*4)(%eax) movl %ecx, (JB_PC*4)(%eax)
LEAVE /* pop frame pointer to prepare for tail-call. */
/* Make a tail call to __sigjmp_save; it takes the same args. */ /* Make a tail call to __sigjmp_save; it takes the same args. */
#ifdef PIC #ifdef PIC
/* We cannot use the PLT, because it requires that %ebx be set, but /* We cannot use the PLT, because it requires that %ebx be set, but
@ -52,9 +61,9 @@ ENTRY (__sigsetjmp)
L(here): L(here):
popl %ecx popl %ecx
addl $_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ecx addl $_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ecx
movl C_SYMBOL_NAME(__sigjmp_save@GOT)(%ecx), %ecx movl C_SYMBOL_NAME (BP_SYM (__sigjmp_save)@GOT)(%ecx), %ecx
jmp *%ecx jmp *%ecx
#else #else
jmp __sigjmp_save jmp BP_SYM (__sigjmp_save)
#endif #endif
END (__sigsetjmp) END (BP_SYM (__sigsetjmp))