summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2022-07-11 12:02:23 +0300
committerMartin Storsjö <martin@martin.st>2022-09-02 23:13:29 +0300
commite4ac156b7c47725327dff78bb83f5eecbaee3add (patch)
tree4417a1abdaa7e087f33a751ec7e6d33d1257786f /libavutil
parent0dd8fe6f4b072077d2d87eb3a2933e145ac41df1 (diff)
libavcodec: Set hidden visibility on global symbols accessed from AArch64 assembly
The AArch64 assembly accesses those symbols directly, without indirection via e.g. the GOT on ELF. In order for this not to require text relocations, those symbols need to be resolved fully at link time, i.e. those symbols can't be interposable. Normally, so far, this is achieved when linking shared libraries in two ways; we have a version script (libavcodec/libavcodec.v) which marks all symbols that don't start with av* as local. Additionally, we try to add -Wl,-Bsymbolic to the linker options if supported, making sure that such symbol references are resolved fully at link time, instead of making them interposable. When the libavcodec static library is linked into another shared library, there's no guarantee that it uses similar options (even though that would be favourable), which would end up requiring text relocations in the AArch64 assembly. Explicitly mark the symbols that are accessed from AArch64 assembly as hidden, so that they are resolved fully at link time even without the version script and -Wl,-Bsymbolic. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/attributes_internal.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/libavutil/attributes_internal.h b/libavutil/attributes_internal.h
new file mode 100644
index 0000000000..9d3d10b63e
--- /dev/null
+++ b/libavutil/attributes_internal.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_ATTRIBUTES_INTERNAL_H
+#define AVUTIL_ATTRIBUTES_INTERNAL_H
+
+#include "attributes.h"
+
+#if (AV_GCC_VERSION_AT_LEAST(4,0) || defined(__clang__)) && (defined(__ELF__) || defined(__MACH__))
+# define attribute_visibility_hidden __attribute__((visibility("hidden")))
+#else
+# define attribute_visibility_hidden
+#endif
+
+#endif /* AVUTIL_ATTRIBUTES_INTERNAL_H */