ref: f711d0a2a838691f3695595149de982f9b8a56c7
parent: 578535509a789530c6bb9de061419a34fc8a1447
author: Sindre Aamås <[email protected]>
date: Wed Mar 8 03:39:28 EST 2017
[Common/x86] Add some documentation for X86_32_PICASM helpers
--- a/codec/common/x86/asm_inc.asm
+++ b/codec/common/x86/asm_inc.asm
@@ -669,6 +669,12 @@
vpsrlw %1, %1, 1
%endmacro
+
+;***********************************************************************
+; Utility macros for X86_32 PIC support
+;***********************************************************************
+
+; Used internally by other macros.
%macro INIT_X86_32_PIC_ 2
%ifdef X86_32_PICASM
%xdefine pic_ptr %1
@@ -690,14 +696,21 @@
%endif
%endmacro
+; Get program counter and define a helper macro "pic(addr)" to convert absolute
+; addresses to program counter-relative addresses if X86_32_PICASM is defined.
+; Otherwise define "pic(addr)" as an identity function.
+; %1=register to store PC/EIP in.
%macro INIT_X86_32_PIC 1
INIT_X86_32_PIC_ %1, 1
%endmacro
+; Equivalent as above, but without preserving the value of the register argument.
%macro INIT_X86_32_PIC_NOPRESERVE 1
INIT_X86_32_PIC_ %1, 0
%endmacro
+; Clean up after INIT_X86_32_PIC.
+; Restore the register used to hold PC/EIP if applicable, and undefine defines.
%macro DEINIT_X86_32_PIC 0
%ifdef X86_32_PICASM
%if pic_ptr_preserve
@@ -710,6 +723,8 @@
%undef pic
%endmacro
+; Equivalent as above, but without undefining. Useful for functions with
+; multiple epilogues.
%macro DEINIT_X86_32_PIC_KEEPDEF 0
%ifdef X86_32_PICASM
%if pic_ptr_preserve