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