Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 236054 | Differences between
and this patch

Collapse All | Expand All

(-)gmp-5.0.1.orig/tests/x86call.asm (-36 / +72 lines)
Lines 1-6 Link Here
1
dnl  x86 calling conventions checking.
1
dnl  x86 calling conventions checking.
2
2
3
dnl  Copyright 2000, 2003 Free Software Foundation, Inc.
3
dnl  Copyright 2000, 2003, 2010 Free Software Foundation, Inc.
4
dnl
4
dnl
5
dnl  This file is part of the GNU MP Library.
5
dnl  This file is part of the GNU MP Library.
6
dnl
6
dnl
Lines 18-23 Link Here
18
dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
18
dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
19
20
20
21
dnl  The current version of the code attempts to keep the call/return
22
dnl  prediction stack valid, but matching calls and returns.
23
21
include(`../config.m4')
24
include(`../config.m4')
22
25
23
26
Lines 61-66 Link Here
61
C Perhaps the finit should be done only if the tags word isn't clear, but
64
C Perhaps the finit should be done only if the tags word isn't clear, but
62
C nothing uses the rounding mode or anything at the moment.
65
C nothing uses the rounding mode or anything at the moment.
63
66
67
define(`WANT_EBX', eval(4*0)($1))
68
define(`WANT_EBP', eval(4*1)($1))
69
define(`WANT_ESI', eval(4*2)($1))
70
define(`WANT_EDI', eval(4*3)($1))
71
72
define(`JUNK_EAX', eval(4*4)($1))
73
define(`JUNK_ECX', eval(4*5)($1))
74
define(`JUNK_EDX', eval(4*6)($1))
75
76
define(`SAVE_EBX', eval(4*7)($1))
77
define(`SAVE_EBP', eval(4*8)($1))
78
define(`SAVE_ESI', eval(4*9)($1))
79
define(`SAVE_EDI', eval(4*10)($1))
80
81
define(`RETADDR',  eval(4*11)($1))
82
83
define(`EBX',	   eval(4*12)($1))
84
define(`EBP',	   eval(4*13)($1))
85
define(`ESI',	   eval(4*14)($1))
86
define(`EDI',	   eval(4*15)($1))
87
define(`EFLAGS',   eval(4*16)($1))
88
89
64
define(G,
90
define(G,
65
m4_assert_numargs(1)
91
m4_assert_numargs(1)
66
`GSYM_PREFIX`'$1')
92
`GSYM_PREFIX`'$1')
Lines 68-115 Link Here
68
	.text
94
	.text
69
	ALIGN(8)
95
	ALIGN(8)
70
PROLOGUE(calling_conventions)
96
PROLOGUE(calling_conventions)
71
	movl	(%esp), %eax
97
	LEA(	G(calling_conventions_values), %ecx)
72
	movl	%eax, G(calling_conventions_retaddr)
98
	popl	RETADDR(%ecx)
73
99
74
	movl	$L(return), (%esp)
100
	movl	%ebx, SAVE_EBX(%ecx)
75
101
	movl	%ebp, SAVE_EBP(%ecx)
76
	movl	%ebx, G(calling_conventions_save_ebx)
102
	movl	%esi, SAVE_ESI(%ecx)
77
	movl	%esi, G(calling_conventions_save_esi)
103
	movl	%edi, SAVE_EDI(%ecx)
78
	movl	%edi, G(calling_conventions_save_edi)
104
79
	movl	%ebp, G(calling_conventions_save_ebp)
105
	movl	WANT_EBX(%ecx), %ebx
80
106
	movl	WANT_EBP(%ecx), %ebp
81
	movl	$0x01234567, %ebx
107
	movl	WANT_ESI(%ecx), %esi
82
	movl	$0x89ABCDEF, %esi
108
	movl	WANT_EDI(%ecx), %edi
83
	movl	$0xFEDCBA98, %edi
109
84
	movl	$0x76543210, %ebp
110
	C try to provoke a problem by starting with junk in the caller-saves
85
111
	C registers, especially in %eax and %edx which will be return values
86
	C try to provoke a problem by starting with junk in the registers,
112
	movl	JUNK_EAX(%ecx), %eax
87
	C especially in %eax and %edx which will be return values
113
	movl	JUNK_EDX(%ecx), %edx
88
	movl	$0x70246135, %eax
114
C	movl	JUNK_ECX(%ecx), %ecx
89
	movl	$0x8ACE9BDF, %ecx
115
90
	movl	$0xFDB97531, %edx
116
ifdef(`PIC',`
91
117
	LEA(	G(calling_conventions_function), %ecx)
92
	jmp	*G(calling_conventions_function)
118
	call	*(%ecx)
93
119
',`
94
L(return):
120
	call	*G(calling_conventions_function)
95
	movl	%ebx, G(calling_conventions_ebx)
121
')
96
	movl	%esi, G(calling_conventions_esi)
122
97
	movl	%edi, G(calling_conventions_edi)
123
	LEA(	G(calling_conventions_values), %ecx)
98
	movl	%ebp, G(calling_conventions_ebp)
124
125
	movl	%ebx, EBX(%ecx)
126
	movl	%ebp, EBP(%ecx)
127
	movl	%esi, ESI(%ecx)
128
	movl	%edi, EDI(%ecx)
99
129
100
	pushf
130
	pushf
101
	popl	%ebx
131
	popl	%ebx
102
	movl	%ebx, G(calling_conventions_eflags)
132
	movl	%ebx, EFLAGS(%ecx)
103
133
134
	movl	SAVE_EBX(%ecx), %ebx
135
	movl	SAVE_ESI(%ecx), %esi
136
	movl	SAVE_EDI(%ecx), %edi
137
	movl	SAVE_EBP(%ecx), %ebp
138
139
	pushl	RETADDR(%ecx)
140
141
ifdef(`PIC',`
142
	LEA(	G(calling_conventions_fenv), %ecx)
143
	fstenv	(%ecx)
144
',`
104
	fstenv	G(calling_conventions_fenv)
145
	fstenv	G(calling_conventions_fenv)
146
')
105
	finit
147
	finit
106
148
107
	movl	G(calling_conventions_save_ebx), %ebx
149
	ret
108
	movl	G(calling_conventions_save_esi), %esi
109
	movl	G(calling_conventions_save_edi), %edi
110
	movl	G(calling_conventions_save_ebp), %ebp
111
112
	jmp	*G(calling_conventions_retaddr)
113
150
114
EPILOGUE()
151
EPILOGUE()
115
(-)gmp-5.0.1.orig/tests/x86check.c (-19 / +35 lines)
Lines 1-7 Link Here
1
/* x86 calling conventions checking. */
1
/* x86 calling conventions checking. */
2
2
3
/*
3
/*
4
Copyright 2000, 2001 Free Software Foundation, Inc.
4
Copyright 2000, 2001, 2010 Free Software Foundation, Inc.
5
5
6
This file is part of the GNU MP Library.
6
This file is part of the GNU MP Library.
7
7
Lines 24-36 Link Here
24
#include "tests.h"
24
#include "tests.h"
25
25
26
26
27
/* temporaries */
27
/* Vector if constants and register values.  We use one vector to allow access
28
int  calling_conventions_save_ebx;
28
   via a base pointer, very beneficial for the PIC-enabled amd64call.asm.  */
29
int  calling_conventions_save_esi;
29
mp_limb_t calling_conventions_values[17] =
30
int  calling_conventions_save_edi;
30
{
31
int  calling_conventions_save_ebp;
31
  CNST_LIMB(0x12345678),	/* want_ebx */
32
int  calling_conventions_retaddr;
32
  CNST_LIMB(0x89ABCDEF),	/* want_ebp */
33
int  calling_conventions_retval;
33
  CNST_LIMB(0xDEADBEEF),	/* want_esi */
34
  CNST_LIMB(0xFFEEDDCC),	/* want_edi */
35
36
  CNST_LIMB(0xFEEDABBA),	/* JUNK_EAX */
37
  CNST_LIMB(0xAB78DE89),	/* JUNK_ECX */
38
  CNST_LIMB(0x12389018)		/* JUNK_EDX */
39
40
  /* rest of array used for dynamic values.  */
41
};
42
43
/* Index starts for various regions in above vector.  */
44
#define WANT	0
45
#define JUNK	4
46
#define SAVE	7
47
#define RETADDR	11
48
#define VAL	12
49
#define EFLAGS	16
50
34
51
35
/* values to check */
52
/* values to check */
36
struct {
53
struct {
Lines 39-49 Link Here
39
  unsigned  tag;
56
  unsigned  tag;
40
  unsigned  other[4];
57
  unsigned  other[4];
41
} calling_conventions_fenv;
58
} calling_conventions_fenv;
42
int  calling_conventions_ebx;
43
int  calling_conventions_esi;
44
int  calling_conventions_edi;
45
int  calling_conventions_ebp;
46
int  calling_conventions_eflags;
47
59
48
/* expected values, as per x86call.asm */
60
/* expected values, as per x86call.asm */
49
#define VALUE_EBX   0x01234567
61
#define VALUE_EBX   0x01234567
Lines 51-56 Link Here
51
#define VALUE_EDI   0xFEDCBA98
63
#define VALUE_EDI   0xFEDCBA98
52
#define VALUE_EBP   0x76543210
64
#define VALUE_EBP   0x76543210
53
65
66
67
const char *regname[] = {"ebx", "ebp", "esi", "edi"};
68
54
#define DIR_BIT(eflags)   (((eflags) & (1<<10)) != 0)
69
#define DIR_BIT(eflags)   (((eflags) & (1<<10)) != 0)
55
70
56
71
Lines 61-66 Link Here
61
{
76
{
62
  const char  *header = "Violated calling conventions:\n";
77
  const char  *header = "Violated calling conventions:\n";
63
  int  ret = 1;
78
  int  ret = 1;
79
  int i;
64
80
65
#define CHECK(callreg, regstr, value)                   \
81
#define CHECK(callreg, regstr, value)                   \
66
  if (callreg != value)                                 \
82
  if (callreg != value)                                 \
Lines 71-85 Link Here
71
      ret = 0;                                          \
87
      ret = 0;                                          \
72
    }
88
    }
73
89
74
  CHECK (calling_conventions_ebx, "ebx", VALUE_EBX);
90
  for (i = 0; i < 4; i++)
75
  CHECK (calling_conventions_esi, "esi", VALUE_ESI);
91
    {
76
  CHECK (calling_conventions_edi, "edi", VALUE_EDI);
92
      CHECK (calling_conventions_values[VAL+i], regname[i], calling_conventions_values[WANT+i]);
77
  CHECK (calling_conventions_ebp, "ebp", VALUE_EBP);
93
    }
78
94
79
  if (DIR_BIT (calling_conventions_eflags) != 0)
95
  if (DIR_BIT (calling_conventions_values[EFLAGS]) != 0)
80
    {
96
    {
81
      printf ("%s   eflags dir bit  got %d want 0\n",
97
      printf ("%s   eflags dir bit  got %d want 0\n",
82
              header, DIR_BIT (calling_conventions_eflags));
98
              header, DIR_BIT (calling_conventions_values[EFLAGS]));
83
      header = "";
99
      header = "";
84
      ret = 0;
100
      ret = 0;
85
    }
101
    }

Return to bug 236054