2 use rustc_target::spec::abi::Abi;
4 use crate::helpers::target_os_is_unix;
6 use shims::unix::dlsym as unix;
7 use shims::windows::dlsym as windows;
9 #[derive(Debug, Copy, Clone)]
10 #[allow(non_camel_case_types)]
13 Windows(windows::Dlsym),
17 // Returns an error for unsupported symbols, and None if this symbol
18 // should become a NULL pointer (pretend it does not exist).
19 pub fn from_str<'tcx>(name: &[u8], target_os: &str) -> InterpResult<'tcx, Option<Dlsym>> {
20 let name = &*String::from_utf8_lossy(name);
22 target if target_os_is_unix(target) =>
23 unix::Dlsym::from_str(name, target)?.map(Dlsym::Posix),
24 "windows" => windows::Dlsym::from_str(name)?.map(Dlsym::Windows),
25 os => bug!("dlsym not implemented for target_os {}", os),
30 impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
31 pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
36 args: &[OpTy<'tcx, Provenance>],
37 dest: &PlaceTy<'tcx, Provenance>,
38 ret: Option<mir::BasicBlock>,
39 ) -> InterpResult<'tcx> {
40 let this = self.eval_context_mut();
42 Dlsym::Posix(dlsym) =>
43 unix::EvalContextExt::call_dlsym(this, dlsym, abi, args, dest, ret),
44 Dlsym::Windows(dlsym) =>
45 windows::EvalContextExt::call_dlsym(this, dlsym, abi, args, dest, ret),