* sysdeps/i386/add_n.S: Wrap entry-point symbol in BP_SYM ().

Check bounds of arguments. 
* sysdeps/i386/addmul_1.S: Likewise. 
* sysdeps/i386/lshift.S: Likewise. 
* sysdeps/i386/mul_1.S: Likewise. 
* sysdeps/i386/rshift.S: Likewise. 
* sysdeps/i386/sub_n.S: Likewise. 
* sysdeps/i386/submul_1.S: Likewise. 
* sysdeps/i386/i586/add_n.S: Likewise. 
* sysdeps/i386/i586/addmul_1.S: Likewise. 
* sysdeps/i386/i586/lshift.S: Likewise. 
* sysdeps/i386/i586/rshift.S: Likewise. 
* sysdeps/i386/i586/sub_n.S: Likewise. 
* sysdeps/i386/i686/add_n.S: Likewise.
	* sysdeps/i386/memchr.S: Likewise.
	* sysdeps/i386/memcmp.S: Likewise.
	* sysdeps/i386/rawmemchr.S: Likewise.
	* sysdeps/i386/i586/bzero.S: Likewise.
	* sysdeps/i386/i586/memcpy.S: Likewise.
	* sysdeps/i386/i586/mempcpy.S: Likewise.
	* sysdeps/i386/i586/memset.S: Likewise.
	* sysdeps/i386/i686/bzero.S: Likewise.
	* sysdeps/i386/i686/memcpy.S: Likewise.
	* sysdeps/i386/i686/mempcpy.S: Likewise.
	* sysdeps/i386/i686/memset.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/strtok_r.S: Likewise.
	* sysdeps/i386/i486/strcat.S: Likewise.
	* sysdeps/i386/i486/strlen.S: Likewise.
	* sysdeps/i386/i586/strchr.S: Likewise.
	* sysdeps/i386/i586/strcpy.S: Likewise.
	* sysdeps/i386/i586/strlen.S: Likewise.
	* sysdeps/i386/i686/strcmp.S: Likewise.
	* sysdeps/i386/i686/strtok.S: Likewise.
	* sysdeps/i386/i686/strtok_r.S: Likewise.

	* sysdeps/i386/fpu/fegetenv.c: Wrap symbol names with BP_SYM ().
	* sysdeps/i386/fpu/fesetenv.c: Likewise.
	* sysdeps/i386/fpu/feupdateenv.c: Likewise.
	* sysdeps/i386/fpu/fgetexcptflg.c: Likewise.
	* sysdeps/i386/fpu/fsetexcptflg.c: Likewise.
	* sysdeps/i386/add_n.S: Wrap entry-point symbol in BP_SYM ().
	Check bounds of arguments.
	* sysdeps/i386/addmul_1.S: Likewise.
	* sysdeps/i386/lshift.S: Likewise.
	* sysdeps/i386/mul_1.S: Likewise.
	* sysdeps/i386/rshift.S: Likewise.
	* sysdeps/i386/sub_n.S: Likewise.
	* sysdeps/i386/submul_1.S: Likewise.
	* sysdeps/i386/i586/add_n.S: Likewise.
	* sysdeps/i386/i586/addmul_1.S: Likewise.
	* sysdeps/i386/i586/lshift.S: Likewise.
	* sysdeps/i386/i586/rshift.S: Likewise.
	* sysdeps/i386/i586/sub_n.S: Likewise.
	* sysdeps/i386/i686/add_n.S: Likewise.

	* sysdeps/i386/memchr.S: Likewise.
	* sysdeps/i386/memcmp.S: Likewise.
	* sysdeps/i386/rawmemchr.S: Likewise.
	* sysdeps/i386/i586/bzero.S: Likewise.
	* sysdeps/i386/i586/memcpy.S: Likewise.
	* sysdeps/i386/i586/mempcpy.S: Likewise.
	* sysdeps/i386/i586/memset.S: Likewise.
	* sysdeps/i386/i686/bzero.S: Likewise.
	* sysdeps/i386/i686/memcpy.S: Likewise.
	* sysdeps/i386/i686/mempcpy.S: Likewise.
	* sysdeps/i386/i686/memset.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/strtok_r.S: Likewise.
	* sysdeps/i386/i486/strcat.S: Likewise.
	* sysdeps/i386/i486/strlen.S: Likewise.
	* sysdeps/i386/i586/strchr.S: Likewise.
	* sysdeps/i386/i586/strcpy.S: Likewise.
	* sysdeps/i386/i586/strlen.S: Likewise.
	* sysdeps/i386/i686/strcmp.S: Likewise.
	* sysdeps/i386/i686/strtok.S: Likewise.
	* sysdeps/i386/i686/strtok_r.S: Likewise.

	* sysdeps/i386/fpu/fegetenv.c: Wrap symbol names with BP_SYM ().
	* sysdeps/i386/fpu/fesetenv.c: Likewise.
	* sysdeps/i386/fpu/feupdateenv.c: Likewise.
	* sysdeps/i386/fpu/fgetexcptflg.c: Likewise.
	* sysdeps/i386/fpu/fsetexcptflg.c: Likewise.
This commit is contained in:
Greg McGary 2000-06-26 22:15:00 +00:00
parent c2eee429d3
commit 2fc0882697
48 changed files with 428 additions and 146 deletions

View File

@ -1,5 +1,57 @@
2000-06-26 Greg McGary <greg@mcgary.org> 2000-06-26 Greg McGary <greg@mcgary.org>
* sysdeps/i386/add_n.S: Wrap entry-point symbol in BP_SYM ().
Check bounds of arguments.
* sysdeps/i386/addmul_1.S: Likewise.
* sysdeps/i386/lshift.S: Likewise.
* sysdeps/i386/mul_1.S: Likewise.
* sysdeps/i386/rshift.S: Likewise.
* sysdeps/i386/sub_n.S: Likewise.
* sysdeps/i386/submul_1.S: Likewise.
* sysdeps/i386/i586/add_n.S: Likewise.
* sysdeps/i386/i586/addmul_1.S: Likewise.
* sysdeps/i386/i586/lshift.S: Likewise.
* sysdeps/i386/i586/rshift.S: Likewise.
* sysdeps/i386/i586/sub_n.S: Likewise.
* sysdeps/i386/i686/add_n.S: Likewise.
* sysdeps/i386/memchr.S: Likewise.
* sysdeps/i386/memcmp.S: Likewise.
* sysdeps/i386/rawmemchr.S: Likewise.
* sysdeps/i386/i586/bzero.S: Likewise.
* sysdeps/i386/i586/memcpy.S: Likewise.
* sysdeps/i386/i586/mempcpy.S: Likewise.
* sysdeps/i386/i586/memset.S: Likewise.
* sysdeps/i386/i686/bzero.S: Likewise.
* sysdeps/i386/i686/memcpy.S: Likewise.
* sysdeps/i386/i686/mempcpy.S: Likewise.
* sysdeps/i386/i686/memset.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/strtok_r.S: Likewise.
* sysdeps/i386/i486/strcat.S: Likewise.
* sysdeps/i386/i486/strlen.S: Likewise.
* sysdeps/i386/i586/strchr.S: Likewise.
* sysdeps/i386/i586/strcpy.S: Likewise.
* sysdeps/i386/i586/strlen.S: Likewise.
* sysdeps/i386/i686/strcmp.S: Likewise.
* sysdeps/i386/i686/strtok.S: Likewise.
* sysdeps/i386/i686/strtok_r.S: Likewise.
* sysdeps/i386/fpu/fegetenv.c: Wrap symbol names with BP_SYM ().
* sysdeps/i386/fpu/fesetenv.c: Likewise.
* sysdeps/i386/fpu/feupdateenv.c: Likewise.
* sysdeps/i386/fpu/fgetexcptflg.c: Likewise.
* sysdeps/i386/fpu/fsetexcptflg.c: Likewise.
* sysdeps/i386/addmul_1.S: Exchange roles of %ebp and %ebx. * sysdeps/i386/addmul_1.S: Exchange roles of %ebp and %ebx.
* sysdeps/i386/mul_1.S: Likewise. * sysdeps/i386/mul_1.S: Likewise.
* sysdeps/i386/submul_1.S: Likewise. * sysdeps/i386/submul_1.S: Likewise.

View File

