ref: cbd820dcebebfd7d5834afbffc18848c0ad9f4e0
parent: 66095ce5951cc382e064dc724f9019c0220e652f
author: Johann <[email protected]>
date: Thu Apr 2 06:41:24 EDT 2020
x86inc.asm: copy PIC macros from x86_abi_support.asm Reapply 7e065cd57. x86inc.asm always defines PIC for x86_64. We undefine it for x32. Incorporate e56f96394 as well to ensure GET_GOT_DEFINED is defined. BUG=webm:1679 Change-Id: I1535d57bcb4223327ca63b4fd11bffcda1009332
--- a/third_party/x86inc/README.libvpx_new
+++ b/third_party/x86inc/README.libvpx_new
@@ -12,3 +12,4 @@
Prefix functions with vpx by default.
Manage name mangling (prefixing with '_') manually because 'PREFIX' does not
exist in libvpx.
+Copy PIC 'GLOBAL' macros from x86_abi_support.asm
--- a/third_party/x86inc/x86inc.asm_new
+++ b/third_party/x86inc/x86inc.asm_new
@@ -107,14 +107,96 @@
%endif
%endmacro
-%if ARCH_X86_64
- %define PIC 1 ; always use PIC on x86-64
- default rel
+; PIC macros from vpx_ports/x86_abi_support.asm.
+%ifidn __OUTPUT_FORMAT__,elf32
+%define ABI_IS_32BIT 1
+%elifidn __OUTPUT_FORMAT__,macho32
+%define ABI_IS_32BIT 1
%elifidn __OUTPUT_FORMAT__,win32
- %define PIC 0 ; PIC isn't used on 32-bit Windows
-%elifndef PIC
- %define PIC 0
+%define ABI_IS_32BIT 1
+%elifidn __OUTPUT_FORMAT__,aout
+%define ABI_IS_32BIT 1
+%else
+%define ABI_IS_32BIT 0
%endif
+
+%if ABI_IS_32BIT
+ %if CONFIG_PIC=1
+ %ifidn __OUTPUT_FORMAT__,elf32
+ %define GET_GOT_DEFINED 1
+ %define WRT_PLT wrt ..plt
+ %macro GET_GOT 1
+ extern _GLOBAL_OFFSET_TABLE_
+ push %1
+ call %%get_got
+ %%sub_offset:
+ jmp %%exitGG
+ %%get_got:
+ mov %1, [esp]
+ add %1, _GLOBAL_OFFSET_TABLE_ + $$ - %%sub_offset wrt ..gotpc
+ ret
+ %%exitGG:
+ %undef GLOBAL
+ %define GLOBAL(x) x + %1 wrt ..gotoff
+ %undef RESTORE_GOT
+ %define RESTORE_GOT pop %1
+ %endmacro
+ %elifidn __OUTPUT_FORMAT__,macho32
+ %define GET_GOT_DEFINED 1
+ %macro GET_GOT 1
+ push %1
+ call %%get_got
+ %%get_got:
+ pop %1
+ %undef GLOBAL
+ %define GLOBAL(x) x + %1 - %%get_got
+ %undef RESTORE_GOT
+ %define RESTORE_GOT pop %1
+ %endmacro
+ %else
+ %define GET_GOT_DEFINED 0
+ %endif
+ %endif
+
+ %if ARCH_X86_64 == 0
+ %undef PIC
+ %endif
+
+%else
+ %macro GET_GOT 1
+ %endmacro
+ %define GLOBAL(x) rel x
+ %define WRT_PLT wrt ..plt
+
+ %if WIN64
+ %define PIC
+ %elifidn __OUTPUT_FORMAT__,macho64
+ %define PIC
+ %elif CONFIG_PIC
+ %define PIC
+ %endif
+%endif
+
+%ifnmacro GET_GOT
+ %macro GET_GOT 1
+ %endmacro
+ %define GLOBAL(x) x
+%endif
+%ifndef RESTORE_GOT
+ %define RESTORE_GOT
+%endif
+%ifndef WRT_PLT
+ %define WRT_PLT
+%endif
+
+%ifdef PIC
+ default rel
+%endif
+
+%ifndef GET_GOT_DEFINED
+ %define GET_GOT_DEFINED 0
+%endif
+; End PIC macros from vpx_ports/x86_abi_support.asm.
%define HAVE_PRIVATE_EXTERN 1
%ifdef __NASM_VER__