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.
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/mul_1.S: Likewise.
* sysdeps/i386/submul_1.S: Likewise.
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */
#define SIZE S2+PTR_SIZE
.text
-ENTRY(__mpn_add_n)
+ENTRY (BP_SYM (__mpn_add_n))
ENTER
pushl %edi
movl S1(%esp),%esi
movl S2(%esp),%edx
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
shrl $3,%ecx /* compute count for unrolled loop */
negl %eax
LEAVE
ret
-END(__mpn_add_n)
+END (BP_SYM (__mpn_add_n))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */
#define s2_limb ebx
.text
-ENTRY(__mpn_addmul_1)
+ENTRY (BP_SYM (__mpn_addmul_1))
ENTER
pushl %edi
movl S1(%esp), %s1_ptr
movl SIZE(%esp), %sizeP
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 (%s1_ptr,%sizeP,4), %s1_ptr
negl %sizeP
LEAVE
ret
-END(__mpn_addmul_1)
+END (BP_SYM (__mpn_addmul_1))
Boston, MA 02111-1307, USA. */
#include <fenv.h>
+#include <bp-sym.h>
int
__fegetenv (fenv_t *envp)
return 0;
}
strong_alias (__fegetenv, __old_fegetenv)
-symbol_version (__old_fegetenv, fegetenv, GLIBC_2.1);
-default_symbol_version (__fegetenv, fegetenv, GLIBC_2.2);
+symbol_version (BP_SYM (__old_fegetenv), BP_SYM (fegetenv), GLIBC_2.1);
+default_symbol_version (BP_SYM (__fegetenv), BP_SYM (fegetenv), GLIBC_2.2);
Boston, MA 02111-1307, USA. */
#include <fenv.h>
-
#include <assert.h>
+#include <bp-sym.h>
int
return 0;
}
strong_alias (__fesetenv, __old_fesetenv)
-symbol_version (__old_fesetenv, fesetenv, GLIBC_2.1);
-default_symbol_version (__fesetenv, fesetenv, GLIBC_2.2);
+symbol_version (BP_SYM (__old_fesetenv), BP_SYM (fesetenv), GLIBC_2.1);
+default_symbol_version (BP_SYM (__fesetenv), BP_SYM (fesetenv), GLIBC_2.2);
Boston, MA 02111-1307, USA. */
#include <fenv.h>
+#include <bp-sym.h>
int
__feupdateenv (const fenv_t *envp)
return 0;
}
strong_alias (__feupdateenv, __old_feupdateenv)
-symbol_version (__old_feupdateenv, feupdateenv, GLIBC_2.1);
-default_symbol_version (__feupdateenv, feupdateenv, GLIBC_2.2);
+symbol_version (BP_SYM (__old_feupdateenv), BP_SYM (feupdateenv), GLIBC_2.1);
+default_symbol_version (BP_SYM (__feupdateenv), BP_SYM (feupdateenv), GLIBC_2.2);
Boston, MA 02111-1307, USA. */
#include <fenv.h>
+#include <bp-sym.h>
int
__fegetexceptflag (fexcept_t *flagp, int excepts)
return 0;
}
strong_alias (__fegetexceptflag, __old_fegetexceptflag)
-symbol_version (__old_fegetexceptflag, fegetexceptflag, GLIBC_2.1);
-default_symbol_version (__fegetexceptflag, fegetexceptflag, GLIBC_2.2);
+symbol_version (BP_SYM (__old_fegetexceptflag), BP_SYM (fegetexceptflag), GLIBC_2.1);
+default_symbol_version (BP_SYM (__fegetexceptflag), BP_SYM (fegetexceptflag), GLIBC_2.2);
#include <fenv.h>
#include <math.h>
+#include <bp-sym.h>
int
__fesetexceptflag (const fexcept_t *flagp, int excepts)
return 0;
}
strong_alias (__fesetexceptflag, __old_fesetexceptflag)
-symbol_version (__old_fesetexceptflag, fesetexceptflag, GLIBC_2.1);
-default_symbol_version (__fesetexceptflag, fesetexceptflag, GLIBC_2.2);
+symbol_version (BP_SYM (__old_fesetexceptflag), BP_SYM (fesetexceptflag), GLIBC_2.1);
+default_symbol_version (BP_SYM (__fesetexceptflag), BP_SYM (fesetexceptflag), GLIBC_2.2);
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */
#define SRC DEST+PTR_SIZE
.text
-ENTRY (strcat)
+ENTRY (BP_SYM (strcat))
ENTER
pushl %edi /* Save callee-safe register. */
movl DEST(%esp), %edx
movl SRC(%esp), %ecx
+ CHECK_BOUNDS_LOW (%edx, DEST(%esp))
+ CHECK_BOUNDS_LOW (%ecx, SRC(%esp))
testb $0xff, (%ecx) /* Is source string empty? */
jz L(8) /* yes => return */
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 */
LEAVE
RET_PTR
-END (strcat)
+END (BP_SYM (strcat))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE /* no space for saved regs */
#define STR PARMS
.text
-ENTRY (strlen)
+ENTRY (BP_SYM (strlen))
ENTER
movl STR(%esp), %ecx
+ CHECK_BOUNDS_LOW (%ecx, STR(%esp))
movl %ecx, %eax /* duplicate it */
andl $3, %ecx /* mask alignment bits */
jz L(2) /* yes => return 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
ret
-END (strlen)
+END (BP_SYM (strlen))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */
#define SIZE S2+PTR_SIZE
.text
-ENTRY(__mpn_add_n)
+ENTRY (BP_SYM (__mpn_add_n))
ENTER
pushl %edi
movl S1(%esp),%esi
movl S2(%esp),%ebx
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
decl %ecx
LEAVE
ret
-END(__mpn_add_n)
+END (BP_SYM (__mpn_add_n))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */
#define s2_limb ebx
.text
-ENTRY(__mpn_addmul_1)
+ENTRY (BP_SYM (__mpn_addmul_1))
ENTER
pushl %edi
movl S1(%esp), %s1_ptr
movl SIZE(%esp), %size
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 (%s1_ptr,%size,4), %s1_ptr
negl %size
LEAVE
ret
#undef size
-END(__mpn_addmul_1)
+END (BP_SYM (__mpn_addmul_1))
#define memset __bzero
#include <sysdeps/i386/i586/memset.S>
-weak_alias (__bzero, bzero)
+weak_alias (BP_SYM (__bzero), BP_SYM (bzero))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */
#define CNT SIZE+4
.text
-ENTRY(__mpn_lshift)
+ENTRY (BP_SYM (__mpn_lshift))
ENTER
pushl %edi
movl S(%esp),%esi
movl SIZE(%esp),%ebx
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. */
cmp $1,%ecx
LEAVE
ret
-END(__mpn_lshift)
+END (BP_SYM (__mpn_lshift))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
/* BEWARE: `#ifdef memcpy' means that memcpy is redefined as `mempcpy',
#define LEN SRC+PTR_SIZE
.text
-ENTRY (memcpy)
+ENTRY (BP_SYM (memcpy))
ENTER
pushl %edi
movl DEST(%esp), %edi
movl SRC(%esp), %esi
movl LEN(%esp), %ecx
+ CHECK_BOUNDS_BOTH_WIDE (%edi, DEST(%esp), %ecx)
+ CHECK_BOUNDS_BOTH_WIDE (%esi, SRC(%esp), %ecx)
movl %edi, %eax
/* We need this in any case. */
LEAVE
RET_PTR
-END (memcpy)
+END (BP_SYM (memcpy))
#define memcpy __mempcpy
#include <sysdeps/i386/i586/memcpy.S>
-weak_alias (__mempcpy, mempcpy)
+weak_alias (BP_SYM (__mempcpy), BP_SYM (mempcpy))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */
#endif
.text
-ENTRY (memset)
+ENTRY (BP_SYM (memset))
ENTER
pushl %edi
movl DEST(%esp), %edi
movl LEN(%esp), %edx
+ CHECK_BOUNDS_BOTH_WIDE (%edi, DEST(%esp), %edx)
#if BZERO_P
xorl %eax, %eax /* we fill with 0 */
#else
movb CHR(%esp), %al
-
movb %al, %ah
movl %eax, %ecx
shll $16, %eax
#if !BZERO_P
/* 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
popl %edi
#else
RET_PTR
#endif
-END (memset)
+END (BP_SYM (memset))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */
#define CNT SIZE+4
.text
-ENTRY(__mpn_rshift)
+ENTRY (BP_SYM (__mpn_rshift))
ENTER
pushl %edi
movl S(%esp),%esi
movl SIZE(%esp),%ebx
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. */
cmp $1,%ecx
LEAVE
ret
-END(__mpn_rshift)
+END (BP_SYM (__mpn_rshift))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
/* This version is especially optimized for the i586 (and following?)
#define CHR STR+PTR_SIZE
.text
-ENTRY (strchr)
+ENTRY (BP_SYM (strchr))
ENTER
pushl %edi /* Save callee-safe registers. */
movl STR(%esp), %eax
movl CHR(%esp), %edx
+ CHECK_BOUNDS_LOW (%eax, STR(%esp))
movl %eax, %edi /* duplicate string pointer for later */
xorl %ecx, %ecx /* clear %ecx */
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 %esi
cmpb %dl, %ch /* fourth byte == C? */
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 %ebx
LEAVE
RET_PTR
-END (strchr)
+END (BP_SYM (strchr))
#undef index
-weak_alias (strchr, index)
+weak_alias (BP_SYM (strchr), BP_SYM (index))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+12 /* space for 3 saved regs */
#define magic 0xfefefeff
.text
-ENTRY(STRCPY)
+ENTRY (BP_SYM (STRCPY))
ENTER
pushl %edi
movl DEST(%esp), %edi
movl SRC(%esp), %esi
+ CHECK_BOUNDS_LOW (%edi, DEST(%esp))
+ CHECK_BOUNDS_LOW (%esi, SRC(%esp))
xorl %eax, %eax
leal -1(%esi), %ecx
L(end): movb %ah, (%edi)
L(end2):
+ /* GKM FIXME: check high bounds */
#ifdef USE_AS_STPCPY
movl %edi, %eax
#else
movl DEST(%esp), %eax
#endif
+ RETURN_BOUNDED_POINTER (DEST(%esp))
popl %ebx
popl %esi
popl %edi
LEAVE
RET_PTR
-END(STRCPY)
+END (BP_SYM (STRCPY))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
/* This version is especially optimized for the i586 (and following?)
#define STR PARMS
.text
-ENTRY(strlen)
+ENTRY (BP_SYM (strlen))
ENTER
movl STR(%esp), %eax
+ CHECK_BOUNDS_LOW (%eax, STR(%esp))
movl $3, %edx /* load mask (= 3) */
andl %eax, %edx /* separate last two bits of address */
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
character */
LEAVE
ret
-END (strlen)
+END (BP_SYM (strlen))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */
#define SIZE S2+PTR_SIZE
.text
-ENTRY(__mpn_sub_n)
+ENTRY (BP_SYM (__mpn_sub_n))
ENTER
pushl %edi
movl S1(%esp),%esi
movl S2(%esp),%ebx
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
decl %ecx
LEAVE
ret
-END(__mpn_sub_n)
+END (BP_SYM (__mpn_sub_n))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */
L(1): addl (%esp), %eax
ret
#endif
-ENTRY(__mpn_add_n)
+ENTRY (BP_SYM (__mpn_add_n))
ENTER
pushl %edi
movl S1(%esp),%esi
movl S2(%esp),%edx
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
shrl $3,%ecx /* compute count for unrolled loop */
negl %eax
LEAVE
ret
-END(__mpn_add_n)
+END (BP_SYM (__mpn_add_n))
#define memset __bzero
#include <sysdeps/i386/i686/memset.S>
-weak_alias (__bzero, bzero)
+weak_alias (BP_SYM (__bzero), BP_SYM (bzero))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE /* no space for saved regs */
#define LEN SRC+PTR_SIZE
.text
-ENTRY(memcpy)
+ENTRY (BP_SYM (memcpy))
ENTER
movl LEN(%esp), %ecx
movl DEST(%esp), %edi
movl %esi, %edx
movl SRC(%esp), %esi
+ CHECK_BOUNDS_BOTH_WIDE (%edi, DEST(%esp), %ecx)
+ CHECK_BOUNDS_BOTH_WIDE (%esi, SRC(%esp), %ecx)
+
cld
shrl $1, %ecx
jnc 1f
movl %eax, %edi
movl %edx, %esi
movl DEST(%esp), %eax
+ RETURN_BOUNDED_POINTER (DEST(%esp))
LEAVE
RET_PTR
-END(memcpy)
+END (BP_SYM (memcpy))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE /* no space for saved regs */
#define LEN SRC+PTR_SIZE
.text
-ENTRY(__mempcpy)
+ENTRY (BP_SYM (__mempcpy))
ENTER
movl LEN(%esp), %ecx
movl %edi, %eax
movl DEST(%esp), %edi
+ CHECK_BOUNDS_BOTH_WIDE (%edi, DEST(%esp), %ecx)
movl %esi, %edx
movl SRC(%esp), %esi
+ CHECK_BOUNDS_BOTH_WIDE (%esi, SRC(%esp), %ecx)
cld
shrl $1, %ecx
jnc 1f
movsl
xchgl %edi, %eax
movl %edx, %esi
+ RETURN_BOUNDED_POINTER (DEST(%esp))
LEAVE
RET_PTR
-END(__mempcpy)
-weak_alias (__mempcpy, mempcpy)
+END (BP_SYM (__mempcpy))
+weak_alias (BP_SYM (__mempcpy), BP_SYM (mempcpy))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */
#endif
.text
-ENTRY (memset)
+ENTRY (BP_SYM (memset))
ENTER
cld
pushl %edi
movl DEST(%esp), %edx
movl LEN(%esp), %ecx
+ CHECK_BOUNDS_BOTH_WIDE (%edx, DEST(%esp), %ecx)
#if BZERO_P
xorl %eax, %eax /* fill with 0 */
#else
1:
#if !BZERO_P
- movl DEST(%esp), %eax
+ movl DEST(%esp), %eax /* start address of destination is result */
+ RETURN_BOUNDED_POINTER (DEST(%esp))
#endif
popl %edi
#else
RET_PTR
#endif
-END (memset)
+END (BP_SYM (memset))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE /* no space for saved regs */
#define STR2 STR1+PTR_SIZE
.text
-ENTRY (strcmp)
+ENTRY (BP_SYM (strcmp))
ENTER
movl STR1(%esp), %ecx
movl STR2(%esp), %edx
+ CHECK_BOUNDS_LOW (%ecx, STR1(%esp))
+ CHECK_BOUNDS_LOW (%edx, STR2(%esp))
L(oop): movb (%ecx), %al
- incl %ecx
cmpb (%edx), %al
jne L(neq)
+ incl %ecx
incl %edx
testb %al, %al
jnz L(oop)
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)
L(neq): movl $1, %eax
- ja L(out)
+ ja L(chk)
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
ret
-END (strcmp)
+END (BP_SYM (strcmp))
/* strtok (str, delim) -- Return next DELIM separated token from STR.
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.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
#include <sysdep.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:
save_ptr:
.space 4
-#define FUNCTION strtok
+#define FUNCTION BP_SYM (strtok)
#endif
.text
ret
#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
pushl %ebx /* Save PIC register. */
L(returnNULL):
xorl %eax, %eax
jmp L(return)
-END (FUNCTION)
+END (BP_SYM (FUNCTION))
#define FUNCTION __strtok_r
#define USE_AS_STRTOK_R 1
#include <sysdeps/i386/i686/strtok.S>
-weak_alias (__strtok_r, strtok_r)
+weak_alias (BP_SYM (__strtok_r), BP_SYM (strtok_r))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+12 /* space for 3 saved regs */
#define CNT SIZE+4
.text
-ENTRY(__mpn_lshift)
+ENTRY (BP_SYM (__mpn_lshift))
ENTER
pushl %edi
movl S(%esp),%esi
movl SIZE(%esp),%edx
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 */
movl (%esi,%edx,4),%ebx /* read most significant limb */
LEAVE
ret
-END(__mpn_lshift)
+END (BP_SYM (__mpn_lshift))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */
#define LEN CHR+4
.text
-ENTRY (memchr)
+ENTRY (BP_SYM (memchr))
ENTER
/* Save callee-safe registers used in this function. */
movl STR(%esp), %eax /* str: pointer to memory block. */
movl CHR(%esp), %edx /* c: byte we are looking for. */
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
them one by one. This is especially true for 0. */
incl %eax /* increment source pointer */
/* No further test needed we we know it is one of the four bytes. */
-
-L(9): popl %edi /* pop saved registers */
+L(9):
+#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
LEAVE
RET_PTR
-END (memchr)
+END (BP_SYM (memchr))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */
#define LEN BLK2+PTR_SIZE
.text
-ENTRY (memcmp)
+ENTRY (BP_SYM (memcmp))
ENTER
pushl %esi /* Save callee-safe registers. */
movl BLK1(%esp), %esi
movl BLK2(%esp), %edi
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. */
LEAVE
ret
-END (memcmp)
+END (BP_SYM (memcmp))
#undef bcmp
-weak_alias (memcmp, bcmp)
+weak_alias (BP_SYM (memcmp), BP_SYM (bcmp))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */
#define s2_limb ebx
.text
-ENTRY(__mpn_mul_1)
+ENTRY (BP_SYM (__mpn_mul_1))
ENTER
pushl %edi
movl S1(%esp), %s1_ptr
movl SIZE(%esp), %size
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 (%s1_ptr,%size,4), %s1_ptr
negl %size
LEAVE
ret
#undef size
-END(__mpn_mul_1)
+END (BP_SYM (__mpn_mul_1))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */
#define CHR STR+PTR_SIZE
.text
-ENTRY (__rawmemchr)
+ENTRY (BP_SYM (__rawmemchr))
ENTER
/* Save callee-safe register used in this function. */
/* Load parameters into registers. */
movl STR(%esp), %eax
movl CHR(%esp), %edx
+ CHECK_BOUNDS_LOW (%eax, STR(%esp))
/* At the moment %edx contains C. What we need for the
algorithm is C in all bytes of the dword. Avoid
/* 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
- ret
-END (__rawmemchr)
-weak_alias (__rawmemchr, rawmemchr)
+ RET_PTR
+END (BP_SYM (__rawmemchr))
+
+weak_alias (BP_SYM (__rawmemchr), BP_SYM (rawmemchr))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+12 /* space for 3 saved regs */
#define CNT SIZE+4
.text
-ENTRY(__mpn_rshift)
+ENTRY (BP_SYM (__mpn_rshift))
ENTER
pushl %edi
movl S(%esp),%esi
movl SIZE(%esp),%edx
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 (%esi,%edx,4),%esi
negl %edx
LEAVE
ret
-END(__mpn_rshift)
+END (BP_SYM (__mpn_rshift))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE /* no space for saved regs */
#define SRC DEST+PTR_SIZE
.text
-ENTRY (__stpcpy)
+ENTRY (BP_SYM (__stpcpy))
ENTER
movl DEST(%esp), %eax
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
to one using addressing mode */
L(4): incl %eax
L(3): incl %eax
L(2):
+ CHECK_BOUNDS_HIGH (%eax, DEST(%esp), jb)
+ RETURN_BOUNDED_POINTER (DEST(%esp))
LEAVE
RET_PTR
-END (__stpcpy)
+END (BP_SYM (__stpcpy))
-weak_alias (__stpcpy, stpcpy)
+weak_alias (BP_SYM (__stpcpy), BP_SYM (stpcpy))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */
#define LEN SRC+PTR_SIZE
.text
-ENTRY (__stpncpy)
+ENTRY (BP_SYM (__stpncpy))
ENTER
pushl %esi
movl DEST(%esp), %eax
movl SRC(%esp), %esi
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
to one using addressing mode */
L(3): decl %ecx /* all bytes written? */
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
RET_PTR
-END (__stpncpy)
+END (BP_SYM (__stpncpy))
-weak_alias (__stpncpy, stpncpy)
+weak_alias (BP_SYM (__stpncpy), BP_SYM (stpncpy))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */
#define CHR STR+PTR_SIZE
.text
-ENTRY (strchr)
+ENTRY (BP_SYM (strchr))
ENTER
pushl %edi /* Save callee-safe registers used here. */
movl STR(%esp), %eax
movl CHR(%esp), %edx
+ CHECK_BOUNDS_LOW (%eax, STR(%esp))
/* At the moment %edx contains C. What we need for the
algorithm is C in all bytes of the dword. Avoid
jz L(1) /* no NUL found => restart loop */
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 */
LEAVE
/* It must be in the fourth byte and it cannot be NUL. */
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
RET_PTR
-END (strchr)
+END (BP_SYM (strchr))
-weak_alias (strchr, index)
+weak_alias (BP_SYM (strchr), BP_SYM (index))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+4 /* space for 1 saved reg */
#define CHR STR+PTR_SIZE
.text
-ENTRY (__strchrnul)
+ENTRY (BP_SYM (__strchrnul))
ENTER
pushl %edi /* Save callee-safe registers used here. */
movl STR(%esp), %eax
movl CHR(%esp), %edx
+ CHECK_BOUNDS_LOW (%eax, STR(%esp))
/* At the moment %edx contains CHR. What we need for the
algorithm is CHR in all bytes of the dword. Avoid
/* It must be in the fourth byte and it cannot be NUL. */
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
RET_PTR
-END (__strchrnul)
+END (BP_SYM (__strchrnul))
-weak_alias (__strchrnul, strchrnul)
+weak_alias (BP_SYM (__strchrnul), BP_SYM (strchrnul))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE /* no space for saved regs */
#define STOP STR+PTR_SIZE
.text
-ENTRY (strcspn)
+ENTRY (BP_SYM (strcspn))
ENTER
movl STR(%esp), %edx
movl STOP(%esp), %eax
+ CHECK_BOUNDS_LOW (%edx, STR(%esp))
/* First we create a table with flags for all possible characters.
For the ASCII (7bit/8bit) or ISO-8859-X character sets which are
L(6): 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
non-valid character */
- addl $256, %esp /* remove stopset */
-
LEAVE
ret
-END (strcspn)
+END (BP_SYM (strcspn))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE /* no space for saved regs */
#define STOP STR+PTR_SIZE
.text
-ENTRY (strpbrk)
+ENTRY (BP_SYM (strpbrk))
ENTER
movl STR(%esp), %edx
movl STOP(%esp), %eax
+ CHECK_BOUNDS_LOW (%edx, STR(%esp))
/* First we create a table with flags for all possible characters.
For the ASCII (7bit/8bit) or ISO-8859-X character sets which are
L(4): addl $256, %esp /* remove stopset */
+ CHECK_BOUNDS_HIGH (%eax, STR(%esp), jb)
orb %cl, %cl /* was last character NUL? */
- jnz L(7) /* no => return pointer */
- xorl %eax, %eax /* return NULL */
+ jnz L(7) /* no => return pointer */
+ xorl %eax, %eax
+ RETURN_NULL_BOUNDED_POINTER
-L(7): LEAVE
+ LEAVE
RET_PTR
-END (strpbrk)
+
+L(7): RETURN_BOUNDED_POINTER (STR(%esp))
+
+ LEAVE
+ RET_PTR
+END (BP_SYM (strpbrk))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */
#define CHR STR+PTR_SIZE
.text
-ENTRY (strrchr)
+ENTRY (BP_SYM (strrchr))
ENTER
pushl %edi /* Save callee-safe registers used here. */
xorl %eax, %eax
movl STR(%esp), %esi
movl CHR(%esp), %ecx
+ CHECK_BOUNDS_LOW (%esi, STR(%esp))
/* At the moment %ecx contains C. What we need for the
algorithm is C in all bytes of the dword. Avoid
jne L(2) /* no => skip */
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
LEAVE
RET_PTR
-END (strrchr)
+END (BP_SYM (strrchr))
-weak_alias (strrchr, rindex)
+weak_alias (BP_SYM (strrchr), BP_SYM (rindex))
#include <sysdep.h>
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE /* no space for saved regs */
#define SKIP STR+PTR_SIZE
.text
-ENTRY (strspn)
+ENTRY (BP_SYM (strspn))
ENTER
movl STR(%esp), %edx
movl SKIP(%esp), %eax
+ CHECK_BOUNDS_LOW (%edx, STR(%esp))
/* First we create a table with flags for all possible characters.
For the ASCII (7bit/8bit) or ISO-8859-X character sets which are
L(6): 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
non-valid character */
- addl $256, %esp /* remove stopset */
-
LEAVE
ret
-END (strspn)
+END (BP_SYM (strspn))
#include <sysdep.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:
#define SAVE DELIM+PTR_SIZE
.text
-
-ENTRY (FUNCTION)
+ENTRY (BP_SYM (FUNCTION))
ENTER
movl STR(%esp), %edx
movl DELIM(%esp), %eax
+ CHECK_BOUNDS_LOW (%edx, STR(%esp))
+ CHECK_BOUNDS_LOW (%eax, DELIM(%esp))
#if !defined (USE_AS_STRTOK_R) && defined (PIC)
pushl %ebx /* Save PIC register. */
L(2): movb (%eax), %cl /* get byte from stopset */
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 1(%eax), %cl /* get byte from stopset */
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 2(%eax), %cl /* get byte from stopset */
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 3(%eax), %cl /* get byte from stopset */
testb $0xff, %cl /* is NUL char? */
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
have to test for two termination conditions
popl %ebx
# 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
LEAVE
RET_PTR
L(returnNULL):
xorl %eax, %eax
+ RETURN_NULL_BOUNDED_POINTER
jmp L(return)
-END (FUNCTION)
+
+END (BP_SYM (FUNCTION))
#define FUNCTION __strtok_r
#define USE_AS_STRTOK_R 1
#include <sysdeps/i386/strtok.S>
-weak_alias (__strtok_r, strtok_r)
+weak_alias (BP_SYM (__strtok_r), BP_SYM (strtok_r))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+8 /* space for 2 saved regs */
#define SIZE S2+PTR_SIZE
.text
-ENTRY(__mpn_sub_n)
+ENTRY (BP_SYM (__mpn_sub_n))
ENTER
pushl %edi
movl S1(%esp),%esi
movl S2(%esp),%edx
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
shrl $3,%ecx /* compute count for unrolled loop */
negl %eax
LEAVE
ret
-END(__mpn_sub_n)
+END (BP_SYM (__mpn_sub_n))
#include "sysdep.h"
#include "asm-syntax.h"
+#include "bp-sym.h"
#include "bp-asm.h"
#define PARMS LINKAGE+16 /* space for 4 saved regs */
#define s2_limb ebx
.text
-ENTRY(__mpn_submul_1)
+ENTRY (BP_SYM (__mpn_submul_1))
ENTER
pushl %edi
movl S1(%esp), %s1_ptr
movl SIZE(%esp), %sizeP
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 (%s1_ptr,%sizeP,4), %s1_ptr
negl %sizeP
LEAVE
ret
-END(__mpn_submul_1)
+END (BP_SYM (__mpn_submul_1))