@ -20,6 +20,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */ #define PARMS LINKAGE+8 /* space for 2 saved regs */
@ -29,7 +30,7 @@
#define SIZE S2+PTR_SIZE #define SIZE S2+PTR_SIZE
.text .text
ENTRY(__mpn_add_n) ENTRY (BP_SYM (__mpn_add_n))
ENTER ENTER
pushl %edi pushl %edi
@ -39,7 +40,13 @@ ENTRY(__mpn_add_n)
movl S1(%esp),%esi movl S1(%esp),%esi
movl S2(%esp),%edx movl S2(%esp),%edx
movl SIZE(%esp),%ecx movl SIZE(%esp),%ecx
#if __BOUNDED_POINTERS__
shll $2, %ecx /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%esi, S1(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%edx, S2(%esp), %ecx)
shrl $2, %ecx
#endif
movl %ecx,%eax movl %ecx,%eax
shrl $3,%ecx /* compute count for unrolled loop */ shrl $3,%ecx /* compute count for unrolled loop */
negl %eax negl %eax
@ -103,4 +110,4 @@ L(oop): movl (%esi),%eax
LEAVE LEAVE
ret ret
END(__mpn_add_n) END (BP_SYM (__mpn_add_n))

View File

@ -20,6 +20,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */ #define PARMS LINKAGE+16 /* space for 4 saved regs */
@ -34,7 +35,7 @@
#define s2_limb ebx #define s2_limb ebx
.text .text
ENTRY(__mpn_addmul_1) ENTRY (BP_SYM (__mpn_addmul_1))
ENTER ENTER
pushl %edi pushl %edi
@ -46,7 +47,13 @@ ENTRY(__mpn_addmul_1)
movl S1(%esp), %s1_ptr movl S1(%esp), %s1_ptr
movl SIZE(%esp), %sizeP movl SIZE(%esp), %sizeP
movl S2LIMB(%esp), %s2_limb movl S2LIMB(%esp), %s2_limb
#if __BOUNDED_POINTERS__
shll $2, %sizeP /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%res_ptr, RES(%esp), %sizeP)
CHECK_BOUNDS_BOTH_WIDE (%s1_ptr, S1(%esp), %sizeP)
CHECK_BOUNDS_BOTH_WIDE (%s2_limb, S2LIMB(%esp), %sizeP)
shrl $2, %sizeP
#endif
leal (%res_ptr,%sizeP,4), %res_ptr leal (%res_ptr,%sizeP,4), %res_ptr
leal (%s1_ptr,%sizeP,4), %s1_ptr leal (%s1_ptr,%sizeP,4), %s1_ptr
negl %sizeP negl %sizeP
@ -72,4 +79,4 @@ L(oop):
LEAVE LEAVE
ret ret
END(__mpn_addmul_1) END (BP_SYM (__mpn_addmul_1))

View File

@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <fenv.h> #include <fenv.h>
#include <bp-sym.h>
int int
__fegetenv (fenv_t *envp) __fegetenv (fenv_t *envp)
@ -29,5 +30,5 @@ __fegetenv (fenv_t *envp)
return 0; return 0;
} }
strong_alias (__fegetenv, __old_fegetenv) strong_alias (__fegetenv, __old_fegetenv)
symbol_version (__old_fegetenv, fegetenv, GLIBC_2.1); symbol_version (BP_SYM (__old_fegetenv), BP_SYM (fegetenv), GLIBC_2.1);
default_symbol_version (__fegetenv, fegetenv, GLIBC_2.2); default_symbol_version (BP_SYM (__fegetenv), BP_SYM (fegetenv), GLIBC_2.2);

View File

@ -19,8 +19,8 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <fenv.h> #include <fenv.h>
#include <assert.h> #include <assert.h>
#include <bp-sym.h>
int int
@ -78,5 +78,5 @@ __fesetenv (const fenv_t *envp)
return 0; return 0;
} }
strong_alias (__fesetenv, __old_fesetenv) strong_alias (__fesetenv, __old_fesetenv)
symbol_version (__old_fesetenv, fesetenv, GLIBC_2.1); symbol_version (BP_SYM (__old_fesetenv), BP_SYM (fesetenv), GLIBC_2.1);
default_symbol_version (__fesetenv, fesetenv, GLIBC_2.2); default_symbol_version (BP_SYM (__fesetenv), BP_SYM (fesetenv), GLIBC_2.2);

View File

@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <fenv.h> #include <fenv.h>
#include <bp-sym.h>
int int
__feupdateenv (const fenv_t *envp) __feupdateenv (const fenv_t *envp)
@ -41,5 +42,5 @@ __feupdateenv (const fenv_t *envp)
return 0; return 0;
} }
strong_alias (__feupdateenv, __old_feupdateenv) strong_alias (__feupdateenv, __old_feupdateenv)
symbol_version (__old_feupdateenv, feupdateenv, GLIBC_2.1); symbol_version (BP_SYM (__old_feupdateenv), BP_SYM (feupdateenv), GLIBC_2.1);
default_symbol_version (__feupdateenv, feupdateenv, GLIBC_2.2); default_symbol_version (BP_SYM (__feupdateenv), BP_SYM (feupdateenv), GLIBC_2.2);

View File

@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <fenv.h> #include <fenv.h>
#include <bp-sym.h>
int int
__fegetexceptflag (fexcept_t *flagp, int excepts) __fegetexceptflag (fexcept_t *flagp, int excepts)
@ -34,5 +35,5 @@ __fegetexceptflag (fexcept_t *flagp, int excepts)
return 0; return 0;
} }
strong_alias (__fegetexceptflag, __old_fegetexceptflag) strong_alias (__fegetexceptflag, __old_fegetexceptflag)
symbol_version (__old_fegetexceptflag, fegetexceptflag, GLIBC_2.1); symbol_version (BP_SYM (__old_fegetexceptflag), BP_SYM (fegetexceptflag), GLIBC_2.1);
default_symbol_version (__fegetexceptflag, fegetexceptflag, GLIBC_2.2); default_symbol_version (BP_SYM (__fegetexceptflag), BP_SYM (fegetexceptflag), GLIBC_2.2);

View File

@ -20,6 +20,7 @@
#include <fenv.h> #include <fenv.h>
#include <math.h> #include <math.h>
#include <bp-sym.h>
int int
__fesetexceptflag (const fexcept_t *flagp, int excepts) __fesetexceptflag (const fexcept_t *flagp, int excepts)
@ -42,5 +43,5 @@ __fesetexceptflag (const fexcept_t *flagp, int excepts)
return 0; return 0;
} }
strong_alias (__fesetexceptflag, __old_fesetexceptflag) strong_alias (__fesetexceptflag, __old_fesetexceptflag)
symbol_version (__old_fesetexceptflag, fesetexceptflag, GLIBC_2.1); symbol_version (BP_SYM (__old_fesetexceptflag), BP_SYM (fesetexceptflag), GLIBC_2.1);
default_symbol_version (__fesetexceptflag, fesetexceptflag, GLIBC_2.2); default_symbol_version (BP_SYM (__fesetexceptflag), BP_SYM (fesetexceptflag), GLIBC_2.2);

View File

@ -22,6 +22,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */ #define PARMS LINKAGE+4 /* space for 1 saved reg */
@ -30,13 +31,15 @@
#define SRC DEST+PTR_SIZE #define SRC DEST+PTR_SIZE
.text .text
ENTRY (strcat) ENTRY (BP_SYM (strcat))
ENTER ENTER
pushl %edi /* Save callee-safe register. */ pushl %edi /* Save callee-safe register. */
movl DEST(%esp), %edx movl DEST(%esp), %edx
movl SRC(%esp), %ecx movl SRC(%esp), %ecx
CHECK_BOUNDS_LOW (%edx, DEST(%esp))
CHECK_BOUNDS_LOW (%ecx, SRC(%esp))
testb $0xff, (%ecx) /* Is source string empty? */ testb $0xff, (%ecx) /* Is source string empty? */
jz L(8) /* yes => return */ jz L(8) /* yes => return */
@ -256,9 +259,11 @@ L(9): movb %al, (%ecx,%edx) /* store first byte of last word */
movb %ah, 3(%ecx,%edx) /* store fourth byte of last word */ movb %ah, 3(%ecx,%edx) /* store fourth byte of last word */
L(8): movl DEST(%esp), %eax /* start address of destination is result */ L(8): /* GKM FIXME: check high bounds */
movl DEST(%esp), %eax /* start address of destination is result */
RETURN_BOUNDED_POINTER (DEST(%esp))
popl %edi /* restore saved register */ popl %edi /* restore saved register */
LEAVE LEAVE
RET_PTR RET_PTR
END (strcat) END (BP_SYM (strcat))

View File

@ -21,16 +21,18 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.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 STR PARMS #define STR PARMS
.text .text
ENTRY (strlen) ENTRY (BP_SYM (strlen))
ENTER ENTER
movl STR(%esp), %ecx movl STR(%esp), %ecx
CHECK_BOUNDS_LOW (%ecx, STR(%esp))
movl %ecx, %eax /* duplicate it */ movl %ecx, %eax /* duplicate it */
andl $3, %ecx /* mask alignment bits */ andl $3, %ecx /* mask alignment bits */
@ -128,8 +130,9 @@ L(3): testb %cl, %cl /* is first byte NUL? */
jz L(2) /* yes => return pointer */ jz L(2) /* yes => return pointer */
incl %eax /* increment pointer */ incl %eax /* increment pointer */
L(2): subl STR(%esp), %eax /* compute difference to string start */ L(2): CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
subl STR(%esp), %eax /* compute difference to string start */
LEAVE LEAVE
ret ret
END (strlen) END (BP_SYM (strlen))

