diff options
author | Greg McGary <greg@mcgary.org> | 2000-07-26 18:21:25 +0000 |
---|---|---|
committer | Greg McGary <greg@mcgary.org> | 2000-07-26 18:21:25 +0000 |
commit | 2ed5fd9a2ab9b9b82f7095116d8f8434b73383cc (patch) | |
tree | ac727a020d668748761bbcf5f7ce92e4c818b0b3 /sysdeps/i386/strtok.S | |
parent | ac556388135e5bf0578cb24bc958870ff3a0f00c (diff) | |
download | glibc-2ed5fd9a2ab9b9b82f7095116d8f8434b73383cc.tar.gz glibc-2ed5fd9a2ab9b9b82f7095116d8f8434b73383cc.tar.xz glibc-2ed5fd9a2ab9b9b82f7095116d8f8434b73383cc.zip |
update
2000-07-26 Greg McGary <greg@mcgary.org> * Makeconfig (+link-bounded, link-libc-bounded, link-extra-libs-bounded): New variables. (built-program-cmd): Omit $(run-program-prefix) for static BP tests. * Makerules (do-tests-clean, common-mostlyclean): Remove BP test files. * Rules (tests-bp.out): New variable. (tests): Conditionally add BP tests. (binaries-bounded): Add variable and associated rule. * csu/Makefile [build-bounded] (extra-objs, install-lib): Move conditional stuff after place where condition is defined. * malloc/malloc.c (bp-checks.h): Add #include. (mem2chunk, chunk_at_offset, bin_at): Wrap BOUNDED_1 around expression. (_bin_at): Add unbounded version of bin_at. (IAV, chunk_alloc): Use unbounded _bin_at. (mALLOc, rEALLOc, chunk_realloc, mEMALIGn, cALLOc, chunk2mem_check, realloc_check, malloc_starter, malloc_atfork): Wrap BOUNDED_N around return value. (chunk_realloc): Adjust oldsize once. * sysdeps/generic/bp-checks.h (__memchr): Remove incorrect decl. (__ubp_memchr): Add correct decl. (_CHECK_STRING): Use __ubp_memchr. * sysdeps/alpha/memchr.S [!__BOUNDED_POINTERS__] (__ubp_memchr): New alias for unbounded-pointer __memchr. * sysdeps/i386/memchr.S: Likewise. * sysdeps/ia64/memchr.S: Likewise. * sysdeps/m68k/memchr.S: Likewise. * sysdeps/sparc/sparc32/memchr.S: Likewise. * sysdeps/sparc/sparc64/memchr.S: Likewise. * sysdeps/vax/memchr.s: Likewise. * sysdeps/i386/strtok.S: Fix bounds checks to pass tests. (SAVE_PTR): New macro. (save_ptr): Expand size as BP. (strtok): Don't bother to write into SAVE_PTR when returning NULL. * sysdeps/i386/i686/strtok.S: Likewise. * sysdeps/i386/bp-asm.h (RETURN_BOUNDED_POINTER, RETURN_NULL_BOUNDED_POINTER): Use %ecx as the scratch register. * sysdeps/i386/bits/string.h [!__BOUNDED_POINTERS__]: Disable inlines. * sysdeps/i386/i486/bits/string.h [!__BOUNDED_POINTERS__]: Likewise. * sysdeps/unix/sysv/linux/getsysstats.c (get_proc_path): Copy bounds of copy_result to mount_proc.
Diffstat (limited to 'sysdeps/i386/strtok.S')
-rw-r--r-- | sysdeps/i386/strtok.S | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/sysdeps/i386/strtok.S b/sysdeps/i386/strtok.S index 47924b2237..ff8980a924 100644 --- a/sysdeps/i386/strtok.S +++ b/sysdeps/i386/strtok.S @@ -39,15 +39,27 @@ We do a common implementation here. */ -#ifndef USE_AS_STRTOK_R +#ifdef USE_AS_STRTOK_R +# define SAVE_PTR 0(%ecx) +#else .bss .local save_ptr ASM_TYPE_DIRECTIVE (save_ptr, @object) .size save_ptr, 4 save_ptr: +# if __BOUNDED_POINTERS__ + .space 12 +# else .space 4 +# endif + +# ifdef PIC +# define SAVE_PTR save_ptr@GOTOFF(%ebx) +# else +# define SAVE_PTR save_ptr +# endif -#define FUNCTION strtok +# define FUNCTION strtok #endif #define PARMS LINKAGE /* no space for saved regs */ @@ -62,10 +74,9 @@ ENTRY (BP_SYM (FUNCTION)) 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) +#if !defined USE_AS_STRTOK_R && defined PIC pushl %ebx /* Save PIC register. */ call L(here) L(here): @@ -76,7 +87,22 @@ L(here): /* If the pointer is NULL we have to use the stored value of the last run. */ cmpl $0, %edx - jne L(0) +#if __BOUNDED_POINTERS__ + movl SAVE(%esp), %ecx + je L(0) + /* Save bounds of incoming non-NULL STR into save area. */ + movl 4+STR(%esp), %eax + movl %eax, 4+SAVE_PTR + movl 8+STR(%esp), %eax + movl %eax, 8+SAVE_PTR + CHECK_BOUNDS_LOW (%edx, SAVE_PTR) + jmp L(1) +L(0): movl SAVE_PTR, %edx + CHECK_BOUNDS_LOW (%edx, SAVE_PTR) + jmp L(1) +#else + jne L(1) +#endif #ifdef USE_AS_STRTOK_R /* The value is stored in the third argument. */ @@ -85,14 +111,10 @@ L(here): #else /* The value is in the local variable defined above. But we have to take care for PIC code. */ -# ifndef PIC - movl save_ptr, %edx -# else - movl save_ptr@GOTOFF(%ebx), %edx -# endif + movl SAVE_PTR, %edx #endif -L(0): +L(1): /* First we create a table with flags for all possible characters. For the ASCII (7bit/8bit) or ISO-8859-X character sets which are supported by the C string functions we have 256 characters. @@ -195,7 +217,7 @@ L(2): movb (%eax), %cl /* get byte from stopset */ 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) +L(1_0): CHECK_BOUNDS_HIGH (%eax, DELIM(%esp), jbe) #else L(1_3):; L(1_2):; L(1_1): /* fall through */ #endif @@ -273,25 +295,17 @@ L(8): /* Remove the stopset table. */ incl %edx L(11): -L(return): /* Store the pointer to the next character. */ #ifdef USE_AS_STRTOK_R movl SAVE(%esp), %ecx - movl %edx, (%ecx) -#else -# ifndef PIC - movl %edx, save_ptr -# else - movl %edx, save_ptr@GOTOFF(%ebx) - 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): + movl %edx, SAVE_PTR + CHECK_BOUNDS_HIGH (%edx, SAVE_PTR, jb) + RETURN_BOUNDED_POINTER (SAVE_PTR) + +L(epilogue): +#if !defined USE_AS_STRTOK_R && defined PIC + popl %ebx #endif LEAVE RET_PTR @@ -299,6 +313,6 @@ L(ret): L(returnNULL): xorl %eax, %eax RETURN_NULL_BOUNDED_POINTER - jmp L(return) + jmp L(epilogue) END (BP_SYM (FUNCTION)) |