From 2fb2a5c50773eecc145099884b9480d78298508e Mon Sep 17 00:00:00 2001 From: Joel Winarske Date: Wed, 2 Dec 2026 16:45:46 -0800 Subject: [PATCH] ndk: define the down-call's variables outside the unnamed namespace GCC 15 does not link the arm64 build. bionic_runtime.cpp defined the four variables its down-call assembly reads (acl_ndk_tls_disp, acl_ndk_wrap_disp, acl_ndk_block_disp, acl_ndk_env_tbl_ptr) as `extern "C"` inside an unnamed namespace. GCC up to 15 gives such a variable internal linkage and a mangled name, so the assembly's references to the C names stay undefined. Clang and GCC 16 use the C name, which is why the clang arm64 builds link. x86-64 has no such variables. The block now closes the unnamed namespace around itself. Tested: - Yocto's aarch64 GCC 15.2, this file compiled to assembly at -O2: before, the four are defined under mangled names and acl_ndk_tls_disp is left undefined; after, all four are defined under their C names. - arm64 (clang release build) on an i.MX 8M Plus: a WebView app loads its library through the down-call and draws. - x86-64 builds with no warning; clang-format clean. Signed-off-by: Joel Winarske --- src/ndk/bionic_runtime.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ndk/bionic_runtime.cpp b/src/ndk/bionic_runtime.cpp index e208a797..c5b6ff3b 100644 --- a/src/ndk/bionic_runtime.cpp +++ b/src/ndk/bionic_runtime.cpp @@ -4414,6 +4414,11 @@ static_assert(offsetof(DowncallBlock, depth) == 0 && // without a first-use check. thread_local DowncallBlock t_downcall_block; +// Outside the unnamed namespace: GCC up to 15 gives a variable declared +// `extern "C"` inside one internal linkage and a mangled name, and the +// assembly below, which names these by their C names, does not link. (Clang +// and GCC 16 use the C name there; functions get it from all of them.) +} // namespace extern "C" { // Read by acl_ndk_downcall_common, which cannot name what is in the anonymous // namespace: the distance from the glibc thread pointer to t_bionic_fs, to @@ -4432,6 +4437,7 @@ acl_ndk_downcall_overflow() { std::abort(); } } // extern "C" +namespace { #define ACL_NDK_STR2(x) #x #define ACL_NDK_STR(x) ACL_NDK_STR2(x)