diff --git a/mpi/i386/mpih-add1.S b/mpi/i386/mpih-add1.S index 652b2321..32091f34 100644 --- a/mpi/i386/mpih-add1.S +++ b/mpi/i386/mpih-add1.S @@ -1,116 +1,122 @@ /* i80386 add_n -- Add two limb vectors of the same length > 0 and store * sum in a third limb vector. * * Copyright (C) 1992, 1994, 1995, 1998, * 2001, 2002 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * * Libgcrypt is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Libgcrypt is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * Note: This code is heavily based on the GNU MP Library. * Actually it's the same code with only minor changes in the * way the data is stored; this is to support the abstraction * of an optional secure memory allocation which may be used * to avoid revealing of sensitive data due to paging etc. */ #include "sysdep.h" #include "asm-syntax.h" /******************* * mpi_limb_t * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_ptr_t s2_ptr, (sp + 12) * mpi_size_t size) (sp + 16) */ .text ALIGN (3) .globl C_SYMBOL_NAME(_gcry_mpih_add_n) C_SYMBOL_NAME(_gcry_mpih_add_n:) + CFI_STARTPROC() pushl %edi + CFI_PUSH(%edi) pushl %esi + CFI_PUSH(%esi) movl 12(%esp),%edi /* res_ptr */ movl 16(%esp),%esi /* s1_ptr */ movl 20(%esp),%edx /* s2_ptr */ movl 24(%esp),%ecx /* size */ movl %ecx,%eax shrl $3,%ecx /* compute count for unrolled loop */ negl %eax andl $7,%eax /* get index where to start loop */ jz Loop /* necessary special case for 0 */ incl %ecx /* adjust loop count */ shll $2,%eax /* adjustment for pointers... */ subl %eax,%edi /* ... since they are offset ... */ subl %eax,%esi /* ... by a constant when we ... */ subl %eax,%edx /* ... enter the loop */ shrl $2,%eax /* restore previous value */ #ifdef PIC /* Calculate start address in loop for PIC. Due to limitations in some assemblers, Loop-L0-3 cannot be put into the leal */ call L0 L0: leal (%eax,%eax,8),%eax addl (%esp),%eax addl $(Loop-L0-3),%eax addl $4,%esp #else /* Calculate start address in loop for non-PIC. */ leal (Loop - 3)(%eax,%eax,8),%eax #endif jmp *%eax /* jump into loop */ ALIGN (3) Loop: movl (%esi),%eax adcl (%edx),%eax movl %eax,(%edi) movl 4(%esi),%eax adcl 4(%edx),%eax movl %eax,4(%edi) movl 8(%esi),%eax adcl 8(%edx),%eax movl %eax,8(%edi) movl 12(%esi),%eax adcl 12(%edx),%eax movl %eax,12(%edi) movl 16(%esi),%eax adcl 16(%edx),%eax movl %eax,16(%edi) movl 20(%esi),%eax adcl 20(%edx),%eax movl %eax,20(%edi) movl 24(%esi),%eax adcl 24(%edx),%eax movl %eax,24(%edi) movl 28(%esi),%eax adcl 28(%edx),%eax movl %eax,28(%edi) leal 32(%edi),%edi leal 32(%esi),%esi leal 32(%edx),%edx decl %ecx jnz Loop sbbl %eax,%eax negl %eax popl %esi + CFI_POP(%esi) popl %edi + CFI_POP(%edi) ret + CFI_ENDPROC() diff --git a/mpi/i386/mpih-lshift.S b/mpi/i386/mpih-lshift.S index bf8ed9d4..55da0678 100644 --- a/mpi/i386/mpih-lshift.S +++ b/mpi/i386/mpih-lshift.S @@ -1,94 +1,102 @@ /* i80386 lshift * Copyright (C) 1992, 1994, 1998, * 2001, 2002 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * * Libgcrypt is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Libgcrypt is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * Note: This code is heavily based on the GNU MP Library. * Actually it's the same code with only minor changes in the * way the data is stored; this is to support the abstraction * of an optional secure memory allocation which may be used * to avoid revealing of sensitive data due to paging etc. */ #include "sysdep.h" #include "asm-syntax.h" /******************* * mpi_limb_t * _gcry_mpih_lshift( mpi_ptr_t wp, (sp + 4) * mpi_ptr_t up, (sp + 8) * mpi_size_t usize, (sp + 12) * unsigned cnt) (sp + 16) */ .text ALIGN (3) .globl C_SYMBOL_NAME(_gcry_mpih_lshift) C_SYMBOL_NAME(_gcry_mpih_lshift:) + CFI_STARTPROC() pushl %edi + CFI_PUSH(%edi) pushl %esi + CFI_PUSH(%esi) pushl %ebx + CFI_PUSH(%ebx) movl 16(%esp),%edi /* res_ptr */ movl 20(%esp),%esi /* s_ptr */ movl 24(%esp),%edx /* size */ movl 28(%esp),%ecx /* cnt */ subl $4,%esi /* adjust s_ptr */ movl (%esi,%edx,4),%ebx /* read most significant limb */ xorl %eax,%eax shldl %cl,%ebx,%eax /* compute carry limb */ decl %edx jz Lend pushl %eax /* push carry limb onto stack */ testb $1,%dl jnz L1 /* enter loop in the middle */ movl %ebx,%eax ALIGN (3) Loop: movl (%esi,%edx,4),%ebx /* load next lower limb */ shldl %cl,%ebx,%eax /* compute result limb */ movl %eax,(%edi,%edx,4) /* store it */ decl %edx L1: movl (%esi,%edx,4),%eax shldl %cl,%eax,%ebx movl %ebx,(%edi,%edx,4) decl %edx jnz Loop shll %cl,%eax /* compute least significant limb */ movl %eax,(%edi) /* store it */ popl %eax /* pop carry limb */ popl %ebx popl %esi popl %edi ret Lend: shll %cl,%ebx /* compute least significant limb */ movl %ebx,(%edi) /* store it */ popl %ebx + CFI_POP(%ebx) popl %esi + CFI_POP(%esi) popl %edi + CFI_POP(%edi) ret + CFI_ENDPROC() diff --git a/mpi/i386/mpih-mul1.S b/mpi/i386/mpih-mul1.S index c9760ef9..9679ea62 100644 --- a/mpi/i386/mpih-mul1.S +++ b/mpi/i386/mpih-mul1.S @@ -1,84 +1,94 @@ /* i80386 mul_1 -- Multiply a limb vector with a limb and store * the result in a second limb vector. * Copyright (C) 1992, 1994, 1998, * 2001, 2002 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * * Libgcrypt is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Libgcrypt is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * Note: This code is heavily based on the GNU MP Library. * Actually it's the same code with only minor changes in the * way the data is stored; this is to support the abstraction * of an optional secure memory allocation which may be used * to avoid revealing of sensitive data due to paging etc. */ #include "sysdep.h" #include "asm-syntax.h" /******************* * mpi_limb_t * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) */ #define res_ptr edi #define s1_ptr esi #define size ecx #define s2_limb ebp TEXT ALIGN (3) GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1) C_SYMBOL_NAME(_gcry_mpih_mul_1:) + CFI_STARTPROC() INSN1(push,l ,R(edi)) + CFI_PUSH(%edi) INSN1(push,l ,R(esi)) + CFI_PUSH(%esi) INSN1(push,l ,R(ebx)) + CFI_PUSH(%ebx) INSN1(push,l ,R(ebp)) + CFI_PUSH(%ebp) INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) INSN2(mov,l ,R(size),MEM_DISP(esp,28)) INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) INSN1(neg,l ,R(size)) INSN2(xor,l ,R(ebx),R(ebx)) ALIGN (3) Loop: INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4)) INSN1(mul,l ,R(s2_limb)) INSN2(add,l ,R(eax),R(ebx)) INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(eax)) INSN2(adc,l ,R(edx),$0) INSN2(mov,l ,R(ebx),R(edx)) INSN1(inc,l ,R(size)) INSN1(jnz, ,Loop) INSN2(mov,l ,R(eax),R(ebx)) INSN1(pop,l ,R(ebp)) + CFI_POP(%ebp) INSN1(pop,l ,R(ebx)) + CFI_POP(%ebx) INSN1(pop,l ,R(esi)) + CFI_POP(%esi) INSN1(pop,l ,R(edi)) + CFI_POP(%edi) ret + CFI_ENDPROC() diff --git a/mpi/i386/mpih-mul2.S b/mpi/i386/mpih-mul2.S index 9794e110..fe4129c4 100644 --- a/mpi/i386/mpih-mul2.S +++ b/mpi/i386/mpih-mul2.S @@ -1,86 +1,96 @@ /* i80386 addmul_1 -- Multiply a limb vector with a limb and add * the result to a second limb vector. * * Copyright (C) 1992, 1994, 1998, * 2001, 2002 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * * Libgcrypt is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Libgcrypt is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * Note: This code is heavily based on the GNU MP Library. * Actually it's the same code with only minor changes in the * way the data is stored; this is to support the abstraction * of an optional secure memory allocation which may be used * to avoid revealing of sensitive data due to paging etc. */ #include "sysdep.h" #include "asm-syntax.h" /******************* * mpi_limb_t * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) */ #define res_ptr edi #define s1_ptr esi #define size ecx #define s2_limb ebp TEXT ALIGN (3) GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1) C_SYMBOL_NAME(_gcry_mpih_addmul_1:) + CFI_STARTPROC() INSN1(push,l ,R(edi)) + CFI_PUSH(%edi) INSN1(push,l ,R(esi)) + CFI_PUSH(%esi) INSN1(push,l ,R(ebx)) + CFI_PUSH(%ebx) INSN1(push,l ,R(ebp)) + CFI_PUSH(%ebp) INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) INSN2(mov,l ,R(size),MEM_DISP(esp,28)) INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) INSN1(neg,l ,R(size)) INSN2(xor,l ,R(ebx),R(ebx)) ALIGN (3) Loop: INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4)) INSN1(mul,l ,R(s2_limb)) INSN2(add,l ,R(eax),R(ebx)) INSN2(adc,l ,R(edx),$0) INSN2(add,l ,MEM_INDEX(res_ptr,size,4),R(eax)) INSN2(adc,l ,R(edx),$0) INSN2(mov,l ,R(ebx),R(edx)) INSN1(inc,l ,R(size)) INSN1(jnz, ,Loop) INSN2(mov,l ,R(eax),R(ebx)) INSN1(pop,l ,R(ebp)) + CFI_POP(%ebp) INSN1(pop,l ,R(ebx)) + CFI_POP(%ebx) INSN1(pop,l ,R(esi)) + CFI_POP(%esi) INSN1(pop,l ,R(edi)) + CFI_POP(%edi) ret + CFI_ENDPROC() diff --git a/mpi/i386/mpih-mul3.S b/mpi/i386/mpih-mul3.S index 6df20176..87577d54 100644 --- a/mpi/i386/mpih-mul3.S +++ b/mpi/i386/mpih-mul3.S @@ -1,86 +1,96 @@ /* i80386 submul_1 -- Multiply a limb vector with a limb and add * the result to a second limb vector. * * Copyright (C) 1992, 1994, 1998, * 2001, 2002 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * * Libgcrypt is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Libgcrypt is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * Note: This code is heavily based on the GNU MP Library. * Actually it's the same code with only minor changes in the * way the data is stored; this is to support the abstraction * of an optional secure memory allocation which may be used * to avoid revealing of sensitive data due to paging etc. */ #include "sysdep.h" #include "asm-syntax.h" /******************* * mpi_limb_t * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) */ #define res_ptr edi #define s1_ptr esi #define size ecx #define s2_limb ebp TEXT ALIGN (3) GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1) C_SYMBOL_NAME(_gcry_mpih_submul_1:) + CFI_STARTPROC() INSN1(push,l ,R(edi)) + CFI_PUSH(%edi) INSN1(push,l ,R(esi)) + CFI_PUSH(%esi) INSN1(push,l ,R(ebx)) + CFI_PUSH(%ebx) INSN1(push,l ,R(ebp)) + CFI_PUSH(%ebp) INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) INSN2(mov,l ,R(size),MEM_DISP(esp,28)) INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) INSN1(neg,l ,R(size)) INSN2(xor,l ,R(ebx),R(ebx)) ALIGN (3) Loop: INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4)) INSN1(mul,l ,R(s2_limb)) INSN2(add,l ,R(eax),R(ebx)) INSN2(adc,l ,R(edx),$0) INSN2(sub,l ,MEM_INDEX(res_ptr,size,4),R(eax)) INSN2(adc,l ,R(edx),$0) INSN2(mov,l ,R(ebx),R(edx)) INSN1(inc,l ,R(size)) INSN1(jnz, ,Loop) INSN2(mov,l ,R(eax),R(ebx)) INSN1(pop,l ,R(ebp)) + CFI_POP(%ebp) INSN1(pop,l ,R(ebx)) + CFI_POP(%ebx) INSN1(pop,l ,R(esi)) + CFI_POP(%esi) INSN1(pop,l ,R(edi)) + CFI_POP(%edi) ret + CFI_ENDPROC() diff --git a/mpi/i386/mpih-rshift.S b/mpi/i386/mpih-rshift.S index 2920e55d..35a8201f 100644 --- a/mpi/i386/mpih-rshift.S +++ b/mpi/i386/mpih-rshift.S @@ -1,97 +1,105 @@ /* i80386 rshift * * Copyright (C) 1992, 1994, 1998, * 2001, 2002 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * * Libgcrypt is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Libgcrypt is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * Note: This code is heavily based on the GNU MP Library. * Actually it's the same code with only minor changes in the * way the data is stored; this is to support the abstraction * of an optional secure memory allocation which may be used * to avoid revealing of sensitive data due to paging etc. */ #include "sysdep.h" #include "asm-syntax.h" /******************* * mpi_limb_t * _gcry_mpih_rshift( mpi_ptr_t wp, (sp + 4) * mpi_ptr_t up, (sp + 8) * mpi_size_t usize, (sp + 12) * unsigned cnt) (sp + 16) */ .text ALIGN (3) .globl C_SYMBOL_NAME(_gcry_mpih_rshift) C_SYMBOL_NAME(_gcry_mpih_rshift:) + CFI_STARTPROC() pushl %edi + CFI_PUSH(%edi) pushl %esi + CFI_PUSH(%esi) pushl %ebx + CFI_PUSH(%ebx) movl 16(%esp),%edi /* wp */ movl 20(%esp),%esi /* up */ movl 24(%esp),%edx /* usize */ movl 28(%esp),%ecx /* cnt */ leal -4(%edi,%edx,4),%edi leal (%esi,%edx,4),%esi negl %edx movl (%esi,%edx,4),%ebx /* read least significant limb */ xorl %eax,%eax shrdl %cl,%ebx,%eax /* compute carry limb */ incl %edx jz Lend2 pushl %eax /* push carry limb onto stack */ testb $1,%dl jnz L2 /* enter loop in the middle */ movl %ebx,%eax ALIGN (3) -Loop2: movl (%esi,%edx,4),%ebx /* load next higher limb */ +Loop2: movl (%esi,%edx,4),%ebx /* load next higher limb */ shrdl %cl,%ebx,%eax /* compute result limb */ movl %eax,(%edi,%edx,4) /* store it */ incl %edx L2: movl (%esi,%edx,4),%eax shrdl %cl,%eax,%ebx movl %ebx,(%edi,%edx,4) incl %edx jnz Loop2 shrl %cl,%eax /* compute most significant limb */ movl %eax,(%edi) /* store it */ popl %eax /* pop carry limb */ popl %ebx popl %esi popl %edi ret Lend2: shrl %cl,%ebx /* compute most significant limb */ movl %ebx,(%edi) /* store it */ popl %ebx + CFI_POP(%ebx) popl %esi + CFI_POP(%esi) popl %edi + CFI_POP(%edi) ret + CFI_ENDPROC() diff --git a/mpi/i386/mpih-sub1.S b/mpi/i386/mpih-sub1.S index f447f7a6..501c4a9f 100644 --- a/mpi/i386/mpih-sub1.S +++ b/mpi/i386/mpih-sub1.S @@ -1,117 +1,123 @@ /* i80386 sub_n -- Sub two limb vectors of the same length > 0 and store * sum in a third limb vector. * * Copyright (C) 1992, 1994, 1995, 1998, * 2001, 2002 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * * Libgcrypt is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Libgcrypt is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * Note: This code is heavily based on the GNU MP Library. * Actually it's the same code with only minor changes in the * way the data is stored; this is to support the abstraction * of an optional secure memory allocation which may be used * to avoid revealing of sensitive data due to paging etc. */ #include "sysdep.h" #include "asm-syntax.h" /******************* * mpi_limb_t * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_ptr_t s2_ptr, (sp + 12) * mpi_size_t size) (sp + 16) */ .text ALIGN (3) .globl C_SYMBOL_NAME(_gcry_mpih_sub_n) C_SYMBOL_NAME(_gcry_mpih_sub_n:) + CFI_STARTPROC() pushl %edi + CFI_PUSH(%edi) pushl %esi + CFI_PUSH(%esi) movl 12(%esp),%edi /* res_ptr */ movl 16(%esp),%esi /* s1_ptr */ movl 20(%esp),%edx /* s2_ptr */ movl 24(%esp),%ecx /* size */ movl %ecx,%eax shrl $3,%ecx /* compute count for unrolled loop */ negl %eax andl $7,%eax /* get index where to start loop */ jz Loop /* necessary special case for 0 */ incl %ecx /* adjust loop count */ shll $2,%eax /* adjustment for pointers... */ subl %eax,%edi /* ... since they are offset ... */ subl %eax,%esi /* ... by a constant when we ... */ subl %eax,%edx /* ... enter the loop */ shrl $2,%eax /* restore previous value */ #ifdef PIC /* Calculate start address in loop for PIC. Due to limitations in some assemblers, Loop-L0-3 cannot be put into the leal */ call L0 L0: leal (%eax,%eax,8),%eax addl (%esp),%eax addl $(Loop-L0-3),%eax addl $4,%esp #else /* Calculate start address in loop for non-PIC. */ leal (Loop - 3)(%eax,%eax,8),%eax #endif jmp *%eax /* jump into loop */ ALIGN (3) Loop: movl (%esi),%eax sbbl (%edx),%eax movl %eax,(%edi) movl 4(%esi),%eax sbbl 4(%edx),%eax movl %eax,4(%edi) movl 8(%esi),%eax sbbl 8(%edx),%eax movl %eax,8(%edi) movl 12(%esi),%eax sbbl 12(%edx),%eax movl %eax,12(%edi) movl 16(%esi),%eax sbbl 16(%edx),%eax movl %eax,16(%edi) movl 20(%esi),%eax sbbl 20(%edx),%eax movl %eax,20(%edi) movl 24(%esi),%eax sbbl 24(%edx),%eax movl %eax,24(%edi) movl 28(%esi),%eax sbbl 28(%edx),%eax movl %eax,28(%edi) leal 32(%edi),%edi leal 32(%esi),%esi leal 32(%edx),%edx decl %ecx jnz Loop sbbl %eax,%eax negl %eax popl %esi + CFI_POP(%esi) popl %edi + CFI_POP(%edi) ret + CFI_ENDPROC() diff --git a/mpi/i386/syntax.h b/mpi/i386/syntax.h index 39ede988..9101585a 100644 --- a/mpi/i386/syntax.h +++ b/mpi/i386/syntax.h @@ -1,68 +1,92 @@ /* syntax.h -- Definitions for x86 syntax variations. * * Copyright (C) 1992, 1994, 1995, 1998, * 2001, 2002 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * * Libgcrypt is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Libgcrypt is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * Note: This code is heavily based on the GNU MP Library. * Actually it's the same code with only minor changes in the * way the data is stored; this is to support the abstraction * of an optional secure memory allocation which may be used * to avoid revealing of sensitive data due to paging etc. */ +#include + +#ifdef HAVE_GCC_ASM_CFI_DIRECTIVES +# define CFI_STARTPROC() .cfi_startproc +# define CFI_ENDPROC() .cfi_endproc +# define CFI_ADJUST_CFA_OFFSET(off) .cfi_adjust_cfa_offset off +# define CFI_REL_OFFSET(reg,off) .cfi_rel_offset reg, off +# define CFI_RESTORE(reg) .cfi_restore reg + +# define CFI_PUSH(reg) \ + CFI_ADJUST_CFA_OFFSET(4); CFI_REL_OFFSET(reg, 0) +# define CFI_POP(reg) \ + CFI_ADJUST_CFA_OFFSET(-4); CFI_RESTORE(reg) +#else +# define CFI_STARTPROC() +# define CFI_ENDPROC() +# define CFI_ADJUST_CFA_OFFSET(off) +# define CFI_REL_OFFSET(reg,off) +# define CFI_RESTORE(reg) + +# define CFI_PUSH(reg) +# define CFI_POP(reg) +#endif + #undef ALIGN #if defined (BSD_SYNTAX) || defined (ELF_SYNTAX) #define R(r) %r #define MEM(base)(base) #define MEM_DISP(base,displacement)displacement(R(base)) #define MEM_INDEX(base,index,size)(R(base),R(index),size) #ifdef __STDC__ #define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst #define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst #else #define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst #define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst #endif #define TEXT .text #if defined (BSD_SYNTAX) #define ALIGN(log) .align log #endif #if defined (ELF_SYNTAX) #define ALIGN(log) .align 1<<(log) #endif #define GLOBL .globl #endif #ifdef INTEL_SYNTAX #define R(r) r #define MEM(base)[base] #define MEM_DISP(base,displacement)[base+(displacement)] #define MEM_INDEX(base,index,size)[base+index*size] #define INSN1(mnemonic,size_suffix,dst)mnemonic dst #define INSN2(mnemonic,size_suffix,dst,src)mnemonic dst,src #define TEXT .text #define ALIGN(log) .align log #define GLOBL .globl #endif #ifdef X86_BROKEN_ALIGN #undef ALIGN #define ALIGN(log) .align log,0x90 #endif