Commit | Line | Data |
---|---|---|
b7b17ed6 JG |
1 | /* |
2 | * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> | |
3 | * | |
4 | * This file is part of Libav. | |
5 | * | |
6 | * Libav 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 | * Libav 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 Libav; 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 | |
69ac24e5 | 26 | # define ELF # |
b7b17ed6 JG |
27 | #endif |
28 | ||
d5a55981 JG |
29 | #if HAVE_AS_FUNC |
30 | # define FUNC | |
31 | #else | |
32 | # define FUNC # | |
33 | #endif | |
34 | ||
e5afa1b5 PC |
35 | #ifndef __has_feature |
36 | # define __has_feature(x) 0 | |
37 | #endif | |
38 | ||
b7b17ed6 JG |
39 | .macro function name, export=0, align=2 |
40 | .macro endfunc | |
41 | ELF .size \name, . - \name | |
d5a55981 | 42 | FUNC .endfunc |
b7b17ed6 JG |
43 | .purgem endfunc |
44 | .endm | |
45 | .text | |
46 | .align \align | |
47 | .if \export | |
48 | .global EXTERN_ASM\name | |
9c029f67 | 49 | ELF .type EXTERN_ASM\name, %function |
d5a55981 | 50 | FUNC .func EXTERN_ASM\name |
b7b17ed6 | 51 | EXTERN_ASM\name: |
9c029f67 | 52 | .else |
b7b17ed6 | 53 | ELF .type \name, %function |
d5a55981 | 54 | FUNC .func \name |
b7b17ed6 | 55 | \name: |
9c029f67 | 56 | .endif |
b7b17ed6 JG |
57 | .endm |
58 | ||
780cd20b | 59 | .macro const name, align=2, relocate=0 |
b7b17ed6 JG |
60 | .macro endconst |
61 | ELF .size \name, . - \name | |
62 | .purgem endconst | |
63 | .endm | |
780cd20b MS |
64 | #if HAVE_SECTION_DATA_REL_RO |
65 | .if \relocate | |
66 | .section .data.rel.ro | |
67 | .else | |
68 | .section .rodata | |
69 | .endif | |
41cf3e3b MS |
70 | #elif defined(_WIN32) |
71 | .section .rdata | |
780cd20b | 72 | #elif !defined(__MACH__) |
b7b17ed6 | 73 | .section .rodata |
a238b83b JG |
74 | #else |
75 | .const_data | |
76 | #endif | |
b7b17ed6 JG |
77 | .align \align |
78 | \name: | |
79 | .endm | |
80 | ||
c44a8a3e | 81 | .macro movrel rd, val, offset=0 |
fd2981ea | 82 | #if CONFIG_PIC && defined(__APPLE__) |
c44a8a3e | 83 | .if \offset < 0 |
fd2981ea JG |
84 | adrp \rd, \val@PAGE |
85 | add \rd, \rd, \val@PAGEOFF | |
c44a8a3e MS |
86 | sub \rd, \rd, -(\offset) |
87 | .else | |
88 | adrp \rd, \val+(\offset)@PAGE | |
89 | add \rd, \rd, \val+(\offset)@PAGEOFF | |
90 | .endif | |
7b7760ad MS |
91 | #elif CONFIG_PIC && defined(_WIN32) |
92 | .if \offset < 0 | |
93 | adrp \rd, \val | |
94 | add \rd, \rd, :lo12:\val | |
95 | sub \rd, \rd, -(\offset) | |
96 | .else | |
97 | adrp \rd, \val+(\offset) | |
98 | add \rd, \rd, :lo12:\val+(\offset) | |
99 | .endif | |
fd2981ea | 100 | #elif CONFIG_PIC |
e5afa1b5 PC |
101 | # if __has_feature(hwaddress_sanitizer) |
102 | adrp \rd, :pg_hi21_nc:\val+(\offset) | |
103 | # else | |
8847eeaa | 104 | adrp \rd, \val+(\offset) |
e5afa1b5 | 105 | # endif |
8847eeaa | 106 | add \rd, \rd, :lo12:\val+(\offset) |
b7b17ed6 | 107 | #else |
c44a8a3e | 108 | ldr \rd, =\val+\offset |
b7b17ed6 JG |
109 | #endif |
110 | .endm | |
9c029f67 JG |
111 | |
112 | #define GLUE(a, b) a ## b | |
113 | #define JOIN(a, b) GLUE(a, b) | |
114 | #define X(s) JOIN(EXTERN_ASM, s) |