[x264-devel] x86inc: Add x86-32 PIC support macros

Henrik Gramner git at videolan.org
Tue Mar 12 19:32:06 CET 2019


x264 | branch: master | Henrik Gramner <henrik at gramner.com> | Thu Jan 31 20:17:56 2019 +0100| [82721eae6edddf4955634adc51bf6eb228cc1313] | committer: Anton Mitrofanov

x86inc: Add x86-32 PIC support macros

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=82721eae6edddf4955634adc51bf6eb228cc1313
---

 common/x86/x86inc.asm | 27 ++++++++++++++++++---------
 configure             |  2 +-
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/common/x86/x86inc.asm b/common/x86/x86inc.asm
index 2ffa6f2d..4a7da7fa 100644
--- a/common/x86/x86inc.asm
+++ b/common/x86/x86inc.asm
@@ -89,16 +89,13 @@
     %endif
 %endmacro
 
-%if WIN64
-    %define PIC
-%elif ARCH_X86_64 == 0
-; x86_32 doesn't require PIC.
-; Some distros prefer shared objects to be PIC, but nothing breaks if
-; the code contains a few textrels, so we'll skip that complexity.
-    %undef PIC
-%endif
-%ifdef PIC
+%if ARCH_X86_64
+    %define PIC 1 ; always use PIC on x86-64
     default rel
+%elifidn __OUTPUT_FORMAT__,win32
+    %define PIC 0 ; PIC isn't used on 32-bit Windows
+%elifndef PIC
+    %define PIC 0
 %endif
 
 %ifdef __NASM_VER__
@@ -220,6 +217,18 @@ DECLARE_REG_TMP_SIZE 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
     %define gprsize 4
 %endif
 
+%macro LEA 2
+%if ARCH_X86_64
+    lea %1, [%2]
+%elif PIC
+    call $+5 ; special-cased to not affect the RSB on most CPU:s
+    pop %1
+    add %1, (%2)-$+1
+%else
+    mov %1, %2
+%endif
+%endmacro
+
 %macro PUSH 1
     push %1
     %ifidn rstk, rsp
diff --git a/configure b/configure
index 91c2855c..741ae506 100755
--- a/configure
+++ b/configure
@@ -734,7 +734,7 @@ case $host_cpu in
         ARCH="X86_64"
         AS="${AS-nasm}"
         AS_EXT=".asm"
-        ASFLAGS="$ASFLAGS -DARCH_X86_64=1 -DPIC -I\$(SRCPATH)/common/x86/"
+        ASFLAGS="$ASFLAGS -DARCH_X86_64=1 -I\$(SRCPATH)/common/x86/"
         stack_alignment=16
         [ $compiler = GNU ] && CFLAGS="-m64 $CFLAGS" && LDFLAGS="-m64 $LDFLAGS"
         if [ "$SYS" = MACOSX ]; then



More information about the x264-devel mailing list