1 ;*****************************************************************************
2 ;* i386inc.asm: h264 encoder library
3 ;*****************************************************************************
4 ;* Copyright (C) 2006 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 ;=============================================================================
26 ; Macros and other preprocessor constants
27 ;=============================================================================
29 ; Symbol prefix for C linkage
41 ; Name of the .rodata section. On OS X we cannot use .rodata because NASM
42 ; is unable to compute address offsets outside of .text so we use the .text
43 ; section instead until NASM is fixed.
44 %macro SECTION_RODATA 0
45 %ifidn __OUTPUT_FORMAT__,macho
46 SECTION .text align=16
49 SECTION .rodata data align=16
53 ; PIC support macros. All these macros are totally harmless when __PIC__ is
54 ; not defined but can ruin everything if misused in PIC mode. On x86, shared
55 ; objects cannot directly access global variables by address, they need to
56 ; go through the GOT (global offset table). Most OSes do not care about it
57 ; and let you load non-shared .so objects (Linux, Win32...). However, OS X
58 ; requires PIC code in its .dylib objects.
60 ; - GOT_* should be used as a suffix for global addressing, eg.
62 ; mov eax, [foo GOT_ebx]
66 ; - picgetgot computes the GOT address into the given register in PIC
67 ; mode, otherwise does nothing. You need to do this before using GOT_*.
69 ; - picpush and picpop respectively push and pop the given register
70 ; in PIC mode, otherwise do nothing. You should always use them around
71 ; picgetgot except when sure that the register is no longer used and is
72 ; being restored later by other means.
74 ; - picesp is defined to compensate the changing of esp when pushing
75 ; a register into the stack, eg.
78 ; mov eax, [picesp + 12]
85 %ifidn __OUTPUT_FORMAT__,macho
86 ; There is no real global offset table on OS X, but we still
87 ; need to reference our variables by offset.
88 %define GOT_eax - fakegot + eax
89 %define GOT_ebx - fakegot + ebx
90 %define GOT_ecx - fakegot + ecx
91 %define GOT_edx - fakegot + edx
99 %ifidn __OUTPUT_FORMAT__,elf
100 %define GOT _GLOBAL_OFFSET_TABLE_
102 %define GOT __GLOBAL_OFFSET_TABLE_
105 %define GOT_eax + eax wrt ..gotoff
106 %define GOT_ebx + ebx wrt ..gotoff
107 %define GOT_ecx + ecx wrt ..gotoff
108 %define GOT_edx + edx wrt ..gotoff
113 add %1, GOT + $$ - %%getgot wrt ..gotpc
137 %assign FENC_STRIDE 16
138 %assign FDEC_STRIDE 32
140 ; This is needed for ELF, otherwise the GNU linker assumes the stack is
141 ; executable by default.
142 %ifidn __OUTPUT_FORMAT__,elf
143 SECTION .note.GNU-stack noalloc noexec nowrite progbits