Skip to content

Commit a096de7

Browse files
committed
native_lib: skip to next .so if function was in dependency of the first
1 parent ed5a655 commit a096de7

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/tools/miri/src/shims/native_lib.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,19 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
114114
// using the `libc` crate where this interface is public.
115115
let mut info = std::mem::MaybeUninit::<libc::Dl_info>::zeroed();
116116
unsafe {
117-
if libc::dladdr(fn_ptr, info.as_mut_ptr()) != 0 {
118-
let info = info.assume_init();
119-
#[cfg(target_os = "cygwin")]
120-
let fname_ptr = info.dli_fname.as_ptr();
121-
#[cfg(not(target_os = "cygwin"))]
122-
let fname_ptr = info.dli_fname;
123-
assert!(!fname_ptr.is_null());
124-
if std::ffi::CStr::from_ptr(fname_ptr).to_str().unwrap()
125-
!= lib_path.to_str().unwrap()
126-
{
127-
return None;
128-
}
117+
let res = libc::dladdr(fn_ptr, info.as_mut_ptr());
118+
assert!(res != 0, "failed to load info about function we already loaded");
119+
let info = info.assume_init();
120+
#[cfg(target_os = "cygwin")]
121+
let fname_ptr = info.dli_fname.as_ptr();
122+
#[cfg(not(target_os = "cygwin"))]
123+
let fname_ptr = info.dli_fname;
124+
assert!(!fname_ptr.is_null());
125+
if std::ffi::CStr::from_ptr(fname_ptr).to_str().unwrap()
126+
!= lib_path.to_str().unwrap()
127+
{
128+
// The function is not actually in this .so, check the next one.
129+
continue;
129130
}
130131
}
131132

0 commit comments

Comments
 (0)