1/* 2 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> 3 * 4 * This file is part of FFmpeg. 5 * 6 * FFmpeg is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * FFmpeg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with FFmpeg; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21#include "config.h" 22 23#ifdef __ELF__ 24# define ELF 25#else 26# define ELF # 27#endif 28 29#if HAVE_AS_FUNC 30# define FUNC 31#else 32# define FUNC # 33#endif 34 35.macro function name, export=0, align=2 36 .macro endfunc 37ELF .size \name, . - \name 38FUNC .endfunc 39 .purgem endfunc 40 .endm 41 .text 42 .align \align 43 .if \export 44 .global EXTERN_ASM\name 45ELF .type EXTERN_ASM\name, %function 46FUNC .func EXTERN_ASM\name 47EXTERN_ASM\name: 48 .else 49ELF .type \name, %function 50FUNC .func \name 51\name: 52 .endif 53.endm 54 55.macro const name, align=2, relocate=0 56 .macro endconst 57ELF .size \name, . - \name 58 .purgem endconst 59 .endm 60#if HAVE_SECTION_DATA_REL_RO 61.if \relocate 62 .section .data.rel.ro 63.else 64 .section .rodata 65.endif 66#elif !defined(__MACH__) 67 .section .rodata 68#else 69 .const_data 70#endif 71 .align \align 72\name: 73.endm 74 75.macro movrel rd, val, offset=0 76#if CONFIG_PIC && defined(__APPLE__) 77 .if \offset < 0 78 adrp \rd, \val@PAGE 79 add \rd, \rd, \val@PAGEOFF 80 sub \rd, \rd, -(\offset) 81 .else 82 adrp \rd, \val+(\offset)@PAGE 83 add \rd, \rd, \val+(\offset)@PAGEOFF 84 .endif 85#elif CONFIG_PIC && defined(_WIN32) 86 .if \offset < 0 87 adrp \rd, \val 88 add \rd, \rd, :lo12:\val 89 sub \rd, \rd, -(\offset) 90 .else 91 adrp \rd, \val+(\offset) 92 add \rd, \rd, :lo12:\val+(\offset) 93 .endif 94#elif CONFIG_PIC 95 adrp \rd, \val+(\offset) 96 add \rd, \rd, :lo12:\val+(\offset) 97#else 98 ldr \rd, =\val+\offset 99#endif 100.endm 101 102#define GLUE(a, b) a ## b 103#define JOIN(a, b) GLUE(a, b) 104#define X(s) JOIN(EXTERN_ASM, s) 105