Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 263955 Details for
Bug 236054
dev-libs/gmp-4.2.2-r2: text relocations in tests which fails on hardened
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
GMP PIC x86 tests patch
gmp-5.0.1-pic.diff (text/plain), 7.08 KB, created by
Robert Connolly
on 2011-02-26 17:59:04 UTC
(
hide
)
Description:
GMP PIC x86 tests patch
Filename:
MIME Type:
Creator:
Robert Connolly
Created:
2011-02-26 17:59:04 UTC
Size:
7.08 KB
patch
obsolete
>Submitted By: Robert Connolly <robert at linuxfromscratch dot org> >Date: 2011-02-25 >Initial Package Version: 5.0.1 >Upstream Status: From Upstream >Origin: http://gmplib.org:8000/gmp/raw-rev/f6ad7c54bb00 >Description: Allow tests to be compiled with -fPIC/-fPIE on x86. > >http://gmplib.org:8000/gmp/rev/f6ad7c54bb00 > >2010-11-29 Torbjorn Granlund <tege@gmplib.org> > > * tests/x86call.asm: Rewrite for code size and to support PIC. > * tests/x86check.c: Rewrite. > >diff -Naur gmp-5.0.1.orig/tests/x86call.asm gmp-5.0.1/tests/x86call.asm >--- gmp-5.0.1.orig/tests/x86call.asm 2010-02-06 12:43:14.000000000 +0000 >+++ gmp-5.0.1/tests/x86call.asm 2011-02-26 03:42:33.000000000 +0000 >@@ -1,6 +1,6 @@ > dnl x86 calling conventions checking. > >-dnl Copyright 2000, 2003 Free Software Foundation, Inc. >+dnl Copyright 2000, 2003, 2010 Free Software Foundation, Inc. > dnl > dnl This file is part of the GNU MP Library. > dnl >@@ -18,6 +18,9 @@ > dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. > > >+dnl The current version of the code attempts to keep the call/return >+dnl prediction stack valid, but matching calls and returns. >+ > include(`../config.m4') > > >@@ -61,6 +64,29 @@ > C Perhaps the finit should be done only if the tags word isn't clear, but > C nothing uses the rounding mode or anything at the moment. > >+define(`WANT_EBX', eval(4*0)($1)) >+define(`WANT_EBP', eval(4*1)($1)) >+define(`WANT_ESI', eval(4*2)($1)) >+define(`WANT_EDI', eval(4*3)($1)) >+ >+define(`JUNK_EAX', eval(4*4)($1)) >+define(`JUNK_ECX', eval(4*5)($1)) >+define(`JUNK_EDX', eval(4*6)($1)) >+ >+define(`SAVE_EBX', eval(4*7)($1)) >+define(`SAVE_EBP', eval(4*8)($1)) >+define(`SAVE_ESI', eval(4*9)($1)) >+define(`SAVE_EDI', eval(4*10)($1)) >+ >+define(`RETADDR', eval(4*11)($1)) >+ >+define(`EBX', eval(4*12)($1)) >+define(`EBP', eval(4*13)($1)) >+define(`ESI', eval(4*14)($1)) >+define(`EDI', eval(4*15)($1)) >+define(`EFLAGS', eval(4*16)($1)) >+ >+ > define(G, > m4_assert_numargs(1) > `GSYM_PREFIX`'$1') >@@ -68,48 +94,58 @@ > .text > ALIGN(8) > PROLOGUE(calling_conventions) >- movl (%esp), %eax >- movl %eax, G(calling_conventions_retaddr) >+ LEA( G(calling_conventions_values), %ecx) >+ popl RETADDR(%ecx) > >- movl $L(return), (%esp) >- >- movl %ebx, G(calling_conventions_save_ebx) >- movl %esi, G(calling_conventions_save_esi) >- movl %edi, G(calling_conventions_save_edi) >- movl %ebp, G(calling_conventions_save_ebp) >- >- movl $0x01234567, %ebx >- movl $0x89ABCDEF, %esi >- movl $0xFEDCBA98, %edi >- movl $0x76543210, %ebp >- >- C try to provoke a problem by starting with junk in the registers, >- C especially in %eax and %edx which will be return values >- movl $0x70246135, %eax >- movl $0x8ACE9BDF, %ecx >- movl $0xFDB97531, %edx >- >- jmp *G(calling_conventions_function) >- >-L(return): >- movl %ebx, G(calling_conventions_ebx) >- movl %esi, G(calling_conventions_esi) >- movl %edi, G(calling_conventions_edi) >- movl %ebp, G(calling_conventions_ebp) >+ movl %ebx, SAVE_EBX(%ecx) >+ movl %ebp, SAVE_EBP(%ecx) >+ movl %esi, SAVE_ESI(%ecx) >+ movl %edi, SAVE_EDI(%ecx) >+ >+ movl WANT_EBX(%ecx), %ebx >+ movl WANT_EBP(%ecx), %ebp >+ movl WANT_ESI(%ecx), %esi >+ movl WANT_EDI(%ecx), %edi >+ >+ C try to provoke a problem by starting with junk in the caller-saves >+ C registers, especially in %eax and %edx which will be return values >+ movl JUNK_EAX(%ecx), %eax >+ movl JUNK_EDX(%ecx), %edx >+C movl JUNK_ECX(%ecx), %ecx >+ >+ifdef(`PIC',` >+ LEA( G(calling_conventions_function), %ecx) >+ call *(%ecx) >+',` >+ call *G(calling_conventions_function) >+') >+ >+ LEA( G(calling_conventions_values), %ecx) >+ >+ movl %ebx, EBX(%ecx) >+ movl %ebp, EBP(%ecx) >+ movl %esi, ESI(%ecx) >+ movl %edi, EDI(%ecx) > > pushf > popl %ebx >- movl %ebx, G(calling_conventions_eflags) >+ movl %ebx, EFLAGS(%ecx) > >+ movl SAVE_EBX(%ecx), %ebx >+ movl SAVE_ESI(%ecx), %esi >+ movl SAVE_EDI(%ecx), %edi >+ movl SAVE_EBP(%ecx), %ebp >+ >+ pushl RETADDR(%ecx) >+ >+ifdef(`PIC',` >+ LEA( G(calling_conventions_fenv), %ecx) >+ fstenv (%ecx) >+',` > fstenv G(calling_conventions_fenv) >+') > finit > >- movl G(calling_conventions_save_ebx), %ebx >- movl G(calling_conventions_save_esi), %esi >- movl G(calling_conventions_save_edi), %edi >- movl G(calling_conventions_save_ebp), %ebp >- >- jmp *G(calling_conventions_retaddr) >+ ret > > EPILOGUE() >- >diff -Naur gmp-5.0.1.orig/tests/x86check.c gmp-5.0.1/tests/x86check.c >--- gmp-5.0.1.orig/tests/x86check.c 2010-02-06 12:43:14.000000000 +0000 >+++ gmp-5.0.1/tests/x86check.c 2011-02-26 03:42:33.000000000 +0000 >@@ -1,7 +1,7 @@ > /* x86 calling conventions checking. */ > > /* >-Copyright 2000, 2001 Free Software Foundation, Inc. >+Copyright 2000, 2001, 2010 Free Software Foundation, Inc. > > This file is part of the GNU MP Library. > >@@ -24,13 +24,30 @@ > #include "tests.h" > > >-/* temporaries */ >-int calling_conventions_save_ebx; >-int calling_conventions_save_esi; >-int calling_conventions_save_edi; >-int calling_conventions_save_ebp; >-int calling_conventions_retaddr; >-int calling_conventions_retval; >+/* Vector if constants and register values. We use one vector to allow access >+ via a base pointer, very beneficial for the PIC-enabled amd64call.asm. */ >+mp_limb_t calling_conventions_values[17] = >+{ >+ CNST_LIMB(0x12345678), /* want_ebx */ >+ CNST_LIMB(0x89ABCDEF), /* want_ebp */ >+ CNST_LIMB(0xDEADBEEF), /* want_esi */ >+ CNST_LIMB(0xFFEEDDCC), /* want_edi */ >+ >+ CNST_LIMB(0xFEEDABBA), /* JUNK_EAX */ >+ CNST_LIMB(0xAB78DE89), /* JUNK_ECX */ >+ CNST_LIMB(0x12389018) /* JUNK_EDX */ >+ >+ /* rest of array used for dynamic values. */ >+}; >+ >+/* Index starts for various regions in above vector. */ >+#define WANT 0 >+#define JUNK 4 >+#define SAVE 7 >+#define RETADDR 11 >+#define VAL 12 >+#define EFLAGS 16 >+ > > /* values to check */ > struct { >@@ -39,11 +56,6 @@ > unsigned tag; > unsigned other[4]; > } calling_conventions_fenv; >-int calling_conventions_ebx; >-int calling_conventions_esi; >-int calling_conventions_edi; >-int calling_conventions_ebp; >-int calling_conventions_eflags; > > /* expected values, as per x86call.asm */ > #define VALUE_EBX 0x01234567 >@@ -51,6 +63,9 @@ > #define VALUE_EDI 0xFEDCBA98 > #define VALUE_EBP 0x76543210 > >+ >+const char *regname[] = {"ebx", "ebp", "esi", "edi"}; >+ > #define DIR_BIT(eflags) (((eflags) & (1<<10)) != 0) > > >@@ -61,6 +76,7 @@ > { > const char *header = "Violated calling conventions:\n"; > int ret = 1; >+ int i; > > #define CHECK(callreg, regstr, value) \ > if (callreg != value) \ >@@ -71,15 +87,15 @@ > ret = 0; \ > } > >- CHECK (calling_conventions_ebx, "ebx", VALUE_EBX); >- CHECK (calling_conventions_esi, "esi", VALUE_ESI); >- CHECK (calling_conventions_edi, "edi", VALUE_EDI); >- CHECK (calling_conventions_ebp, "ebp", VALUE_EBP); >+ for (i = 0; i < 4; i++) >+ { >+ CHECK (calling_conventions_values[VAL+i], regname[i], calling_conventions_values[WANT+i]); >+ } > >- if (DIR_BIT (calling_conventions_eflags) != 0) >+ if (DIR_BIT (calling_conventions_values[EFLAGS]) != 0) > { > printf ("%s eflags dir bit got %d want 0\n", >- header, DIR_BIT (calling_conventions_eflags)); >+ header, DIR_BIT (calling_conventions_values[EFLAGS])); > header = ""; > ret = 0; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 236054
:
164017
|
240257
| 263955