View File

@ -20,6 +20,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */ #define PARMS LINKAGE+16 /* space for 4 saved regs */
@ -29,7 +30,7 @@
#define SIZE S2+PTR_SIZE #define SIZE S2+PTR_SIZE
.text .text
ENTRY(__mpn_add_n) ENTRY (BP_SYM (__mpn_add_n))
ENTER ENTER
pushl %edi pushl %edi
@ -41,7 +42,13 @@ ENTRY(__mpn_add_n)
movl S1(%esp),%esi movl S1(%esp),%esi
movl S2(%esp),%ebx movl S2(%esp),%ebx
movl SIZE(%esp),%ecx movl SIZE(%esp),%ecx
#if __BOUNDED_POINTERS__
shll $2, %ecx /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%esi, S1(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%ebx, S2(%esp), %ecx)
shrl $2, %ecx
#endif
movl (%ebx),%ebp movl (%ebx),%ebp
decl %ecx decl %ecx
@ -127,4 +134,4 @@ L(end2):
LEAVE LEAVE
ret ret
END(__mpn_add_n) END (BP_SYM (__mpn_add_n))

View File

@ -20,6 +20,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */ #define PARMS LINKAGE+16 /* space for 4 saved regs */
@ -34,7 +35,7 @@
#define s2_limb ebx #define s2_limb ebx
.text .text
ENTRY(__mpn_addmul_1) ENTRY (BP_SYM (__mpn_addmul_1))
ENTER ENTER
pushl %edi pushl %edi
@ -46,7 +47,13 @@ ENTRY(__mpn_addmul_1)
movl S1(%esp), %s1_ptr movl S1(%esp), %s1_ptr
movl SIZE(%esp), %size movl SIZE(%esp), %size
movl S2LIMB(%esp), %s2_limb movl S2LIMB(%esp), %s2_limb
#if __BOUNDED_POINTERS__
shll $2, %size /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%res_ptr, RES(%esp), %size)
CHECK_BOUNDS_BOTH_WIDE (%s1_ptr, S1(%esp), %size)
CHECK_BOUNDS_BOTH_WIDE (%s2_limb, S2LIMB(%esp), %size)
shrl $2, %size
#endif
leal (%res_ptr,%size,4), %res_ptr leal (%res_ptr,%size,4), %res_ptr
leal (%s1_ptr,%size,4), %s1_ptr leal (%s1_ptr,%size,4), %s1_ptr
negl %size negl %size
@ -80,4 +87,4 @@ L(oop): adcl $0, %ebp
LEAVE LEAVE
ret ret
#undef size #undef size
END(__mpn_addmul_1) END (BP_SYM (__mpn_addmul_1))

View File

@ -1,3 +1,3 @@
#define memset __bzero #define memset __bzero
#include <sysdeps/i386/i586/memset.S> #include <sysdeps/i386/i586/memset.S>
weak_alias (__bzero, bzero) weak_alias (BP_SYM (__bzero), BP_SYM (bzero))

View File

@ -19,6 +19,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */ #define PARMS LINKAGE+16 /* space for 4 saved regs */
@ -28,7 +29,7 @@
#define CNT SIZE+4 #define CNT SIZE+4
.text .text
ENTRY(__mpn_lshift) ENTRY (BP_SYM (__mpn_lshift))
ENTER ENTER
pushl %edi pushl %edi
@ -40,6 +41,12 @@ ENTRY(__mpn_lshift)
movl S(%esp),%esi movl S(%esp),%esi
movl SIZE(%esp),%ebx movl SIZE(%esp),%ebx
movl CNT(%esp),%ecx movl CNT(%esp),%ecx
#if __BOUNDED_POINTERS__
shll $2, %ebx /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ebx)
CHECK_BOUNDS_BOTH_WIDE (%esi, S(%esp), %ebx)
shrl $2, %ebx
#endif
/* We can use faster code for shift-by-1 under certain conditions. */ /* We can use faster code for shift-by-1 under certain conditions. */
cmp $1,%ecx cmp $1,%ecx
@ -222,4 +229,4 @@ L(L1): movl %edx,(%edi) /* store last limb */
LEAVE LEAVE
ret ret
END(__mpn_lshift) END (BP_SYM (__mpn_lshift))

View File

@ -20,6 +20,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
/* BEWARE: `#ifdef memcpy' means that memcpy is redefined as `mempcpy', /* BEWARE: `#ifdef memcpy' means that memcpy is redefined as `mempcpy',
@ -34,7 +35,7 @@
#define LEN SRC+PTR_SIZE #define LEN SRC+PTR_SIZE
.text .text
ENTRY (memcpy) ENTRY (BP_SYM (memcpy))
ENTER ENTER
pushl %edi pushl %edi
@ -43,6 +44,8 @@ ENTRY (memcpy)
movl DEST(%esp), %edi movl DEST(%esp), %edi
movl SRC(%esp), %esi movl SRC(%esp), %esi
movl LEN(%esp), %ecx movl LEN(%esp), %ecx
CHECK_BOUNDS_BOTH_WIDE (%edi, DEST(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%esi, SRC(%esp), %ecx)
movl %edi, %eax movl %edi, %eax
/* We need this in any case. */ /* We need this in any case. */
@ -112,4 +115,4 @@ L(1): rep; movsb
LEAVE LEAVE
RET_PTR RET_PTR
END (memcpy) END (BP_SYM (memcpy))

View File

@ -1,4 +1,4 @@
#define memcpy __mempcpy #define memcpy __mempcpy
#include <sysdeps/i386/i586/memcpy.S> #include <sysdeps/i386/i586/memcpy.S>
weak_alias (__mempcpy, mempcpy) weak_alias (BP_SYM (__mempcpy), BP_SYM (mempcpy))

View File

@ -21,6 +21,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ /* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */
@ -37,18 +38,18 @@
#endif #endif
.text .text
ENTRY (memset) ENTRY (BP_SYM (memset))
ENTER ENTER
pushl %edi pushl %edi
movl DEST(%esp), %edi movl DEST(%esp), %edi
movl LEN(%esp), %edx movl LEN(%esp), %edx
CHECK_BOUNDS_BOTH_WIDE (%edi, DEST(%esp), %edx)
#if BZERO_P #if BZERO_P
xorl %eax, %eax /* we fill with 0 */ xorl %eax, %eax /* we fill with 0 */
#else #else
movb CHR(%esp), %al movb CHR(%esp), %al
movb %al, %ah movb %al, %ah
movl %eax, %ecx movl %eax, %ecx
shll $16, %eax shll $16, %eax
@ -101,7 +102,8 @@ L(2): shrl $2, %ecx /* convert byte count to longword count */
#if !BZERO_P #if !BZERO_P
/* Load result (only if used as memset). */ /* Load result (only if used as memset). */
movl DEST(%esp), %eax movl DEST(%esp), %eax /* start address of destination is result */
RETURN_BOUNDED_POINTER (DEST(%esp))
#endif #endif
popl %edi popl %edi
@ -111,4 +113,4 @@ L(2): shrl $2, %ecx /* convert byte count to longword count */
#else #else
RET_PTR RET_PTR
#endif #endif
END (memset) END (BP_SYM (memset))

View File

@ -19,6 +19,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */ #define PARMS LINKAGE+16 /* space for 4 saved regs */
@ -28,7 +29,7 @@
#define CNT SIZE+4 #define CNT SIZE+4
.text .text
ENTRY(__mpn_rshift) ENTRY (BP_SYM (__mpn_rshift))
ENTER ENTER
pushl %edi pushl %edi
@ -40,6 +41,12 @@ ENTRY(__mpn_rshift)
movl S(%esp),%esi movl S(%esp),%esi
movl SIZE(%esp),%ebx movl SIZE(%esp),%ebx
movl CNT(%esp),%ecx movl CNT(%esp),%ecx
#if __BOUNDED_POINTERS__
shll $2, %ebx /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ebx)
CHECK_BOUNDS_BOTH_WIDE (%esi, S(%esp), %ebx)
shrl $2, %ebx
#endif
/* We can use faster code for shift-by-1 under certain conditions. */ /* We can use faster code for shift-by-1 under certain conditions. */
cmp $1,%ecx cmp $1,%ecx
@ -222,4 +229,4 @@ L(L1): movl %edx,(%edi) /* store last limb */
LEAVE LEAVE
ret ret
END(__mpn_rshift) END (BP_SYM (__mpn_rshift))

