Răsfoiți Sursa

app: add atexit() shim to workaround openssl issues (temp workaround)

jkds 1 lună în urmă
părinte
comite
a5317a2a42
2 a modificat fișierele cu 18 adăugiri și 2 ștergeri
  1. 14 0
      bin/app/src/android/mod.rs
  2. 4 2
      bin/drk/Cargo.toml

+ 14 - 0
bin/app/src/android/mod.rs

@@ -84,3 +84,17 @@ pub fn get_screen_density() -> f32 {
 pub fn is_ime_visible() -> bool {
     call_mainactivity_bool_method!("isImeVisible")
 }
+
+/// OpenSSL's statically linked `libcrypto` registers `OPENSSL_cleanup` through
+/// `atexit()`. Bionic only exports `atexit` as the versioned symbol
+/// `atexit@@LIBC`, so the bare, unversioned reference baked into `libcrypto.a`
+/// cannot be resolved by the dynamic loader and aborts `dlopen` with
+/// `cannot locate symbol "atexit"`. Defining `atexit` here lets
+/// `libdarkfi-app.so` satisfy the symbol itself. The handler is dropped on
+/// purpose: Android kills the process on exit, so `OPENSSL_cleanup` has nothing
+/// to reclaim.
+#[no_mangle]
+pub extern "C" fn atexit(func: Option<extern "C" fn()>) -> std::ffi::c_int {
+    let _ = func;
+    0
+}

+ 4 - 2
bin/drk/Cargo.toml

@@ -32,7 +32,6 @@ num-bigint = "0.4.6"
 prettytable-rs = "0.10.0"
 rand = "0.8.6"
 rodio = {version = "0.21.1", default-features = false, features = ["playback", "mp3"]}
-rusqlite = {version = "0.37.0", features = ["sqlcipher"]}
 sled-overlay = "0.1.20"
 toml = "0.9.8"
 tracing = "0.1.44"
@@ -51,8 +50,11 @@ serde = {version = "1.0.228", features = ["derive"]}
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
 
+[target.'cfg(not(target_os = "android"))'.dependencies]
+rusqlite = {version = "0.37.0", features = ["sqlcipher"]}
+
 [target.'cfg(target_os = "android")'.dependencies]
-libsqlite3-sys = { version = "*", features = ["bundled-sqlcipher-vendored-openssl"] }
+rusqlite = {version = "0.37.0", features = ["bundled-sqlcipher-vendored-openssl"]}
 
 [lints]
 workspace = true