PR #25790 opened by Jason5480
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25790
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25790.patch

Fixes #25787.

`tx_float_neon.S` loads the `ff_tx_tab_*_float` tables with `movrel`, which on 
ELF with PIC is a plain `adrp` + `add` against the symbol. With default 
visibility, a static libavutil cannot be linked into a shared library on 
aarch64 (for example an Android app) unless that library is linked with 
`-Bsymbolic`. This patch gives the tables hidden visibility in `TABLE_DEF`, 
with `attribute_visibility_hidden` from `attributes_internal.h`. They are used 
only inside libavutil, and a shared libavutil already keeps `ff_` symbols 
local, so shared builds do not change.

Tested:

- Android arm64, NDK r27c (clang/lld), `--enable-pic --enable-static 
--disable-shared`: `clang --target=aarch64-linux-android28 -shared 
-Wl,--whole-archive libavutil.a -Wl,--no-whole-archive -lm` fails on master 
(`ff_tx_tab_{32,53,64,128,256}_float`, then lld's error limit) and links with 
this patch. All 54 `ff_tx_tab_*` symbols in `tx_float.o`, `tx_double.o`, and 
`tx_int32.o` are `HIDDEN`, and none are in the resulting `.so`'s dynamic symbol 
table.
- aarch64 Linux, GNU ld: a static libavutil (`--enable-pic`) links into a 
shared object.
- `make fate-checkasm-av_tx` passes on x86_64 (shared, and static with 
`--enable-pic`) and on aarch64 under qemu-user (shared, and static with 
`--enable-pic`).



>From 5941d910cf969619e31db81b03ae70d0f7a2197e Mon Sep 17 00:00:00 2001
From: Iason Nikolas <[email protected]>
Date: Fri, 6 Nov 2026 00:00:53 +0200
Subject: [PATCH] avutil/tx: give the tables hidden visibility

tx_float_neon.S loads the ff_tx_tab_*_float tables with movrel, which on
ELF with PIC is a plain adrp + add against the symbol. The tables had
default visibility, so when a static libavutil is linked into a shared
library, such as an Android app, the linker rejects these references
unless the shared library is linked with -Bsymbolic:

  ld.lld: error: relocation R_AARCH64_ADR_PREL_PG_HI21 cannot be used
  against symbol 'ff_tx_tab_32_float'; recompile with -fPIC

The tables are only used inside libavutil, and a shared libavutil
already keeps ff_ symbols local through its version script, so shared
builds do not change.

Fixes #25787.

Signed-off-by: Iason Nikolas <[email protected]>
---
 libavutil/tx_template.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index ecee572e40e..03f38831138 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -24,9 +24,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "attributes_internal.h"
 #include "mem.h"
 
+/* Hidden, so that assembly can address the tables PC-relatively even when
+ * libavutil is linked statically into a shared library. */
 #define TABLE_DEF(name, size) \
+    attribute_visibility_hidden \
     DECLARE_ALIGNED(32, TXSample, TX_TAB(ff_tx_tab_ ##name))[size]
 
 #define SR_POW2_TABLES \
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to