2010-11-10 Francisco Blas Izquierdo Riera #285703 * src/sha1-sse2.S: Add support for x86 and AMD64 This patch is licensed uder the same LICENSE as aircrack-ng diff -ru aircrack-ng-1.1.old/src/sha1-sse2.S aircrack-ng-1.1/src/sha1-sse2.S --- aircrack-ng-1.1.old/src/sha1-sse2.S 2010-01-22 02:01:28.000000000 +0100 +++ aircrack-ng-1.1/src/sha1-sse2.S 2011-02-26 06:22:37.061208191 +0100 @@ -8,9 +8,36 @@ // input blocks must be (four bytes) interleaved. #if defined(__x86_64__) && defined(__APPLE__) +#define PRELOAD(x) #define MANGLE(x) x(%rip) +#define INIT_PIC() +#define END_PIC() #else +#ifdef __PIC__ + +#ifdef __x86_64__ +#define PRELOAD(x) movq x@GOTPCREL(%rip), %rbx; +#define MANGLE(x) (%rbx) +#define INIT_PIC() pushq %rbx +#define END_PIC() popq %rbx +#else +#undef __i686 /* gcc builtin define gets in our way */ +#define PRELOAD(x) +#define MANGLE(x) x ## @GOTOFF(%ebx) +#define INIT_PIC() \ + call __i686.get_pc_thunk.bx ; \ + addl $_GLOBAL_OFFSET_TABLE_, %ebx +#define END_PIC() +#endif + +#else + +#define PRELOAD(x) #define MANGLE(x) x +#define INIT_PIC() +#define END_PIC() + +#endif #endif #if defined(__i386__) || defined(__x86_64__) @@ -142,12 +169,15 @@ paddd tmp2, e; \ movdqa b, tmp2; \ pslld $30, b; \ + PRELOAD(k) \ paddd MANGLE(k), e; \ psrld $2, tmp2; \ por tmp2, b; \ movdqa (data*16)(edx_rsi), tmp1; \ movdqa tmp1, tmp2; \ + PRELOAD(const_ff00) \ pand MANGLE(const_ff00), tmp1; \ + PRELOAD(const_00ff) \ pand MANGLE(const_00ff), tmp2; \ psrld $8, tmp1; \ pslld $8, tmp2; \ @@ -181,6 +211,7 @@ paddd tmp2, e; \ movdqa b, tmp2; \ pslld $30, b; \ + PRELOAD(k) \ paddd MANGLE(k), e; \ psrld $2, tmp2; \ por tmp2, b; @@ -192,10 +223,16 @@ shasse2_init: _shasse2_init: + INIT_PIC() + PRELOAD(const_init_a) movdqa MANGLE(const_init_a), ctxa + PRELOAD(const_init_b) movdqa MANGLE(const_init_b), ctxb + PRELOAD(const_init_c) movdqa MANGLE(const_init_c), ctxc + PRELOAD(const_init_d) movdqa MANGLE(const_init_d), ctxd + PRELOAD(const_init_e) movdqa MANGLE(const_init_e), ctxe movdqa ctxa, 0(eax_rdi) @@ -203,6 +240,7 @@ movdqa ctxc, 32(eax_rdi) movdqa ctxd, 48(eax_rdi) movdqa ctxe, 64(eax_rdi) + END_PIC() ret @@ -212,17 +250,20 @@ shasse2_ends: _shasse2_ends: - movdqa 0(eax_rdi), ctxa + INIT_PIC() + movdqa 0(eax_rdi), ctxa movdqa 16(eax_rdi), ctxb movdqa 32(eax_rdi), ctxc movdqa 48(eax_rdi), ctxd movdqa 64(eax_rdi), ctxe + PRELOAD(const_ff00) movdqa MANGLE(const_ff00), tmp3 movdqa ctxa, tmp1 movdqa ctxb, tmp2 pand tmp3, ctxa pand tmp3, ctxb + PRELOAD(const_00ff) movdqa MANGLE(const_00ff), tmp3 pand tmp3, tmp1 pand tmp3, tmp2 @@ -243,6 +284,7 @@ movdqa ctxa, 0(edx_rsi) movdqa ctxb, 16(edx_rsi) + PRELOAD(const_ff00) movdqa MANGLE(const_ff00), tmp5 movdqa ctxc, tmp1 movdqa ctxd, tmp2 @@ -250,6 +292,7 @@ pand tmp5, ctxc pand tmp5, ctxd pand tmp5, ctxe + PRELOAD(const_00ff) movdqa MANGLE(const_00ff), tmp5 pand tmp5, tmp1 pand tmp5, tmp2 @@ -279,6 +322,7 @@ movdqa ctxc, 32(edx_rsi) movdqa ctxd, 48(edx_rsi) movdqa ctxe, 64(edx_rsi) + END_PIC() ret @@ -289,6 +333,7 @@ shasse2_data: _shasse2_data: + INIT_PIC() movdqa 0(eax_rdi), ctxa movdqa 16(eax_rdi), ctxb movdqa 32(eax_rdi), ctxc @@ -400,6 +445,7 @@ movdqa ctxc, 32(eax_rdi) movdqa ctxd, 48(eax_rdi) movdqa ctxe, 64(eax_rdi) + END_PIC() ret @@ -462,6 +508,17 @@ pop %ebx #endif ret +#ifdef __i386__ +#ifdef __PIC__ + .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits +.globl __i686.get_pc_thunk.bx + .hidden __i686.get_pc_thunk.bx + .type __i686.get_pc_thunk.bx,@function +__i686.get_pc_thunk.bx: + movl (%esp), %ebx + ret +#endif +#endif #endif