about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-06-09 21:49:50 +0200
committerRalf Jung <post@ralfj.de>2025-06-09 21:49:50 +0200
commita096de73ea6f9a41026f6c6ad5a393f9418aab97 (patch)
tree91bf232afb37b985723084ef368c3e43f2850689
parented5a65538694537ec1776a40c708f84545c0508b (diff)
downloadrust-a096de73ea6f9a41026f6c6ad5a393f9418aab97.tar.gz
rust-a096de73ea6f9a41026f6c6ad5a393f9418aab97.zip
native_lib: skip to next .so if function was in dependency of the first
-rw-r--r--src/tools/miri/src/shims/native_lib.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/tools/miri/src/shims/native_lib.rs b/src/tools/miri/src/shims/native_lib.rs
index 40440bf6da4..acf258f4eed 100644
--- a/src/tools/miri/src/shims/native_lib.rs
+++ b/src/tools/miri/src/shims/native_lib.rs
@@ -114,18 +114,19 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
             // using the `libc` crate where this interface is public.
             let mut info = std::mem::MaybeUninit::<libc::Dl_info>::zeroed();
             unsafe {
-                if libc::dladdr(fn_ptr, info.as_mut_ptr()) != 0 {
-                    let info = info.assume_init();
-                    #[cfg(target_os = "cygwin")]
-                    let fname_ptr = info.dli_fname.as_ptr();
-                    #[cfg(not(target_os = "cygwin"))]
-                    let fname_ptr = info.dli_fname;
-                    assert!(!fname_ptr.is_null());
-                    if std::ffi::CStr::from_ptr(fname_ptr).to_str().unwrap()
-                        != lib_path.to_str().unwrap()
-                    {
-                        return None;
-                    }
+                let res = libc::dladdr(fn_ptr, info.as_mut_ptr());
+                assert!(res != 0, "failed to load info about function we already loaded");
+                let info = info.assume_init();
+                #[cfg(target_os = "cygwin")]
+                let fname_ptr = info.dli_fname.as_ptr();
+                #[cfg(not(target_os = "cygwin"))]
+                let fname_ptr = info.dli_fname;
+                assert!(!fname_ptr.is_null());
+                if std::ffi::CStr::from_ptr(fname_ptr).to_str().unwrap()
+                    != lib_path.to_str().unwrap()
+                {
+                    // The function is not actually in this .so, check the next one.
+                    continue;
                 }
             }