View File

@ -21,6 +21,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
/* This version is especially optimized for the i586 (and following?) /* This version is especially optimized for the i586 (and following?)
@ -42,7 +43,7 @@
#define CHR STR+PTR_SIZE #define CHR STR+PTR_SIZE
.text .text
ENTRY (strchr) ENTRY (BP_SYM (strchr))
ENTER ENTER
pushl %edi /* Save callee-safe registers. */ pushl %edi /* Save callee-safe registers. */
@ -53,6 +54,7 @@ ENTRY (strchr)
movl STR(%esp), %eax movl STR(%esp), %eax
movl CHR(%esp), %edx movl CHR(%esp), %edx
CHECK_BOUNDS_LOW (%eax, STR(%esp))
movl %eax, %edi /* duplicate string pointer for later */ movl %eax, %edi /* duplicate string pointer for later */
xorl %ecx, %ecx /* clear %ecx */ xorl %ecx, %ecx /* clear %ecx */
@ -279,7 +281,9 @@ L(5): subl $4, %eax /* adjust pointer */
incl %eax /* increment pointer */ incl %eax /* increment pointer */
L(2): popl %ebp /* restore saved registers */ L(2): CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
RETURN_BOUNDED_POINTER (STR(%esp))
popl %ebp /* restore saved registers */
popl %ebx popl %ebx
popl %esi popl %esi
@ -321,8 +325,8 @@ L(4): subl $4, %eax /* adjust pointer */
cmpb %dl, %ch /* fourth byte == C? */ cmpb %dl, %ch /* fourth byte == C? */
je L(2) /* yes => return pointer */ je L(2) /* yes => return pointer */
L(3): xorl %eax, %eax /* set return value = NULL */ L(3): xorl %eax, %eax
RETURN_NULL_BOUNDED_POINTER
popl %ebp /* restore saved registers */ popl %ebp /* restore saved registers */
popl %ebx popl %ebx
@ -331,7 +335,7 @@ L(3): xorl %eax, %eax /* set return value = NULL */
LEAVE LEAVE
RET_PTR RET_PTR
END (strchr) END (BP_SYM (strchr))
#undef index #undef index
weak_alias (strchr, index) weak_alias (BP_SYM (strchr), BP_SYM (index))

View File

@ -20,6 +20,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+12 /* space for 3 saved regs */ #define PARMS LINKAGE+12 /* space for 3 saved regs */
@ -34,7 +35,7 @@
#define magic 0xfefefeff #define magic 0xfefefeff
.text .text
ENTRY(STRCPY) ENTRY (BP_SYM (STRCPY))
ENTER ENTER
pushl %edi pushl %edi
@ -43,6 +44,8 @@ ENTRY(STRCPY)
movl DEST(%esp), %edi movl DEST(%esp), %edi
movl SRC(%esp), %esi movl SRC(%esp), %esi
CHECK_BOUNDS_LOW (%edi, DEST(%esp))
CHECK_BOUNDS_LOW (%esi, SRC(%esp))
xorl %eax, %eax xorl %eax, %eax
leal -1(%esi), %ecx leal -1(%esi), %ecx
@ -142,15 +145,17 @@ L(4): movb %dl, (%edi)
L(end): movb %ah, (%edi) L(end): movb %ah, (%edi)
L(end2): L(end2):
/* GKM FIXME: check high bounds */
#ifdef USE_AS_STPCPY #ifdef USE_AS_STPCPY
movl %edi, %eax movl %edi, %eax
#else #else
movl DEST(%esp), %eax movl DEST(%esp), %eax
#endif #endif
RETURN_BOUNDED_POINTER (DEST(%esp))
popl %ebx popl %ebx
popl %esi popl %esi
popl %edi popl %edi
LEAVE LEAVE
RET_PTR RET_PTR
END(STRCPY) END (BP_SYM (STRCPY))

View File

@ -21,6 +21,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
/* This version is especially optimized for the i586 (and following?) /* This version is especially optimized for the i586 (and following?)
@ -40,10 +41,11 @@
#define STR PARMS #define STR PARMS
.text .text
ENTRY(strlen) ENTRY (BP_SYM (strlen))
ENTER ENTER
movl STR(%esp), %eax movl STR(%esp), %eax
CHECK_BOUNDS_LOW (%eax, STR(%esp))
movl $3, %edx /* load mask (= 3) */ movl $3, %edx /* load mask (= 3) */
andl %eax, %edx /* separate last two bits of address */ andl %eax, %edx /* separate last two bits of address */
@ -177,9 +179,10 @@ L(3): subl $4, %eax /* correct too early pointer increment */
incl %eax /* increment pointer */ incl %eax /* increment pointer */
L(2): subl STR(%esp), %eax /* now compute the length as difference L(2): CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
subl STR(%esp), %eax /* now compute the length as difference
between start and terminating NUL between start and terminating NUL
character */ character */
LEAVE LEAVE
ret ret
END (strlen) END (BP_SYM (strlen))

View File

@ -20,6 +20,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */ #define PARMS LINKAGE+16 /* space for 4 saved regs */
@ -29,7 +30,7 @@
#define SIZE S2+PTR_SIZE #define SIZE S2+PTR_SIZE
.text .text
ENTRY(__mpn_sub_n) ENTRY (BP_SYM (__mpn_sub_n))
ENTER ENTER
pushl %edi pushl %edi
@ -41,7 +42,13 @@ ENTRY(__mpn_sub_n)
movl S1(%esp),%esi movl S1(%esp),%esi
movl S2(%esp),%ebx movl S2(%esp),%ebx
movl SIZE(%esp),%ecx movl SIZE(%esp),%ecx
#if __BOUNDED_POINTERS__
shll $2, %ecx /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%esi, S1(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%ebx, S2(%esp), %ecx)
shrl $2, %ecx
#endif
movl (%ebx),%ebp movl (%ebx),%ebp
decl %ecx decl %ecx
@ -127,4 +134,4 @@ L(end2):
LEAVE LEAVE
ret ret
END(__mpn_sub_n) END (BP_SYM (__mpn_sub_n))

View File

@ -20,6 +20,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */ #define PARMS LINKAGE+8 /* space for 2 saved regs */
@ -33,7 +34,7 @@
L(1): addl (%esp), %eax L(1): addl (%esp), %eax
ret ret
#endif #endif
ENTRY(__mpn_add_n) ENTRY (BP_SYM (__mpn_add_n))
ENTER ENTER
pushl %edi pushl %edi
@ -43,7 +44,13 @@ ENTRY(__mpn_add_n)
movl S1(%esp),%esi movl S1(%esp),%esi
movl S2(%esp),%edx movl S2(%esp),%edx
movl SIZE(%esp),%ecx movl SIZE(%esp),%ecx
#if __BOUNDED_POINTERS__
shll $2, %ecx /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%esi, S1(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%edx, S2(%esp), %ecx)
shrl $2, %ecx
#endif
movl %ecx,%eax movl %ecx,%eax
shrl $3,%ecx /* compute count for unrolled loop */ shrl $3,%ecx /* compute count for unrolled loop */
negl %eax negl %eax
@ -104,4 +111,4 @@ L(oop): movl (%esi),%eax
LEAVE LEAVE
ret ret
END(__mpn_add_n) END (BP_SYM (__mpn_add_n))

View File

@ -1,3 +1,3 @@
#define memset __bzero #define memset __bzero
#include <sysdeps/i386/i686/memset.S> #include <sysdeps/i386/i686/memset.S>
weak_alias (__bzero, bzero) weak_alias (BP_SYM (__bzero), BP_SYM (bzero))

View File

