$OpenBSD: patch-common_x86_cabac-a_asm,v 1.1 2018/09/16 06:37:15 ajacoutot Exp $

x86: Always use PIC in x86-64 asm

Index: common/x86/cabac-a.asm
--- common/x86/cabac-a.asm.orig
+++ common/x86/cabac-a.asm
@@ -36,11 +36,7 @@ SECTION_RODATA 64
     %xdefine %%funccpu2 %3 ; last64
     %xdefine %%funccpu3 %4 ; last15/last16
     coeff_last_%1:
-    %ifdef PIC
-        %xdefine %%base coeff_last_%1 ; offset relative to the start of the table
-    %else
-        %xdefine %%base 0             ; absolute address
-    %endif
+    %xdefine %%base coeff_last_%1
     %rep 14
         %ifidn %5, 4
             dd mangle(private_prefix %+ _coeff_last%5_ %+ %%funccpu1) - %%base
@@ -121,15 +117,13 @@ struc cb
 endstruc
 
 %macro LOAD_GLOBAL 3-5 0 ; dst, base, off1, off2, tmp
-%ifdef PIC
-    %ifidn %4, 0
-        movzx %1, byte [%2+%3+r7-$$]
-    %else
-        lea   %5, [r7+%4]
-        movzx %1, byte [%2+%3+%5-$$]
-    %endif
-%else
+%if ARCH_X86_64 == 0
     movzx %1, byte [%2+%3+%4]
+%elifidn %4, 0
+    movzx %1, byte [%2+%3+r7-$$]
+%else
+    lea   %5, [r7+%4]
+    movzx %1, byte [%2+%3+%5-$$]
 %endif
 %endmacro
 
@@ -154,9 +148,9 @@ cglobal cabac_encode_decision_%1, 1,7
     shr   t5d, 6
     movifnidn t2d, r2m
 %if WIN64
-    PUSH r7
+    PUSH   r7
 %endif
-%ifdef PIC
+%if ARCH_X86_64
     lea    r7, [$$]
 %endif
     LOAD_GLOBAL t5d, cabac_range_lps-4, t5, t4*2, t4
@@ -183,7 +177,7 @@ cglobal cabac_encode_decision_%1, 1,7
     shl   t6d, t3b
 %endif
 %if WIN64
-    POP r7
+    POP    r7
 %endif
     mov   [t0+cb.range], t4d
     add   t3d, [t0+cb.queue]
@@ -409,13 +403,9 @@ CABAC bmi2
 %endmacro
 
 %macro COEFF_LAST 2 ; table, ctx_block_cat
-%ifdef PIC
     lea    r1, [%1 GLOBAL]
     movsxd r6, [r1+4*%2]
     add    r6, r1
-%else
-    movsxd r6, [%1+4*%2]
-%endif
     call   r6
 %endmacro
 
@@ -436,15 +426,9 @@ CABAC bmi2
     %define dct r4
 %endif
 
-%ifdef PIC
-    cglobal func, 4,13,6,-maxcoeffs*SIZEOF_DCTCOEF
+cglobal func, 4,13,6,-maxcoeffs*SIZEOF_DCTCOEF
     lea     r12, [$$]
     %define GLOBAL +r12-$$
-%else
-    cglobal func, 4,12,6,-maxcoeffs*SIZEOF_DCTCOEF
-    %define GLOBAL
-%endif
-
     shl     r1d, 4                                            ; MB_INTERLACED*16
 %if %1
     lea      r4, [significant_coeff_flag_offset_8x8+r1*4 GLOBAL]     ; r12 = sig offset 8x8
@@ -653,15 +637,10 @@ CABAC_RESIDUAL_RD 1, coeff_last_avx512
 
 %macro CABAC_RESIDUAL 1
 cglobal cabac_block_residual_internal, 4,15,0,-4*64
-%ifdef PIC
 ; if we use the same r7 as in cabac_encode_decision, we can cheat and save a register.
     lea     r7, [$$]
     %define lastm [rsp+4*1]
     %define GLOBAL +r7-$$
-%else
-    %define lastm r7d
-    %define GLOBAL
-%endif
     shl     r1d, 4
 
     %define sigoffq r8
