Files
wz-phone/desktop/src-tauri/cpp/getauxval_fix.c
Siavash Sameni a852cad15e
Some checks failed
Mirror to GitHub / mirror (push) Failing after 38s
Build Release Binaries / build-amd64 (push) Failing after 3m55s
step D(android): compile cpp/getauxval_fix.c alongside hello.c
Fourth incremental variable. Adds the getauxval_fix.c shim from the
legacy wzp-android crate (which has been shipping with it for months
without issue) to our cc::Build on Android. The file defines a single
getauxval() function that delegates to bionic's real runtime
implementation via dlsym — this is needed because rustc links
compiler-rt's broken static getauxval stub that SIGSEGVs in .so
libraries loaded via dlopen (reads __libc_auxv which is NULL).

Not imported from Rust. Goal: verify that adding a second C static
archive (and especially one that overrides a libc-ish symbol) doesn't
regress the working build.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 15:03:37 +04:00

27 lines
877 B
C

/* Override the broken static getauxval from compiler-rt/CRT.
*
* The static version reads from __libc_auxv which is NULL in shared libs
* loaded via dlopen, causing SIGSEGV in init_have_lse_atomics at load time.
* This version calls the real bionic getauxval via dlsym.
*
* Copied verbatim from crates/wzp-android/cpp/getauxval_fix.c — the legacy
* wzp-android crate has been using this shim successfully for months.
*/
#ifdef __ANDROID__
#include <dlfcn.h>
#include <stdint.h>
typedef unsigned long (*getauxval_fn)(unsigned long);
unsigned long getauxval(unsigned long type) {
static getauxval_fn real_getauxval = (getauxval_fn)0;
if (!real_getauxval) {
real_getauxval = (getauxval_fn)dlsym((void*)-1L /* RTLD_DEFAULT */, "getauxval");
if (!real_getauxval) {
return 0;
}
}
return real_getauxval(type);
}
#endif