@ -21,6 +21,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.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 */
@ -30,7 +31,7 @@
#define LEN SRC+PTR_SIZE #define LEN SRC+PTR_SIZE
.text .text
ENTRY(memcpy) ENTRY (BP_SYM (memcpy))
ENTER ENTER
movl LEN(%esp), %ecx movl LEN(%esp), %ecx
@ -38,6 +39,9 @@ ENTRY(memcpy)
movl DEST(%esp), %edi movl DEST(%esp), %edi
movl %esi, %edx movl %esi, %edx
movl SRC(%esp), %esi movl SRC(%esp), %esi
CHECK_BOUNDS_BOTH_WIDE (%edi, DEST(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%esi, SRC(%esp), %ecx)
cld cld
shrl $1, %ecx shrl $1, %ecx
jnc 1f jnc 1f
@ -50,7 +54,8 @@ ENTRY(memcpy)
movl %eax, %edi movl %eax, %edi
movl %edx, %esi movl %edx, %esi
movl DEST(%esp), %eax movl DEST(%esp), %eax
RETURN_BOUNDED_POINTER (DEST(%esp))
LEAVE LEAVE
RET_PTR RET_PTR
END(memcpy) END (BP_SYM (memcpy))

View File

@ -21,6 +21,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.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 */
@ -30,14 +31,16 @@
#define LEN SRC+PTR_SIZE #define LEN SRC+PTR_SIZE
.text .text
ENTRY(__mempcpy) ENTRY (BP_SYM (__mempcpy))
ENTER ENTER
movl LEN(%esp), %ecx movl LEN(%esp), %ecx
movl %edi, %eax movl %edi, %eax
movl DEST(%esp), %edi movl DEST(%esp), %edi
CHECK_BOUNDS_BOTH_WIDE (%edi, DEST(%esp), %ecx)
movl %esi, %edx movl %esi, %edx
movl SRC(%esp), %esi movl SRC(%esp), %esi
CHECK_BOUNDS_BOTH_WIDE (%esi, SRC(%esp), %ecx)
cld cld
shrl $1, %ecx shrl $1, %ecx
jnc 1f jnc 1f
@ -49,8 +52,9 @@ ENTRY(__mempcpy)
movsl movsl
xchgl %edi, %eax xchgl %edi, %eax
movl %edx, %esi movl %edx, %esi
RETURN_BOUNDED_POINTER (DEST(%esp))
LEAVE LEAVE
RET_PTR RET_PTR
END(__mempcpy) END (BP_SYM (__mempcpy))
weak_alias (__mempcpy, mempcpy) weak_alias (BP_SYM (__mempcpy), BP_SYM (mempcpy))

View File

@ -21,6 +21,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ /* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */
@ -38,13 +39,14 @@
#endif #endif
.text .text
ENTRY (memset) ENTRY (BP_SYM (memset))
ENTER ENTER
cld cld
pushl %edi pushl %edi
movl DEST(%esp), %edx movl DEST(%esp), %edx
movl LEN(%esp), %ecx movl LEN(%esp), %ecx
CHECK_BOUNDS_BOTH_WIDE (%edx, DEST(%esp), %ecx)
#if BZERO_P #if BZERO_P
xorl %eax, %eax /* fill with 0 */ xorl %eax, %eax /* fill with 0 */
#else #else
@ -79,7 +81,8 @@ ENTRY (memset)
1: 1:
#if !BZERO_P #if !BZERO_P
movl DEST(%esp), %eax movl DEST(%esp), %eax /* start address of destination is result */
RETURN_BOUNDED_POINTER (DEST(%esp))
#endif #endif
popl %edi popl %edi
@ -89,4 +92,4 @@ ENTRY (memset)
#else #else
RET_PTR RET_PTR
#endif #endif
END (memset) END (BP_SYM (memset))

View File

@ -20,6 +20,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.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 */
@ -27,27 +28,37 @@
#define STR2 STR1+PTR_SIZE #define STR2 STR1+PTR_SIZE
.text .text
ENTRY (strcmp) ENTRY (BP_SYM (strcmp))
ENTER ENTER
movl STR1(%esp), %ecx movl STR1(%esp), %ecx
movl STR2(%esp), %edx movl STR2(%esp), %edx
CHECK_BOUNDS_LOW (%ecx, STR1(%esp))
CHECK_BOUNDS_LOW (%edx, STR2(%esp))
L(oop): movb (%ecx), %al L(oop): movb (%ecx), %al
incl %ecx
cmpb (%edx), %al cmpb (%edx), %al
jne L(neq) jne L(neq)
incl %ecx
incl %edx incl %edx
testb %al, %al testb %al, %al
jnz L(oop) jnz L(oop)
xorl %eax, %eax xorl %eax, %eax
/* when strings are equal, pointers rest one beyond
the end of the NUL terminators. */
CHECK_BOUNDS_HIGH (%ecx, STR1(%esp), jbe)
CHECK_BOUNDS_HIGH (%edx, STR2(%esp), jbe)
jmp L(out) jmp L(out)
L(neq): movl $1, %eax L(neq): movl $1, %eax
ja L(out) ja L(chk)
negl %eax negl %eax
/* When strings differ, pointers rest on
the unequal characters. */
L(chk): CHECK_BOUNDS_HIGH (%ecx, STR1(%esp), jb)
CHECK_BOUNDS_HIGH (%edx, STR2(%esp), jb)
L(out): LEAVE L(out): LEAVE
ret ret
END (strcmp) END (BP_SYM (strcmp))

View File

@ -1,6 +1,6 @@
/* strtok (str, delim) -- Return next DELIM separated token from STR. /* strtok (str, delim) -- Return next DELIM separated token from STR.
For Intel 80686. For Intel 80686.
Copyright (C) 1998 Free Software Foundation, Inc. Copyright (C) 1998, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@ -21,6 +21,8 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h"
/* This file can be used for three variants of the strtok function: /* This file can be used for three variants of the strtok function:
@ -45,7 +47,7 @@
save_ptr: save_ptr:
.space 4 .space 4
#define FUNCTION strtok #define FUNCTION BP_SYM (strtok)
#endif #endif
.text .text
@ -55,7 +57,14 @@ save_ptr:
ret ret
#endif #endif
ENTRY (FUNCTION) #define PARMS LINKAGE /* no space for saved regs */
#define RTN PARMS
#define STR RTN+RTN_SIZE
#define DELIM STR+PTR_SIZE
#define SAVE DELIM+PTR_SIZE
ENTRY (BP_SYM (FUNCTION))
ENTER
#if !defined USE_AS_STRTOK_R && defined PIC #if !defined USE_AS_STRTOK_R && defined PIC
pushl %ebx /* Save PIC register. */ pushl %ebx /* Save PIC register. */
@ -226,4 +235,4 @@ L(return):
L(returnNULL): L(returnNULL):
xorl %eax, %eax xorl %eax, %eax
jmp L(return) jmp L(return)
END (FUNCTION) END (BP_SYM (FUNCTION))

View File

@ -1,4 +1,4 @@
#define FUNCTION __strtok_r #define FUNCTION __strtok_r
#define USE_AS_STRTOK_R 1 #define USE_AS_STRTOK_R 1
#include <sysdeps/i386/i686/strtok.S> #include <sysdeps/i386/i686/strtok.S>
weak_alias (__strtok_r, strtok_r) weak_alias (BP_SYM (__strtok_r), BP_SYM (strtok_r))

View File

@ -19,6 +19,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+12 /* space for 3 saved regs */ #define PARMS LINKAGE+12 /* space for 3 saved regs */
@ -28,7 +29,7 @@
#define CNT SIZE+4 #define CNT SIZE+4
.text .text
ENTRY(__mpn_lshift) ENTRY (BP_SYM (__mpn_lshift))
ENTER ENTER
pushl %edi pushl %edi
@ -39,7 +40,12 @@ ENTRY(__mpn_lshift)
movl S(%esp),%esi movl S(%esp),%esi
movl SIZE(%esp),%edx movl SIZE(%esp),%edx
movl CNT(%esp),%ecx movl CNT(%esp),%ecx
#if __BOUNDED_POINTERS__
shll $2, %edx /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %edx)
CHECK_BOUNDS_BOTH_WIDE (%esi, S(%esp), %edx)
shrl $2, %edx
#endif
subl $4,%esi /* adjust s_ptr */ subl $4,%esi /* adjust s_ptr */
movl (%esi,%edx,4),%ebx /* read most significant limb */ movl (%esi,%edx,4),%ebx /* read most significant limb */
@ -84,4 +90,4 @@ L(end): shll %cl,%ebx /* compute least significant limb */
LEAVE LEAVE
ret ret
END(__mpn_lshift) END (BP_SYM (__mpn_lshift))

View File

@ -32,6 +32,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */ #define PARMS LINKAGE+8 /* space for 2 saved regs */
@ -41,7 +42,7 @@
#define LEN CHR+4 #define LEN CHR+4
.text .text
ENTRY (memchr) ENTRY (BP_SYM (memchr))
ENTER ENTER
/* Save callee-safe registers used in this function. */ /* Save callee-safe registers used in this function. */
@ -52,6 +53,7 @@ ENTRY (memchr)
movl STR(%esp), %eax /* str: pointer to memory block. */ movl STR(%esp), %eax /* str: pointer to memory block. */
movl CHR(%esp), %edx /* c: byte we are looking for. */ movl CHR(%esp), %edx /* c: byte we are looking for. */
movl LEN(%esp), %esi /* len: length of memory block. */ movl LEN(%esp), %esi /* len: length of memory block. */
CHECK_BOUNDS_BOTH_WIDE (%eax, STR(%esp), %esi)
/* If my must not test more than three characters test /* If my must not test more than three characters test
them one by one. This is especially true for 0. */ them one by one. This is especially true for 0. */
@ -310,10 +312,17 @@ L(8): testb %cl, %cl /* test first byte in dword */
incl %eax /* increment source pointer */ incl %eax /* increment source pointer */
/* No further test needed we we know it is one of the four bytes. */ /* No further test needed we we know it is one of the four bytes. */
L(9):
L(9): popl %edi /* pop saved registers */ #if __BOUNDED_POINTERS__
/* If RTN pointer is phony, don't copy return value into it. */
movl RTN(%esp), %ecx
testl %ecx, %ecx
jz L(pop)
RETURN_BOUNDED_POINTER (STR(%esp))
#endif
L(pop): popl %edi /* pop saved registers */
popl %esi popl %esi
LEAVE LEAVE
RET_PTR RET_PTR
END (memchr) END (BP_SYM (memchr))

