Skip to content

Commit

Permalink
* sysdeps/i386/fpu/s_frexp.S: Check bounds.
Browse files Browse the repository at this point in the history
Wrap extern symbols in BP_SYM (). 
* sysdeps/i386/fpu/s_frexpf.S: Likewise. 
* sysdeps/i386/fpu/s_frexpl.S: Likewise. 
* sysdeps/i386/fpu/s_remquo.S: Likewise. 
* sysdeps/i386/fpu/s_remquof.S: Likewise. 
* sysdeps/i386/fpu/s_remquol.S: Likewise. 
* sysdeps/i386/fpu/s_sincos.S: Likewise. 
* sysdeps/i386/fpu/s_sincosf.S: Likewise. 
* sysdeps/i386/fpu/s_sincosl.S: Likewise. 
* sysdeps/unix/sysv/linux/i386/clone.S: Likewise. 
* sysdeps/unix/sysv/linux/i386/mmap64.S: Likewise.
  • Loading branch information
Greg McGary committed Aug 17, 2000
1 parent 9a81430 commit 9e25f6e
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 103 deletions.
36 changes: 24 additions & 12 deletions sysdeps/i386/fpu/s_frexp.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ix87 specific frexp implementation for double.
Copyright (C) 1997 Free Software Foundation, Inc.
Copyright (C) 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand All @@ -19,6 +19,8 @@
Boston, MA 02111-1307, USA. */

#include <machine/asm.h>
#include "bp-sym.h"
#include "bp-asm.h"

#ifdef __ELF__
.section .rodata
Expand All @@ -37,10 +39,17 @@ two54: .byte 0, 0, 0, 0, 0, 0, 0x50, 0x43
#define MO(op) op
#endif

#define PARMS LINKAGE /* no space for saved regs */
#define VAL0 PARMS
#define VAL1 VAL0+4
#define EXPP VAL1+4

.text
ENTRY(__frexp)
movl 4(%esp), %ecx
movl 8(%esp), %eax
ENTRY (BP_SYM (__frexp))
ENTER

movl VAL0(%esp), %ecx
movl VAL1(%esp), %eax
movl %eax, %edx
andl $0x7fffffff, %eax
orl %eax, %ecx
Expand All @@ -52,16 +61,16 @@ ENTRY(__frexp)
cmpl $0x00100000, %eax
jae 2f

fldl 4(%esp)
fldl VAL0(%esp)
#ifdef PIC
call 3f
3: popl %edx
addl $_GLOBAL_OFFSET_TABLE_+[.-3b], %edx
#endif
fmull MO(two54)
movl $-54, %ecx
fstpl 4(%esp)
movl 8(%esp), %eax
fstpl VAL0(%esp)
movl VAL1(%esp), %eax
movl %eax, %edx
andl $0x7fffffff, %eax

Expand All @@ -70,13 +79,16 @@ ENTRY(__frexp)
subl $1022, %eax
orl $0x3fe00000, %edx
addl %eax, %ecx
movl %edx, 8(%esp)
movl %edx, VAL1(%esp)

/* Store %ecx in the variable pointed to by the second argument,
get the factor from the stack and return. */
1: movl 12(%esp), %eax
fldl 4(%esp)
1: movl EXPP(%esp), %eax
CHECK_BOUNDS_BOTH_WIDE (%eax, EXPP(%esp), $4)
fldl VAL0(%esp)
movl %ecx, (%eax)

LEAVE
ret
END(__frexp)
weak_alias (__frexp, frexp)
END (BP_SYM (__frexp))
weak_alias (BP_SYM (__frexp), BP_SYM (frexp))
33 changes: 22 additions & 11 deletions sysdeps/i386/fpu/s_frexpf.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ix87 specific frexp implementation for float.
Copyright (C) 1997 Free Software Foundation, Inc.
Copyright (C) 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand All @@ -19,6 +19,8 @@
Boston, MA 02111-1307, USA. */

#include <machine/asm.h>
#include "bp-sym.h"
#include "bp-asm.h"

#ifdef __ELF__
.section .rodata
Expand All @@ -37,9 +39,15 @@ two25: .byte 0, 0, 0, 0x4c
#define MO(op) op
#endif

#define PARMS LINKAGE /* no space for saved regs */
#define VAL PARMS
#define EXPP VAL+4

