From e4e0be979e083caef67616b4f87cab3c7efa2730 Mon Sep 17 00:00:00 2001 From: Jonathon Fernyhough Date: Sat, 21 Apr 2018 16:18:00 +0100 Subject: [PATCH] Fix ed25519-amd64-asm PIC compatibility The Hyperledger implementation (https://github.com/hyperledger/iroha-ed25519) contains changes to the assembly code to allow PIC. This in turn fixes compilation/linking of ZeroTier One when "full hardening" flags are used. --- ext/ed25519-amd64-asm/fe25519_mul.s | 8 +- ext/ed25519-amd64-asm/fe25519_square.s | 8 +- ext/ed25519-amd64-asm/ge25519_add_p1p1.s | 72 +++++++++--------- ext/ed25519-amd64-asm/ge25519_dbl_p1p1.s | 32 ++++---- ext/ed25519-amd64-asm/ge25519_nielsadd2.s | 56 +++++++------- ext/ed25519-amd64-asm/ge25519_nielsadd_p1p1.s | 24 +++--- ext/ed25519-amd64-asm/ge25519_p1p1_to_p2.s | 24 +++--- ext/ed25519-amd64-asm/ge25519_p1p1_to_p3.s | 32 ++++---- .../ge25519_pnielsadd_p1p1.s | 32 ++++---- ext/ed25519-amd64-asm/sc25519_add.s | 8 +- ext/ed25519-amd64-asm/sc25519_barrett.s | 74 +++++++++---------- 11 files changed, 185 insertions(+), 185 deletions(-) diff --git a/ext/ed25519-amd64-asm/fe25519_mul.s b/ext/ed25519-amd64-asm/fe25519_mul.s index 7e24518d3..147842811 100644 --- a/ext/ed25519-amd64-asm/fe25519_mul.s +++ b/ext/ed25519-amd64-asm/fe25519_mul.s @@ -652,7 +652,7 @@ adc %rdx,%r11 mov %r8,%rax # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: mulr4 = mulrax # asm 1: mov mulr4=int64#2 @@ -670,7 +670,7 @@ mov %r9,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add squarer4=int64#2 @@ -444,7 +444,7 @@ mov %r12,%rax mov %rdx,%r11 # qhasm: (uint128) squarerdx squarerax = squarerax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? squarer5 += squarerax # asm 1: add mulr4=int64#5 @@ -1226,7 +1226,7 @@ mov %r9,%rax mov %rdx,%r9 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#5 @@ -1908,7 +1908,7 @@ mov %r9,%rax mov %rdx,%r9 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#5 @@ -2760,7 +2760,7 @@ mov %r9,%rax mov %rdx,%r9 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D0,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D0,%rax +movq crypto_sign_ed25519_amd64_64_EC2D0(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx0 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D1,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D1,%rax +movq crypto_sign_ed25519_amd64_64_EC2D1(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx0 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D2,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D2,%rax +movq crypto_sign_ed25519_amd64_64_EC2D2(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx0 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D3,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D3,%rax +movq crypto_sign_ed25519_amd64_64_EC2D3(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx0 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D0,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D0,%rax +movq crypto_sign_ed25519_amd64_64_EC2D0(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx1 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D1,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D1,%rax +movq crypto_sign_ed25519_amd64_64_EC2D1(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx1 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D2,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D2,%rax +movq crypto_sign_ed25519_amd64_64_EC2D2(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx1 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D3,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D3,%rax +movq crypto_sign_ed25519_amd64_64_EC2D3(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx1 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D0,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D0,%rax +movq crypto_sign_ed25519_amd64_64_EC2D0(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx2 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D1,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D1,%rax +movq crypto_sign_ed25519_amd64_64_EC2D1(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx2 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D2,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D2,%rax +movq crypto_sign_ed25519_amd64_64_EC2D2(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx2 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D3,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D3,%rax +movq crypto_sign_ed25519_amd64_64_EC2D3(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx2 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D0,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D0,%rax +movq crypto_sign_ed25519_amd64_64_EC2D0(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx3 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D1,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D1,%rax +movq crypto_sign_ed25519_amd64_64_EC2D1(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx3 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D2,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D2,%rax +movq crypto_sign_ed25519_amd64_64_EC2D2(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx3 # asm 1: mul mulrax=int64#7 # asm 2: movq crypto_sign_ed25519_amd64_64_EC2D3,>mulrax=%rax -movq crypto_sign_ed25519_amd64_64_EC2D3,%rax +movq crypto_sign_ed25519_amd64_64_EC2D3(%rip),%rax # qhasm: (uint128) mulrdx mulrax = mulrax * mulx3 # asm 1: mul mulr4=int64#5 @@ -3442,7 +3442,7 @@ mov %r9,%rax mov %rdx,%r9 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#2 @@ -4124,7 +4124,7 @@ mov %r9,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add squarer4=int64#9 @@ -594,7 +594,7 @@ mov %r12,%rax mov %rdx,%r12 # qhasm: (uint128) squarerdx squarerax = squarerax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? squarer5 += squarerax # asm 1: add squarer4=int64#9 @@ -1061,7 +1061,7 @@ mov %r12,%rax mov %rdx,%r12 # qhasm: (uint128) squarerdx squarerax = squarerax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? squarer5 += squarerax # asm 1: add squarer4=int64#9 @@ -1528,7 +1528,7 @@ mov %r12,%rax mov %rdx,%r12 # qhasm: (uint128) squarerdx squarerax = squarerax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? squarer5 += squarerax # asm 1: add squarer4=int64#8 @@ -2650,7 +2650,7 @@ mov %r11,%rax mov %rdx,%r11 # qhasm: (uint128) squarerdx squarerax = squarerax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? squarer5 += squarerax # asm 1: add mulr4=int64#4 @@ -1079,7 +1079,7 @@ mov %r8,%rax mov %rdx,%r8 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#4 @@ -1761,7 +1761,7 @@ mov %r8,%rax mov %rdx,%r8 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#2 @@ -2613,7 +2613,7 @@ mov %r8,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#2 @@ -3550,7 +3550,7 @@ mov %rcx,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#2 @@ -4232,7 +4232,7 @@ mov %rcx,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#2 @@ -4914,7 +4914,7 @@ mov %rcx,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#2 @@ -5596,7 +5596,7 @@ mov %rcx,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#5 @@ -1088,7 +1088,7 @@ mov %r9,%rax mov %rdx,%r9 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#5 @@ -1770,7 +1770,7 @@ mov %r9,%rax mov %rdx,%r9 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#4 @@ -2622,7 +2622,7 @@ mov %r9,%rax mov %rdx,%r8 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#4 @@ -677,7 +677,7 @@ mov %r8,%rax mov %rdx,%r8 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#4 @@ -1359,7 +1359,7 @@ mov %r8,%rax mov %rdx,%r8 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#2 @@ -2041,7 +2041,7 @@ mov %r8,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#4 @@ -685,7 +685,7 @@ mov %r8,%rax mov %rdx,%r8 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#4 @@ -1367,7 +1367,7 @@ mov %r8,%rax mov %rdx,%r8 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#4 @@ -2049,7 +2049,7 @@ mov %r8,%rax mov %rdx,%r8 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#2 @@ -2731,7 +2731,7 @@ mov %r8,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#5 @@ -1016,7 +1016,7 @@ mov %r9,%rax mov %rdx,%r9 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#5 @@ -1698,7 +1698,7 @@ mov %r9,%rax mov %rdx,%r9 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#5 @@ -2550,7 +2550,7 @@ mov %r9,%rax mov %rdx,%r9 # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add mulr4=int64#2 @@ -3232,7 +3232,7 @@ mov %r9,%rax mov %rdx,%rcx # qhasm: (uint128) mulrdx mulrax = mulrax * *(uint64 *)&crypto_sign_ed25519_amd64_64_38 -mulq crypto_sign_ed25519_amd64_64_38 +mulq crypto_sign_ed25519_amd64_64_38(%rip) # qhasm: carry? mulr5 += mulrax # asm 1: add q23=int64#10 @@ -203,7 +203,7 @@ mov %rdx,%r13 movq 24(%rsi),%rax # qhasm: (uint128) rdx rax = rax * *(uint64 *) &crypto_sign_ed25519_amd64_64_MU4 -mulq crypto_sign_ed25519_amd64_64_MU4 +mulq crypto_sign_ed25519_amd64_64_MU4(%rip) # qhasm: q24 = rax # asm 1: mov q24=int64#12 @@ -226,7 +226,7 @@ adc %rdx,%r8 movq 32(%rsi),%rax # qhasm: (uint128) rdx rax = rax * *(uint64 *) &crypto_sign_ed25519_amd64_64_MU2 -mulq crypto_sign_ed25519_amd64_64_MU2 +mulq crypto_sign_ed25519_amd64_64_MU2(%rip) # qhasm: carry? q23 += rax # asm 1: add r20=int64#5 @@ -762,7 +762,7 @@ mov %rdx,%r9 movq 56(%rsp),%rax # qhasm: (uint128) rdx rax = rax * *(uint64 *) &crypto_sign_ed25519_amd64_64_ORDER1 -mulq crypto_sign_ed25519_amd64_64_ORDER1 +mulq crypto_sign_ed25519_amd64_64_ORDER1(%rip) # qhasm: r21 = rax # asm 1: mov r21=int64#8 @@ -790,7 +790,7 @@ adc %rdx,%r9 movq 56(%rsp),%rax # qhasm: (uint128) rdx rax = rax * *(uint64 *) &crypto_sign_ed25519_amd64_64_ORDER2 -mulq crypto_sign_ed25519_amd64_64_ORDER2 +mulq crypto_sign_ed25519_amd64_64_ORDER2(%rip) # qhasm: r22 = rax # asm 1: mov r22=int64#9 @@ -818,7 +818,7 @@ adc %rdx,%r9 movq 56(%rsp),%rax # qhasm: (uint128) rdx rax = rax * *(uint64 *) &crypto_sign_ed25519_amd64_64_ORDER3 -mulq crypto_sign_ed25519_amd64_64_ORDER3 +mulq crypto_sign_ed25519_amd64_64_ORDER3(%rip) # qhasm: free rdx @@ -838,7 +838,7 @@ add %r9,%r12 movq 64(%rsp),%rax # qhasm: (uint128) rdx rax = rax * *(uint64 *) &crypto_sign_ed25519_amd64_64_ORDER0 -mulq crypto_sign_ed25519_amd64_64_ORDER0 +mulq crypto_sign_ed25519_amd64_64_ORDER0(%rip) # qhasm: carry? r21 += rax # asm 1: add