View File

@ -19,6 +19,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */ #define PARMS LINKAGE+4 /* space for 1 saved reg */
@ -27,7 +28,7 @@
#define LEN BLK2+PTR_SIZE #define LEN BLK2+PTR_SIZE
.text .text
ENTRY (memcmp) ENTRY (BP_SYM (memcmp))
ENTER ENTER
pushl %esi /* Save callee-safe registers. */ pushl %esi /* Save callee-safe registers. */
@ -37,6 +38,8 @@ ENTRY (memcmp)
movl BLK1(%esp), %esi movl BLK1(%esp), %esi
movl BLK2(%esp), %edi movl BLK2(%esp), %edi
movl LEN(%esp), %ecx movl LEN(%esp), %ecx
CHECK_BOUNDS_BOTH_WIDE (%esi, BLK1(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%edi, BLK2(%esp), %ecx)
cld /* Set direction of comparison. */ cld /* Set direction of comparison. */
@ -64,7 +67,7 @@ L(1): popl %esi /* Restore registers. */
LEAVE LEAVE
ret ret
END (memcmp) END (BP_SYM (memcmp))
#undef bcmp #undef bcmp
weak_alias (memcmp, bcmp) weak_alias (BP_SYM (memcmp), BP_SYM (bcmp))

View File

@ -20,6 +20,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */ #define PARMS LINKAGE+16 /* space for 4 saved regs */
@ -34,7 +35,7 @@
#define s2_limb ebx #define s2_limb ebx
.text .text
ENTRY(__mpn_mul_1) ENTRY (BP_SYM (__mpn_mul_1))
ENTER ENTER
pushl %edi pushl %edi
@ -46,7 +47,13 @@ ENTRY(__mpn_mul_1)
movl S1(%esp), %s1_ptr movl S1(%esp), %s1_ptr
movl SIZE(%esp), %size movl SIZE(%esp), %size
movl S2LIMB(%esp), %s2_limb movl S2LIMB(%esp), %s2_limb
#if __BOUNDED_POINTERS__
shll $2, %size /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%res_ptr, RES(%esp), %size)
CHECK_BOUNDS_BOTH_WIDE (%s1_ptr, S1(%esp), %size)
CHECK_BOUNDS_BOTH_WIDE (%s2_limb, S2LIMB(%esp), %size)
shrl $2, %size
#endif
leal (%res_ptr,%size,4), %res_ptr leal (%res_ptr,%size,4), %res_ptr
leal (%s1_ptr,%size,4), %s1_ptr leal (%s1_ptr,%size,4), %s1_ptr
negl %size negl %size
@ -72,4 +79,4 @@ L(oop):
LEAVE LEAVE
ret ret
#undef size #undef size
END(__mpn_mul_1) END (BP_SYM (__mpn_mul_1))

View File

@ -31,6 +31,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */ #define PARMS LINKAGE+4 /* space for 1 saved reg */
@ -39,7 +40,7 @@
#define CHR STR+PTR_SIZE #define CHR STR+PTR_SIZE
.text .text
ENTRY (__rawmemchr) ENTRY (BP_SYM (__rawmemchr))
ENTER ENTER
/* Save callee-safe register used in this function. */ /* Save callee-safe register used in this function. */
@ -48,6 +49,7 @@ ENTRY (__rawmemchr)
/* Load parameters into registers. */ /* Load parameters into registers. */
movl STR(%esp), %eax movl STR(%esp), %eax
movl CHR(%esp), %edx movl CHR(%esp), %edx
CHECK_BOUNDS_LOW (%eax, STR(%esp))
/* At the moment %edx contains C. What we need for the /* At the moment %edx contains C. What we need for the
algorithm is C in all bytes of the dword. Avoid algorithm is C in all bytes of the dword. Avoid
@ -213,9 +215,13 @@ L(8): testb %cl, %cl /* test first byte in dword */
/* No further test needed we we know it is one of the four bytes. */ /* No further test needed we we know it is one of the four bytes. */
L(9): popl %edi /* pop saved register */ L(9):
CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
RETURN_BOUNDED_POINTER (STR(%esp))
popl %edi /* pop saved register */
LEAVE LEAVE
ret RET_PTR
END (__rawmemchr) END (BP_SYM (__rawmemchr))
weak_alias (__rawmemchr, rawmemchr)
weak_alias (BP_SYM (__rawmemchr), BP_SYM (rawmemchr))

View File

@ -19,6 +19,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+12 /* space for 3 saved regs */ #define PARMS LINKAGE+12 /* space for 3 saved regs */
@ -28,7 +29,7 @@
#define CNT SIZE+4 #define CNT SIZE+4
.text .text
ENTRY(__mpn_rshift) ENTRY (BP_SYM (__mpn_rshift))
ENTER ENTER
pushl %edi pushl %edi
@ -39,7 +40,12 @@ ENTRY(__mpn_rshift)
movl S(%esp),%esi movl S(%esp),%esi
movl SIZE(%esp),%edx movl SIZE(%esp),%edx
movl CNT(%esp),%ecx movl CNT(%esp),%ecx
#if __BOUNDED_POINTERS__
shll $2, %edx /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %edx)
CHECK_BOUNDS_BOTH_WIDE (%esi, S(%esp), %edx)
shrl $2, %edx
#endif
leal -4(%edi,%edx,4),%edi leal -4(%edi,%edx,4),%edi
leal (%esi,%edx,4),%esi leal (%esi,%edx,4),%esi
negl %edx negl %edx
@ -86,4 +92,4 @@ L(end): shrl %cl,%ebx /* compute most significant limb */
LEAVE LEAVE
ret ret
END(__mpn_rshift) END (BP_SYM (__mpn_rshift))

View File

@ -24,6 +24,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.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 */
@ -32,11 +33,13 @@
#define SRC DEST+PTR_SIZE #define SRC DEST+PTR_SIZE
.text .text
ENTRY (__stpcpy) ENTRY (BP_SYM (__stpcpy))
ENTER ENTER
movl DEST(%esp), %eax movl DEST(%esp), %eax
movl SRC(%esp), %ecx movl SRC(%esp), %ecx
CHECK_BOUNDS_LOW (%eax, DEST(%esp))
CHECK_BOUNDS_LOW (%ecx, SRC(%esp))
subl %eax, %ecx /* magic: reduce number of loop variants subl %eax, %ecx /* magic: reduce number of loop variants
to one using addressing mode */ to one using addressing mode */
@ -82,9 +85,11 @@ L(1): addl $4, %eax /* increment loop counter */
L(4): incl %eax L(4): incl %eax
L(3): incl %eax L(3): incl %eax
L(2): L(2):
CHECK_BOUNDS_HIGH (%eax, DEST(%esp), jb)
RETURN_BOUNDED_POINTER (DEST(%esp))
LEAVE LEAVE
RET_PTR RET_PTR
END (__stpcpy) END (BP_SYM (__stpcpy))
weak_alias (__stpcpy, stpcpy) weak_alias (BP_SYM (__stpcpy), BP_SYM (stpcpy))

View File

@ -26,6 +26,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */ #define PARMS LINKAGE+4 /* space for 1 saved reg */
@ -35,7 +36,7 @@
#define LEN SRC+PTR_SIZE #define LEN SRC+PTR_SIZE
.text .text
ENTRY (__stpncpy) ENTRY (BP_SYM (__stpncpy))
ENTER ENTER
pushl %esi pushl %esi
@ -43,6 +44,8 @@ ENTRY (__stpncpy)
movl DEST(%esp), %eax movl DEST(%esp), %eax
movl SRC(%esp), %esi movl SRC(%esp), %esi
movl LEN(%esp), %ecx movl LEN(%esp), %ecx
CHECK_BOUNDS_LOW (%eax, DEST(%esp))
CHECK_BOUNDS_LOW (%esi, SRC(%esp))
subl %eax, %esi /* magic: reduce number of loop variants subl %eax, %esi /* magic: reduce number of loop variants
to one using addressing mode */ to one using addressing mode */
@ -137,10 +140,17 @@ L(8):
L(3): decl %ecx /* all bytes written? */ L(3): decl %ecx /* all bytes written? */
jnz L(8) /* no, then again */ jnz L(8) /* no, then again */
L(9): popl %esi /* restore saved register content */ L(9):
#if __BOUNDED_POINTERS__
addl %eax, %esi /* undo magic: %esi now points beyond end of SRC */
CHECK_BOUNDS_HIGH (%esi, SRC(%esp), jb)
CHECK_BOUNDS_HIGH (%eax, DEST(%esp), jb)
RETURN_BOUNDED_POINTER (DEST(%esp))
#endif
popl %esi /* restore saved register content */
LEAVE LEAVE
RET_PTR RET_PTR
END (__stpncpy) END (BP_SYM (__stpncpy))
weak_alias (__stpncpy, stpncpy) weak_alias (BP_SYM (__stpncpy), BP_SYM (stpncpy))