.text
ENTRY(__frexpf)
movl 4(%esp), %eax
ENTRY (BP_SYM (__frexpf))
ENTER

movl VAL(%esp), %eax
xorl %ecx, %ecx
movl %eax, %edx
andl $0x7fffffff, %eax
Expand All @@ -50,16 +58,16 @@ ENTRY(__frexpf)
cmpl $0x00800000, %eax
jae 2f

flds 4(%esp)
flds VAL(%esp)
#ifdef PIC
call 3f
3: popl %edx
addl $_GLOBAL_OFFSET_TABLE_+[.-3b], %edx
#endif
fmuls MO(two25)
movl $-25, %ecx
fstps 4(%esp)
movl 4(%esp), %eax
fstps VAL(%esp)
movl VAL(%esp), %eax
movl %eax, %edx
andl $0x7fffffff, %eax

Expand All @@ -68,13 +76,16 @@ ENTRY(__frexpf)
subl $126, %eax
orl $0x3f000000, %edx
addl %eax, %ecx
movl %edx, 4(%esp)
movl %edx, VAL(%esp)

/* Store %ecx in the variable pointed to by the second argument,
get the factor from the stack and return. */
1: movl 8(%esp), %eax
flds 4(%esp)
1: movl EXPP(%esp), %eax
CHECK_BOUNDS_BOTH_WIDE (%eax, EXPP(%esp), $4)
flds VAL(%esp)
movl %ecx, (%eax)

LEAVE
ret
END(__frexpf)
weak_alias (__frexpf, frexpf)
END (BP_SYM (__frexpf))
weak_alias (BP_SYM (__frexpf), BP_SYM (frexpf))
39 changes: 26 additions & 13 deletions sysdeps/i386/fpu/s_frexpl.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ix87 specific frexp implementation for long double.
Copyright (C) 1997 Free Software Foundation, Inc.
Copyright (C) 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand All @@ -19,6 +19,8 @@
Boston, MA 02111-1307, USA. */

#include <machine/asm.h>
#include "bp-sym.h"
#include "bp-asm.h"

#ifdef __ELF__
.section .rodata
Expand All @@ -37,11 +39,19 @@ two64: .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x43
#define MO(op) op
#endif

#define PARMS LINKAGE /* no space for saved regs */
#define VAL0 PARMS
#define VAL1 VAL0+4
#define VAL2 VAL1+4
#define EXPP VAL2+4

.text
ENTRY(__frexpl)
movl 4(%esp), %ecx
movl 12(%esp), %eax
orl 8(%esp), %ecx
ENTRY (BP_SYM (__frexpl))
ENTER

movl VAL0(%esp), %ecx
movl VAL2(%esp), %eax
orl VAL1(%esp), %ecx
movl %eax, %edx
andl $0x7fff, %eax
orl %eax, %ecx
Expand All @@ -53,30 +63,33 @@ ENTRY(__frexpl)
cmpl $0, %eax
je 2f

fldt 4(%esp)
fldt VAL0(%esp)
#ifdef PIC
call 3f
3: popl %edx
addl $_GLOBAL_OFFSET_TABLE_+[.-3b], %edx
#endif
fmull MO(two64) /* It's not necessary to use a 80bit factor */
movl $-64, %ecx
fstpt 4(%esp)
movl 12(%esp), %eax
fstpt VAL0(%esp)
movl VAL2(%esp), %eax
movl %eax, %edx
andl $0x7fff, %eax

2: andl $0x8000, %edx
subl $16382, %eax
orl $0x3ffe, %edx
addl %eax, %ecx
movl %edx, 12(%esp)
movl %edx, VAL2(%esp)

/* Store %ecx in the variable pointed to by the second argument,
get the factor from the stack and return. */
1: movl 16(%esp), %eax
fldt 4(%esp)
1: movl EXPP(%esp), %eax
CHECK_BOUNDS_BOTH_WIDE (%eax, EXPP(%esp), $4)
fldt VAL0(%esp)
movl %ecx, (%eax)

LEAVE
ret
END(__frexpl)
weak_alias (__frexpl, frexpl)
END (BP_SYM (__frexpl))
weak_alias (BP_SYM (__frexpl), BP_SYM (frexpl))
29 changes: 21 additions & 8 deletions sysdeps/i386/fpu/s_remquo.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
*/

