summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorJohann <johannkoenig@google.com>2016-02-17 18:21:03 -0800
committerJohann <johannkoenig@google.com>2016-02-17 18:45:21 -0800
commit7e065cd57392772b2ec20388f9cacc1c828995e9 (patch)
tree85cba6c618c96de53b1bf98bcc8e24ec637329e3 /third_party
parent71ccd103bd7ec1c6d34ea03417debfc558e64e05 (diff)
Copy PIC handling code from x86_abi_support
Change-Id: Ia05fe78d2bd29b6aebaf6605719fe8a32528f25c
Diffstat (limited to 'third_party')
-rw-r--r--third_party/x86inc/README.libvpx1
-rw-r--r--third_party/x86inc/x86inc.asm94
2 files changed, 84 insertions, 11 deletions
diff --git a/third_party/x86inc/README.libvpx b/third_party/x86inc/README.libvpx
index 2a75c4ad1..6fe3429d6 100644
--- a/third_party/x86inc/README.libvpx
+++ b/third_party/x86inc/README.libvpx
@@ -14,3 +14,4 @@ Manage name mangling (prefixing with '_') manually because 'PREFIX' does not
exist in libvpx.
Expand PIC default to macho64 and respect CONFIG_PIC from libvpx
Set 'private_extern' visibility for macho targets.
+Copy PIC 'GLOBAL' macros from x86_abi_support.asm
diff --git a/third_party/x86inc/x86inc.asm b/third_party/x86inc/x86inc.asm
index 112e37288..e28348eef 100644
--- a/third_party/x86inc/x86inc.asm
+++ b/third_party/x86inc/x86inc.asm
@@ -101,21 +101,93 @@
SECTION .rodata align=%1
%endmacro
-%if WIN64
- %define PIC
-%elifidn __OUTPUT_FORMAT__,macho64
- %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
-%elif CONFIG_PIC
- %define PIC
+; PIC macros are copied from vpx_ports/x86_abi_support.asm. The "define PIC"
+; from original code is added in for 64bit.
+%ifidn __OUTPUT_FORMAT__,elf32
+%define ABI_IS_32BIT 1
+%elifidn __OUTPUT_FORMAT__,macho32
+%define ABI_IS_32BIT 1
+%elifidn __OUTPUT_FORMAT__,win32
+%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
+; Done with PIC macros
%ifdef __NASM_VER__
%use smartalign