View File

@ -22,6 +22,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */ #define PARMS LINKAGE+4 /* space for 1 saved reg */
@ -30,12 +31,13 @@
#define CHR STR+PTR_SIZE #define CHR STR+PTR_SIZE
.text .text
ENTRY (strchr) ENTRY (BP_SYM (strchr))
ENTER ENTER
pushl %edi /* Save callee-safe registers used here. */ pushl %edi /* Save callee-safe registers used here. */
movl STR(%esp), %eax movl STR(%esp), %eax
movl CHR(%esp), %edx movl CHR(%esp), %edx
CHECK_BOUNDS_LOW (%eax, STR(%esp))
/* At the moment %edx contains C. What we need for the /* At the moment %edx contains C. What we need for the
algorithm is C in all bytes of the dword. Avoid algorithm is C in all bytes of the dword. Avoid
@ -239,7 +241,8 @@ L(11): movl (%eax), %ecx /* get word (= 4 bytes) in question */
jz L(1) /* no NUL found => restart loop */ jz L(1) /* no NUL found => restart loop */
L(2): /* Return NULL. */ L(2): /* Return NULL. */
xorl %eax, %eax /* load NULL in return value register */ xorl %eax, %eax
RETURN_NULL_BOUNDED_POINTER
popl %edi /* restore saved register content */ popl %edi /* restore saved register content */
LEAVE LEAVE
@ -274,10 +277,13 @@ L(7): testb %cl, %cl /* is first byte C? */
/* It must be in the fourth byte and it cannot be NUL. */ /* It must be in the fourth byte and it cannot be NUL. */
incl %eax incl %eax
L(6): popl %edi /* restore saved register content */ L(6):
CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
RETURN_BOUNDED_POINTER (STR(%esp))
popl %edi /* restore saved register content */
LEAVE LEAVE
RET_PTR RET_PTR
END (strchr) END (BP_SYM (strchr))
weak_alias (strchr, index) weak_alias (BP_SYM (strchr), BP_SYM (index))

View File

@ -23,6 +23,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */ #define PARMS LINKAGE+4 /* space for 1 saved reg */
@ -31,13 +32,14 @@
#define CHR STR+PTR_SIZE #define CHR STR+PTR_SIZE
.text .text
ENTRY (__strchrnul) ENTRY (BP_SYM (__strchrnul))
ENTER ENTER
pushl %edi /* Save callee-safe registers used here. */ pushl %edi /* Save callee-safe registers used here. */
movl STR(%esp), %eax movl STR(%esp), %eax
movl CHR(%esp), %edx movl CHR(%esp), %edx
CHECK_BOUNDS_LOW (%eax, STR(%esp))
/* At the moment %edx contains CHR. What we need for the /* At the moment %edx contains CHR. What we need for the
algorithm is CHR in all bytes of the dword. Avoid algorithm is CHR in all bytes of the dword. Avoid
@ -269,10 +271,12 @@ L(7): testb %cl, %cl /* is first byte CHR? */
/* It must be in the fourth byte and it cannot be NUL. */ /* It must be in the fourth byte and it cannot be NUL. */
incl %eax incl %eax
L(6): popl %edi /* restore saved register content */ L(6): CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
RETURN_BOUNDED_POINTER (STR(%esp))
popl %edi /* restore saved register content */
LEAVE LEAVE
RET_PTR RET_PTR
END (__strchrnul) END (BP_SYM (__strchrnul))
weak_alias (__strchrnul, strchrnul) weak_alias (BP_SYM (__strchrnul), BP_SYM (strchrnul))

View File

@ -23,6 +23,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.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 */
@ -30,11 +31,12 @@
#define STOP STR+PTR_SIZE #define STOP STR+PTR_SIZE
.text .text
ENTRY (strcspn) ENTRY (BP_SYM (strcspn))
ENTER ENTER
movl STR(%esp), %edx movl STR(%esp), %edx
movl STOP(%esp), %eax movl STOP(%esp), %eax
CHECK_BOUNDS_LOW (%edx, STR(%esp))
/* First we create a table with flags for all possible characters. /* First we create a table with flags for all possible characters.
For the ASCII (7bit/8bit) or ISO-8859-X character sets which are For the ASCII (7bit/8bit) or ISO-8859-X character sets which are
@ -169,11 +171,11 @@ L(3): addl $4, %eax /* adjust pointer for full loop round */
L(6): incl %eax L(6): incl %eax
L(5): incl %eax L(5): incl %eax
L(4): subl %edx, %eax /* we have to return the number of valid L(4): addl $256, %esp /* remove stopset */
CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
subl %edx, %eax /* we have to return the number of valid
characters, so compute distance to first characters, so compute distance to first
non-valid character */ non-valid character */
addl $256, %esp /* remove stopset */
LEAVE LEAVE
ret ret
END (strcspn) END (BP_SYM (strcspn))

View File

@ -23,6 +23,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.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 */
@ -31,11 +32,12 @@
#define STOP STR+PTR_SIZE #define STOP STR+PTR_SIZE
.text .text
ENTRY (strpbrk) ENTRY (BP_SYM (strpbrk))
ENTER ENTER
movl STR(%esp), %edx movl STR(%esp), %edx
movl STOP(%esp), %eax movl STOP(%esp), %eax
CHECK_BOUNDS_LOW (%edx, STR(%esp))
/* First we create a table with flags for all possible characters. /* First we create a table with flags for all possible characters.
For the ASCII (7bit/8bit) or ISO-8859-X character sets which are For the ASCII (7bit/8bit) or ISO-8859-X character sets which are
@ -172,10 +174,17 @@ L(5): incl %eax
L(4): addl $256, %esp /* remove stopset */ L(4): addl $256, %esp /* remove stopset */
CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
orb %cl, %cl /* was last character NUL? */ orb %cl, %cl /* was last character NUL? */
jnz L(7) /* no => return pointer */ jnz L(7) /* no => return pointer */
xorl %eax, %eax /* return NULL */ xorl %eax, %eax
RETURN_NULL_BOUNDED_POINTER
L(7): LEAVE LEAVE
RET_PTR RET_PTR
END (strpbrk)
L(7): RETURN_BOUNDED_POINTER (STR(%esp))
LEAVE
RET_PTR
END (BP_SYM (strpbrk))

View File

@ -22,6 +22,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */ #define PARMS LINKAGE+8 /* space for 2 saved regs */
@ -30,7 +31,7 @@
#define CHR STR+PTR_SIZE #define CHR STR+PTR_SIZE
.text .text
ENTRY (strrchr) ENTRY (BP_SYM (strrchr))
ENTER ENTER
pushl %edi /* Save callee-safe registers used here. */ pushl %edi /* Save callee-safe registers used here. */
@ -39,6 +40,7 @@ ENTRY (strrchr)
xorl %eax, %eax xorl %eax, %eax
movl STR(%esp), %esi movl STR(%esp), %esi
movl CHR(%esp), %ecx movl CHR(%esp), %ecx
CHECK_BOUNDS_LOW (%esi, STR(%esp))
/* At the moment %ecx contains C. What we need for the /* At the moment %ecx contains C. What we need for the
algorithm is C in all bytes of the dword. Avoid algorithm is C in all bytes of the dword. Avoid
@ -319,11 +321,13 @@ L(26): testb %dl, %dl /* is third byte == NUL */
jne L(2) /* no => skip */ jne L(2) /* no => skip */
leal 3(%esi), %eax /* store address as result */ leal 3(%esi), %eax /* store address as result */
L(2): popl %esi /* restore saved register content */ L(2): CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
RETURN_BOUNDED_POINTER (STR(%esp))
popl %esi /* restore saved register content */
popl %edi popl %edi
LEAVE LEAVE
RET_PTR RET_PTR
END (strrchr) END (BP_SYM (strrchr))
weak_alias (strrchr, rindex) weak_alias (BP_SYM (strrchr), BP_SYM (rindex))