#include <machine/asm.h>
#include "bp-sym.h"
#include "bp-asm.h"

ENTRY(__remquo)
fldl 12(%esp)
fldl 4(%esp)
#define PARMS LINKAGE /* no space for saved regs */
#define DVDND PARMS
#define DVSOR DVDND+8
#define QUOP DVSOR+8

.text
ENTRY (BP_SYM (__remquo))
ENTER

fldl DVSOR(%esp)
fldl DVDND(%esp)
1: fprem1
fstsw %ax
sahf
Expand All @@ -24,13 +34,16 @@ ENTRY(__remquo)
movl $0xef2960, %eax
shrl %cl, %eax
andl $3, %eax
movl 20(%esp), %ecx
movl 8(%esp), %edx
xorl 16(%esp), %edx
movl QUOP(%esp), %ecx
CHECK_BOUNDS_BOTH_WIDE (%ecx, QUOP(%esp), $4)
movl DVDND+4(%esp), %edx
xorl DVSOR+4(%esp), %edx
testl $0x80000000, %edx
jz 1f
negl %eax
1: movl %eax, (%ecx)

LEAVE
ret
END (__remquo)
weak_alias (__remquo, remquo)
END (BP_SYM (__remquo))
weak_alias (BP_SYM (__remquo), BP_SYM (remquo))
29 changes: 21 additions & 8 deletions sysdeps/i386/fpu/s_remquof.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
*/

#include <machine/asm.h>
#include "bp-sym.h"
#include "bp-asm.h"

ENTRY(__remquof)
flds 8(%esp)
flds 4(%esp)
#define PARMS LINKAGE /* no space for saved regs */
#define DVDND PARMS
#define DVSOR DVDND+4
#define QUOP DVSOR+4

.text
ENTRY (BP_SYM (__remquof))
ENTER

flds DVSOR(%esp)
flds DVDND(%esp)
1: fprem1
fstsw %ax
sahf
Expand All @@ -24,13 +34,16 @@ ENTRY(__remquof)
movl $0xef2960, %eax
shrl %cl, %eax
andl $3, %eax
movl 12(%esp), %ecx
movl 4(%esp), %edx
xorl 8(%esp), %edx
movl QUOP(%esp), %ecx
CHECK_BOUNDS_BOTH_WIDE (%ecx, QUOP(%esp), $4)
movl DVDND(%esp), %edx
xorl DVSOR(%esp), %edx
testl $0x80000000, %edx
jz 1f
negl %eax
1: movl %eax, (%ecx)

LEAVE
ret
END (__remquof)
weak_alias (__remquof, remquof)
END (BP_SYM (__remquof))
weak_alias (BP_SYM (__remquof), BP_SYM (remquof))
29 changes: 21 additions & 8 deletions sysdeps/i386/fpu/s_remquol.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
*/

#include <machine/asm.h>
#include "bp-sym.h"
#include "bp-asm.h"

ENTRY(__remquol)
fldt 16(%esp)
fldt 4(%esp)
#define PARMS LINKAGE /* no space for saved regs */
#define DVDND PARMS
#define DVSOR DVDND+12
#define QUOP DVSOR+12

.text
ENTRY (BP_SYM (__remquol))
ENTER

fldt DVSOR(%esp)
fldt DVDND(%esp)
1: fprem1
fstsw %ax
sahf
Expand All @@ -24,13 +34,16 @@ ENTRY(__remquol)
movl $0xef2960, %eax
shrl %cl, %eax
andl $3, %eax
movl 28(%esp), %ecx
movl 12(%esp), %edx
xorl 24(%esp), %edx
movl QUOP(%esp), %ecx
CHECK_BOUNDS_BOTH_WIDE (%ecx, QUOP(%esp), $4)
movl DVDND+8(%esp), %edx
xorl DVSOR+8(%esp), %edx
testl $0x8000, %edx
jz 1f
negl %eax
1: movl %eax, (%ecx)

LEAVE
ret
END (__remquol)
weak_alias (__remquol, remquol)
END (BP_SYM (__remquol))
weak_alias (BP_SYM (__remquol), BP_SYM (remquol))
Loading

0 comments on commit 9e25f6e

Please sign in to comment.