aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386
diff options
context:
space:
mode:
authorGreg McGary <greg@mcgary.org>2000-06-09 06:14:39 +0000
committerGreg McGary <greg@mcgary.org>2000-06-09 06:14:39 +0000
commit3f02f778cdbec7d95e0a9d6f9368ce9cda0a6d03 (patch)
treea193d5f40640e64b7b6555e831772c1934e2a8d0 /sysdeps/i386
parenta40fb915f89d0e225058c0865de4504f83f90173 (diff)
downloadglibc-3f02f778cdbec7d95e0a9d6f9368ce9cda0a6d03.tar.xz
glibc-3f02f778cdbec7d95e0a9d6f9368ce9cda0a6d03.zip
* sysdeps/i386/bp-asm.h: New file.
* sysdeps/i386/__longjmp.S: Define & use symbolic argument stack offsets. Add ENTER/LEAVE macros for optionally maintaining frame-pointer chain when debugging. * sysdeps/i386/add_n.S: Likewise. * sysdeps/i386/addmul_1.S: Likewise. * sysdeps/i386/lshift.S: Likewise. * sysdeps/i386/memchr.S: Likewise. * sysdeps/i386/memcmp.S: Likewise. * sysdeps/i386/mul_1.S: Likewise. * sysdeps/i386/rawmemchr.S: Likewise. * sysdeps/i386/rshift.S: Likewise. * sysdeps/i386/stpcpy.S: Likewise. * sysdeps/i386/stpncpy.S: Likewise. * sysdeps/i386/strchr.S: Likewise. * sysdeps/i386/strchrnul.S: Likewise. * sysdeps/i386/strcspn.S: Likewise. * sysdeps/i386/strpbrk.S: Likewise. * sysdeps/i386/strrchr.S: Likewise. * sysdeps/i386/strspn.S: Likewise. * sysdeps/i386/strtok.S: Likewise. * sysdeps/i386/sub_n.S: Likewise. * sysdeps/i386/submul_1.S: Likewise. * sysdeps/i386/elf/setjmp.S: Likewise. * sysdeps/i386/i486/strcat.S: Likewise. * sysdeps/i386/i486/strlen.S: Likewise. * sysdeps/i386/i586/add_n.S: Likewise. * sysdeps/i386/i586/lshift.S: Likewise. * sysdeps/i386/i586/memcpy.S: Likewise. * sysdeps/i386/i586/memset.S: Likewise. * sysdeps/i386/i586/rshift.S: Likewise. * sysdeps/i386/i586/strchr.S: Likewise. * sysdeps/i386/i586/strcpy.S: Likewise. * sysdeps/i386/i586/strlen.S: Likewise. * sysdeps/i386/i586/sub_n.S: Likewise. * sysdeps/i386/i686/add_n.S: Likewise. * sysdeps/i386/i686/memcpy.S: Likewise. * sysdeps/i386/i686/mempcpy.S: Likewise. * sysdeps/i386/i686/memset.S: Likewise. * sysdeps/i386/i686/strcmp.S: Likewise. 2000-06-08 Greg McGary <greg@mcgary.org> * sysdeps/i386/bp-asm.h: New file. * sysdeps/i386/__longjmp.S: Define & use symbolic argument stack offsets. Add ENTER/LEAVE macros for optionally maintaining frame-pointer chain when debugging. * sysdeps/i386/add_n.S: Likewise. * sysdeps/i386/addmul_1.S: Likewise. * sysdeps/i386/lshift.S: Likewise. * sysdeps/i386/memchr.S: Likewise. * sysdeps/i386/memcmp.S: Likewise. * sysdeps/i386/mul_1.S: Likewise. * sysdeps/i386/rawmemchr.S: Likewise. * sysdeps/i386/rshift.S: Likewise. * sysdeps/i386/stpcpy.S: Likewise. * sysdeps/i386/stpncpy.S: Likewise. * sysdeps/i386/strchr.S: Likewise. * sysdeps/i386/strchrnul.S: Likewise. * sysdeps/i386/strcspn.S: Likewise. * sysdeps/i386/strpbrk.S: Likewise. * sysdeps/i386/strrchr.S: Likewise. * sysdeps/i386/strspn.S: Likewise. * sysdeps/i386/strtok.S: Likewise. * sysdeps/i386/sub_n.S: Likewise. * sysdeps/i386/submul_1.S: Likewise. * sysdeps/i386/elf/setjmp.S: Likewise. * sysdeps/i386/i486/strcat.S: Likewise. * sysdeps/i386/i486/strlen.S: Likewise. * sysdeps/i386/i586/add_n.S: Likewise. * sysdeps/i386/i586/lshift.S: Likewise. * sysdeps/i386/i586/memcpy.S: Likewise. * sysdeps/i386/i586/memset.S: Likewise. * sysdeps/i386/i586/rshift.S: Likewise. * sysdeps/i386/i586/strchr.S: Likewise. * sysdeps/i386/i586/strcpy.S: Likewise. * sysdeps/i386/i586/strlen.S: Likewise. * sysdeps/i386/i586/sub_n.S: Likewise. * sysdeps/i386/i686/add_n.S: Likewise. * sysdeps/i386/i686/memcpy.S: Likewise. * sysdeps/i386/i686/mempcpy.S: Likewise. * sysdeps/i386/i686/memset.S: Likewise. * sysdeps/i386/i686/strcmp.S: Likewise.
Diffstat (limited to 'sysdeps/i386')
-rw-r--r--sysdeps/i386/__longjmp.S15
-rw-r--r--sysdeps/i386/add_n.S29
-rw-r--r--sysdeps/i386/addmul_1.S25
-rw-r--r--sysdeps/i386/bp-asm.h142
-rw-r--r--sysdeps/i386/elf/setjmp.S7
-rw-r--r--sysdeps/i386/i486/strcat.S23
-rw-r--r--sysdeps/i386/i486/strlen.S16
-rw-r--r--sysdeps/i386/i586/add_n.S29
-rw-r--r--sysdeps/i386/i586/lshift.S33
-rw-r--r--sysdeps/i386/i586/memcpy.S39
-rw-r--r--sysdeps/i386/i586/memset.S41
-rw-r--r--sysdeps/i386/i586/rshift.S33
-rw-r--r--sysdeps/i386/i586/strchr.S24
-rw-r--r--sysdeps/i386/i586/strcpy.S23
-rw-r--r--sysdeps/i386/i586/strlen.S17
-rw-r--r--sysdeps/i386/i586/sub_n.S29
-rw-r--r--sysdeps/i386/i686/add_n.S27
-rw-r--r--sysdeps/i386/i686/memcpy.S29
-rw-r--r--sysdeps/i386/i686/mempcpy.S27
-rw-r--r--sysdeps/i386/i686/memset.S47
-rw-r--r--sysdeps/i386/i686/strcmp.S37
-rw-r--r--sysdeps/i386/lshift.S31
-rw-r--r--sysdeps/i386/memchr.S57
-rw-r--r--sysdeps/i386/memcmp.S22
-rw-r--r--sysdeps/i386/mul_1.S20
-rw-r--r--sysdeps/i386/rawmemchr.S19
-rw-r--r--sysdeps/i386/rshift.S31
-rw-r--r--sysdeps/i386/stpcpy.S21
-rw-r--r--sysdeps/i386/stpncpy.S24
-rw-r--r--sysdeps/i386/strchr.S26
-rw-r--r--sysdeps/i386/strchrnul.S53
-rw-r--r--sysdeps/i386/strcspn.S18
-rw-r--r--sysdeps/i386/strpbrk.S21
-rw-r--r--sysdeps/i386/strrchr.S21
-rw-r--r--sysdeps/i386/strspn.S18
-rw-r--r--sysdeps/i386/strtok.S21
-rw-r--r--sysdeps/i386/sub_n.S29
-rw-r--r--sysdeps/i386/submul_1.S28
38 files changed, 732 insertions, 420 deletions
diff --git a/sysdeps/i386/__longjmp.S b/sysdeps/i386/__longjmp.S
index a8049e9de3..54f31361be 100644
--- a/sysdeps/i386/__longjmp.S
+++ b/sysdeps/i386/__longjmp.S
@@ -1,5 +1,5 @@
/* longjmp for i386.
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,10 +21,19 @@
#define _ASM
#define _SETJMP_H
#include <bits/setjmp.h>
+#include <bp-asm.h>
+
+#define PARMS LINKAGE /* no space for saved regs */
+#define JBUF PARMS
+#define VAL JBUF+PTR_SIZE
ENTRY (__longjmp)
- movl 4(%esp), %ecx /* User's jmp_buf in %ecx. */
- movl 8(%esp), %eax /* Second argument is return value. */
+ ENTER
+
+ movl JBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
+ LEAVE
+
+ movl VAL(%esp), %eax /* Second argument is return value. */
/* Save the return address now. */
movl (JB_PC*4)(%ecx), %edx
/* Restore registers. */
diff --git a/sysdeps/i386/add_n.S b/sysdeps/i386/add_n.S
index 8bf1512087..edd2e852fd 100644
--- a/sysdeps/i386/add_n.S
+++ b/sysdeps/i386/add_n.S
@@ -1,6 +1,6 @@
/* Add two limb vectors of the same length > 0 and store sum in a third
limb vector.
- Copyright (C) 1992, 94, 95, 97, 98 Free Software Foundation, Inc.
+ Copyright (C) 1992, 94, 95, 97, 98, 2000 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
The GNU MP Library is free software; you can redistribute it and/or modify
@@ -18,26 +18,27 @@
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
-/*
- INPUT PARAMETERS
- res_ptr (sp + 4)
- s1_ptr (sp + 8)
- s2_ptr (sp + 12)
- size (sp + 16)
-*/
-
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-asm.h"
+
+#define PARMS LINKAGE+8 /* space for 2 saved regs */
+#define RES PARMS
+#define S1 RES+PTR_SIZE
+#define S2 S1+PTR_SIZE
+#define SIZE S2+PTR_SIZE
.text
ENTRY(__mpn_add_n)
+ ENTER
+
pushl %edi
pushl %esi
- movl 12(%esp),%edi /* res_ptr */
- movl 16(%esp),%esi /* s1_ptr */
- movl 20(%esp),%edx /* s2_ptr */
- movl 24(%esp),%ecx /* size */
+ movl RES(%esp),%edi
+ movl S1(%esp),%esi
+ movl S2(%esp),%edx
+ movl SIZE(%esp),%ecx
movl %ecx,%eax
shrl $3,%ecx /* compute count for unrolled loop */
@@ -99,5 +100,7 @@ L(oop): movl (%esi),%eax
popl %esi
popl %edi
+
+ LEAVE
ret
END(__mpn_add_n)
diff --git a/sysdeps/i386/addmul_1.S b/sysdeps/i386/addmul_1.S
index d7df5270c3..50151ea07d 100644
--- a/sysdeps/i386/addmul_1.S
+++ b/sysdeps/i386/addmul_1.S
@@ -1,6 +1,6 @@
/* i80386 __mpn_addmul_1 -- Multiply a limb vector with a limb and add
the result to a second limb vector.
- Copyright (C) 1992, 1994, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
The GNU MP Library is free software; you can redistribute it and/or modify
@@ -18,16 +18,15 @@
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
-/*
- INPUT PARAMETERS
- res_ptr (sp + 4)
- s1_ptr (sp + 8)
- sizeP (sp + 12)
- s2_limb (sp + 16)
-*/
-
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-asm.h"
+
+#define PARMS LINKAGE+16 /* space for 4 saved regs */
+#define RES PARMS
+#define S1 RES+PTR_SIZE
+#define SIZE S1+PTR_SIZE
+#define S2LIMB SIZE+4
#define res_ptr edi
#define s1_ptr esi
@@ -42,10 +41,10 @@ ENTRY(__mpn_addmul_1)
INSN1(push,l ,R(ebx))
INSN1(push,l ,R(ebp))
- INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
- INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
- INSN2(mov,l ,R(sizeP),MEM_DISP(esp,28))
- INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,RES))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,S1))
+ INSN2(mov,l ,R(sizeP),MEM_DISP(esp,SIZE))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,S2LIMB))
INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,sizeP,4))
INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,sizeP,4))
diff --git a/sysdeps/i386/bp-asm.h b/sysdeps/i386/bp-asm.h
new file mode 100644
index 0000000000..197c6da88c
--- /dev/null
+++ b/sysdeps/i386/bp-asm.h
@@ -0,0 +1,142 @@
+/* Bounded-pointer definitions for x86 assembler.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ Contributed by Greg McGary <greg@mcgary.org>
+
+ This file is part of the GNU C Library. Its master source is NOT part of
+ the C library, however. The master source lives in the GNU MP Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _bp_asm_h_
+# define _bp_asm_h_ 1
+
+# if __ASSEMBLER__
+
+# if __BOUNDED_POINTERS__
+
+/* Bounded pointers occupy three words. */
+# define PTR_SIZE 12
+/* Bounded pointer return values are passed back through a hidden
+ argument that points to caller-allocate space. The hidden arg
+ occupies one word on the stack. */
+# define RTN_SIZE 4
+/* Although the caller pushes the hidden arg, the callee is
+ responsible for popping it. */
+# define RET_PTR ret $RTN_SIZE
+/* Maintain frame pointer chain in leaf assembler functions for the benefit
+ of debugging stack traces when bounds violations occur. */
+# define ENTER pushl %ebp; movl %esp, %ebp
+# define LEAVE movl %ebp, %esp; popl %ebp
+/* Stack space overhead of procedure-call linkage: return address and
+ frame pointer. */
+# define LINKAGE 8
+
+/* Int 5 is the "bound range" exception also raised by the "bound"
+ instruction. */
+# define BOUNDS_VIOLATED int $5
+
+# define CHECK_BOUNDS_LOW(VAL_REG, BP_MEM) \
+ cmpl 4+BP_MEM, VAL_REG; \
+ jae 0f; /* continue if value >= low */ \
+ BOUNDS_VIOLATED; \
+ 0:
+
+# define CHECK_BOUNDS_HIGH(VAL_REG, BP_MEM, Jcc) \
+ cmpl 8+BP_MEM, VAL_REG; \
+ Jcc 0f; /* continue if value < high */ \
+ BOUNDS_VIOLATED; \
+ 0:
+
+# define CHECK_BOUNDS_BOTH(VAL_REG, BP_MEM) \
+ cmpl 4+BP_MEM, VAL_REG; \
+ jb 1f; /* die if value < low */ \
+ cmpl 8+BP_MEM, VAL_REG; \
+ jb 0f; /* continue if value < high */ \
+ 1: BOUNDS_VIOLATED; \
+ 0:
+
+# define CHECK_BOUNDS_BOTH_WIDE(VAL_REG, BP_MEM, LENGTH) \
+ CHECK_BOUNDS_LOW(VAL_REG, BP_MEM); \
+ addl LENGTH, VAL_REG; \
+ cmpl 8+BP_MEM, VAL_REG; \
+ jbe 0f; /* continue if value <= high */ \
+ BOUNDS_VIOLATED; \
+ 0: subl LENGTH, VAL_REG /* restore value */
+
+/* Take bounds from BP_MEM and affix them to the pointer
+ value in %eax, stuffing all into memory at RTN(%esp).
+ Use %ecx as a scratch register. */
+
+# define RETURN_BOUNDED_POINTER(BP_MEM) \
+ movl RTN(%esp), %ecx; \
+ movl %eax, 0(%ecx); \
+ movl 4+BP_MEM, %eax; \
+ movl %eax, 4(%ecx); \
+ movl 8+BP_MEM, %eax; \
+ movl %eax, 8(%ecx)
+
+# define RETURN_NULL_BOUNDED_POINTER \
+ movl RTN(%esp), %ecx; \
+ movl %eax, 0(%ecx); \
+ movl %eax, 4(%ecx); \
+ movl %eax, 8(%ecx)
+
+/* The caller of __errno_location is responsible for allocating space
+ for the three-word BP return-value and passing pushing its address
+ as an implicit first argument. */
+# define PUSH_ERRNO_LOCATION_RETURN \
+ subl $8, %esp; \
+ subl $4, %esp; \
+ pushl %esp
+
+/* __errno_location is responsible for popping the implicit first
+ 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. */
+# define POP_ERRNO_LOCATION_RETURN \
+ movl (%esp), %eax; \
+ addl $4, %esp; \
+ addl $8, %esp
+
+# else /* !__BOUNDED_POINTERS__ */
+
+/* Unbounded pointers occupy one word. */
+# define PTR_SIZE 4
+/* Unbounded pointer return values are passed back in the register %eax. */
+# define RTN_SIZE 0
+/* Use simple return instruction for unbounded pointer values. */
+# define RET_PTR ret
+/* Don't maintain frame pointer chain for leaf assembler functions. */
+# define ENTER
+# define LEAVE
+/* Stack space overhead of procedure-call linkage: return address only. */
+# define LINKAGE 4
+
+# define CHECK_BOUNDS_LOW(VAL_REG, BP_MEM)
+# define CHECK_BOUNDS_HIGH(VAL_REG, BP_MEM, Jcc)
+# define CHECK_BOUNDS_BOTH(VAL_REG, BP_MEM)
+# define CHECK_BOUNDS_BOTH_WIDE(VAL_REG, BP_MEM, LENGTH)
+# define RETURN_BOUNDED_POINTER(BP_MEM)
+
+# define RETURN_NULL_BOUNDED_POINTER
+
+# define PUSH_ERRNO_LOCATION_RETURN
+# define POP_ERRNO_LOCATION_RETURN
+
+# endif /* !__BOUNDED_POINTERS__ */
+
+# endif /* __ASSEMBLER__ */
+
+#endif /* _bp_asm_h_ */
diff --git a/sysdeps/i386/elf/setjmp.S b/sysdeps/i386/elf/setjmp.S
index 40710be1ef..e734809bf8 100644
--- a/sysdeps/i386/elf/setjmp.S
+++ b/sysdeps/i386/elf/setjmp.S
@@ -21,6 +21,11 @@
#define _ASM
#define _SETJMP_H
#include <bits/setjmp.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
them weak. */
@@ -55,7 +60,7 @@ ENTRY (__sigsetjmp)
movl %esi, (JB_SI*4)(%eax)
movl %edi, (JB_DI*4)(%eax)
movl %ebp, (JB_BP*4)(%eax)
- leal 4(%esp), %ecx /* Save SP as it will be after we return. */
+ leal JBUF(%esp), %ecx /* Save SP as it will be after we return. */
movl %ecx, (JB_SP*4)(%eax)
movl 0(%esp), %ecx /* Save PC we are returning to now. */
movl %ecx, (JB_PC*4)(%eax)
diff --git a/sysdeps/i386/i486/strcat.S b/sysdeps/i386/i486/strcat.S
index c3893315e7..c4ab170389 100644
--- a/sysdeps/i386/i486/strcat.S
+++ b/sysdeps/i386/i486/strcat.S
@@ -1,6 +1,6 @@
/* strcat(dest, src) -- Append SRC on the end of DEST.
For Intel 80x86, x>=4.
- 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.
Contributed by Ulrich Drepper <drepper@ipd.info.uni-karlsruhe.de>.
Optimised a little by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au>
@@ -22,19 +22,21 @@
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-asm.h"
-/*
- INPUT PARAMETERS:
- dest (sp + 4)
- src (sp + 8)
-*/
+#define PARMS LINKAGE+4 /* space for 1 saved reg */
+#define RTN PARMS
+#define DEST RTN+RTN_SIZE
+#define SRC DEST+PTR_SIZE
.text
ENTRY (strcat)
+ ENTER
+
pushl %edi /* Save callee-safe register. */
- movl 12(%esp), %ecx /* load source pointer */
- movl 8(%esp), %edx /* load destination pointer */
+ movl DEST(%esp), %edx
+ movl SRC(%esp), %ecx
testb $0xff, (%ecx) /* Is source string empty? */
jz L(8) /* yes => return */
@@ -254,8 +256,9 @@ L(9): movb %al, (%ecx,%edx) /* store first byte of last word */
movb %ah, 3(%ecx,%edx) /* store fourth byte of last word */
-L(8): movl 8(%esp), %eax /* start address of destination is result */
+L(8): movl DEST(%esp), %eax /* start address of destination is result */
popl %edi /* restore saved register */
- ret
+ LEAVE
+ RET_PTR