View File

@ -23,6 +23,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.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 */
@ -30,11 +31,12 @@
#define SKIP STR+PTR_SIZE #define SKIP STR+PTR_SIZE
.text .text
ENTRY (strspn) ENTRY (BP_SYM (strspn))
ENTER ENTER
movl STR(%esp), %edx movl STR(%esp), %edx
movl SKIP(%esp), %eax movl SKIP(%esp), %eax
CHECK_BOUNDS_LOW (%edx, STR(%esp))
/* First we create a table with flags for all possible characters. /* First we create a table with flags for all possible characters.
For the ASCII (7bit/8bit) or ISO-8859-X character sets which are For the ASCII (7bit/8bit) or ISO-8859-X character sets which are
@ -169,11 +171,11 @@ L(3): addl $4, %eax /* adjust pointer for full loop round */
L(6): incl %eax L(6): incl %eax
L(5): incl %eax L(5): incl %eax
L(4): subl %edx, %eax /* we have to return the number of valid L(4): addl $256, %esp /* remove stopset */
CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
subl %edx, %eax /* we have to return the number of valid
characters, so compute distance to first characters, so compute distance to first
non-valid character */ non-valid character */
addl $256, %esp /* remove stopset */
LEAVE LEAVE
ret ret
END (strspn) END (BP_SYM (strspn))

View File

@ -21,6 +21,7 @@
#include <sysdep.h> #include <sysdep.h>
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
/* This file can be used for three variants of the strtok function: /* This file can be used for three variants of the strtok function:
@ -56,12 +57,13 @@ save_ptr:
#define SAVE DELIM+PTR_SIZE #define SAVE DELIM+PTR_SIZE
.text .text
ENTRY (BP_SYM (FUNCTION))
ENTRY (FUNCTION)
ENTER ENTER
movl STR(%esp), %edx movl STR(%esp), %edx
movl DELIM(%esp), %eax movl DELIM(%esp), %eax
CHECK_BOUNDS_LOW (%edx, STR(%esp))
CHECK_BOUNDS_LOW (%eax, DELIM(%esp))
#if !defined (USE_AS_STRTOK_R) && defined (PIC) #if !defined (USE_AS_STRTOK_R) && defined (PIC)
pushl %ebx /* Save PIC register. */ pushl %ebx /* Save PIC register. */
@ -169,17 +171,17 @@ L(0):
L(2): movb (%eax), %cl /* get byte from stopset */ L(2): movb (%eax), %cl /* get byte from stopset */
testb %cl, %cl /* is NUL char? */ testb %cl, %cl /* is NUL char? */
jz L(1) /* yes => start compare loop */ jz L(1_1) /* yes => start compare loop */
movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */ movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */
movb 1(%eax), %cl /* get byte from stopset */ movb 1(%eax), %cl /* get byte from stopset */
testb $0xff, %cl /* is NUL char? */ testb $0xff, %cl /* is NUL char? */
jz L(1) /* yes => start compare loop */ jz L(1_2) /* yes => start compare loop */
movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */ movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */
movb 2(%eax), %cl /* get byte from stopset */ movb 2(%eax), %cl /* get byte from stopset */
testb $0xff, %cl /* is NUL char? */ testb $0xff, %cl /* is NUL char? */
jz L(1) /* yes => start compare loop */ jz L(1_3) /* yes => start compare loop */
movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */ movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */
movb 3(%eax), %cl /* get byte from stopset */ movb 3(%eax), %cl /* get byte from stopset */
@ -188,7 +190,16 @@ L(2): movb (%eax), %cl /* get byte from stopset */
testb $0xff, %cl /* is NUL char? */ testb $0xff, %cl /* is NUL char? */
jnz L(2) /* no => process next dword from stopset */ jnz L(2) /* no => process next dword from stopset */
L(1): leal -4(%edx), %eax /* prepare loop */ #if __BOUNDED_POINTERS__
jmp L(1_0) /* pointer is correct for bounds check */
L(1_3): incl %eax /* adjust pointer for bounds check */
L(1_2): incl %eax /* ditto */
L(1_1): incl %eax /* ditto */
L(1_0): CHECK_BOUNDS_HIGH (%eax, DELIM(%esp), jb)
#else
L(1_3):; L(1_2):; L(1_1): /* fall through */
#endif
leal -4(%edx), %eax /* prepare loop */
/* We use a neat trick for the following loop. Normally we would /* We use a neat trick for the following loop. Normally we would
have to test for two termination conditions have to test for two termination conditions
@ -274,11 +285,20 @@ L(return):
movl %edx, save_ptr@GOTOFF(%ebx) movl %edx, save_ptr@GOTOFF(%ebx)
popl %ebx popl %ebx
# endif # endif
#endif
#if __BOUNDED_POINTERS__
testl %eax, %eax
jz L(ret)
CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
RETURN_BOUNDED_POINTER (STR(%esp))
L(ret):
#endif #endif
LEAVE LEAVE
RET_PTR RET_PTR
L(returnNULL): L(returnNULL):
xorl %eax, %eax xorl %eax, %eax
RETURN_NULL_BOUNDED_POINTER
jmp L(return) jmp L(return)
END (FUNCTION)
END (BP_SYM (FUNCTION))

View File

@ -1,4 +1,4 @@
#define FUNCTION __strtok_r #define FUNCTION __strtok_r
#define USE_AS_STRTOK_R 1 #define USE_AS_STRTOK_R 1
#include <sysdeps/i386/strtok.S> #include <sysdeps/i386/strtok.S>
weak_alias (__strtok_r, strtok_r) weak_alias (BP_SYM (__strtok_r), BP_SYM (strtok_r))

View File

@ -20,6 +20,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */ #define PARMS LINKAGE+8 /* space for 2 saved regs */
@ -29,7 +30,7 @@
#define SIZE S2+PTR_SIZE #define SIZE S2+PTR_SIZE
.text .text
ENTRY(__mpn_sub_n) ENTRY (BP_SYM (__mpn_sub_n))
ENTER ENTER
pushl %edi pushl %edi
@ -39,7 +40,13 @@ ENTRY(__mpn_sub_n)
movl S1(%esp),%esi movl S1(%esp),%esi
movl S2(%esp),%edx movl S2(%esp),%edx
movl SIZE(%esp),%ecx movl SIZE(%esp),%ecx
#if __BOUNDED_POINTERS__
shll $2, %ecx /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%esi, S1(%esp), %ecx)
CHECK_BOUNDS_BOTH_WIDE (%edx, S2(%esp), %ecx)
shrl $2, %ecx
#endif
movl %ecx,%eax movl %ecx,%eax
shrl $3,%ecx /* compute count for unrolled loop */ shrl $3,%ecx /* compute count for unrolled loop */
negl %eax negl %eax
@ -103,4 +110,4 @@ L(oop): movl (%esi),%eax
LEAVE LEAVE
ret ret
END(__mpn_sub_n) END (BP_SYM (__mpn_sub_n))

View File

@ -20,6 +20,7 @@
#include "sysdep.h" #include "sysdep.h"
#include "asm-syntax.h" #include "asm-syntax.h"
#include "bp-sym.h"
#include "bp-asm.h" #include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */ #define PARMS LINKAGE+16 /* space for 4 saved regs */
@ -34,7 +35,7 @@
#define s2_limb ebx #define s2_limb ebx
.text .text
ENTRY(__mpn_submul_1) ENTRY (BP_SYM (__mpn_submul_1))
ENTER ENTER
pushl %edi pushl %edi
@ -46,7 +47,13 @@ ENTRY(__mpn_submul_1)
movl S1(%esp), %s1_ptr movl S1(%esp), %s1_ptr
movl SIZE(%esp), %sizeP movl SIZE(%esp), %sizeP
movl S2LIMB(%esp), %s2_limb movl S2LIMB(%esp), %s2_limb
#if __BOUNDED_POINTERS__
shll $2, %sizeP /* convert limbs to bytes */
CHECK_BOUNDS_BOTH_WIDE (%res_ptr, RES(%esp), %sizeP)
CHECK_BOUNDS_BOTH_WIDE (%s1_ptr, S1(%esp), %sizeP)
CHECK_BOUNDS_BOTH_WIDE (%s2_limb, S2LIMB(%esp), %sizeP)
shrl $2, %sizeP
#endif
leal (%res_ptr,%sizeP,4), %res_ptr leal (%res_ptr,%sizeP,4), %res_ptr
leal (%s1_ptr,%sizeP,4), %s1_ptr leal (%s1_ptr,%sizeP,4), %s1_ptr
negl %sizeP negl %sizeP
@ -72,4 +79,4 @@ L(oop):
LEAVE LEAVE
ret ret
END(__mpn_submul_1) END (BP_SYM (__mpn_submul_1))