1 ;*****************************************************************************
2 ;* x86inc-32.asm: h264 encoder library
3 ;*****************************************************************************
4 ;* Copyright (C) 2006-2008 x264 project
6 ;* Authors: Sam Hocevar <sam@zoy.org>
7 ;* Loren Merritt <lorenm@u.washington.edu>
9 ;* This program is free software; you can redistribute it and/or modify
10 ;* it under the terms of the GNU General Public License as published by
11 ;* the Free Software Foundation; either version 2 of the License, or
12 ;* (at your option) any later version.
14 ;* This program is distributed in the hope that it will be useful,
15 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;* GNU General Public License for more details.
19 ;* You should have received a copy of the GNU General Public License
20 ;* along with this program; if not, write to the Free Software
21 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
22 ;*****************************************************************************
26 ; Name of the .rodata section. On OS X we cannot use .rodata because NASM
27 ; is unable to compute address offsets outside of .text so we use the .text
28 ; section instead until NASM is fixed.
29 %macro SECTION_RODATA 0
30 %ifidn __OUTPUT_FORMAT__,macho
31 SECTION .text align=16
34 SECTION .rodata align=16
38 ; PIC support macros. All these macros are totally harmless when __PIC__ is
39 ; not defined but can ruin everything if misused in PIC mode. On x86, shared
40 ; objects cannot directly access global variables by address, they need to
41 ; go through the GOT (global offset table). Most OSes do not care about it
42 ; and let you load non-shared .so objects (Linux, Win32...). However, OS X
43 ; requires PIC code in its .dylib objects.
45 ; - GLOBAL should be used as a suffix for global addressing, eg.
47 ; mov eax, [foo GLOBAL]
51 ; - picgetgot computes the GOT address into the given register in PIC
52 ; mode, otherwise does nothing. You need to do this before using GLOBAL.
53 ; Before in both execution order and compiled code order (so GLOBAL knows
54 ; which register the GOT is in).
56 ; - picpush and picpop respectively push and pop the given register
57 ; in PIC mode, otherwise do nothing. You should always use them around
58 ; picgetgot except when sure that the register is no longer used and is
59 ; being restored later by other means.
61 ; - picesp is defined to compensate the changing of esp when pushing
62 ; a register into the stack, eg.
65 ; mov eax, [picesp + 12]
73 %ifidn __OUTPUT_FORMAT__,macho
74 ; There is no real global offset table on OS X, but we still
75 ; need to reference our variables by offset.
76 %define GOT_reg(x) - fakegot + x
83 %define GLOBAL GOT_reg(%1)
86 %ifidn __OUTPUT_FORMAT__,elf
87 %define GOT _GLOBAL_OFFSET_TABLE_
89 %define GOT __GLOBAL_OFFSET_TABLE_
92 %define GOT_reg(x) + x wrt ..gotoff
97 add %1, GOT + $$ - %%getgot wrt ..gotpc
99 %define GLOBAL GOT_reg(%1)