]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/src/shims/unix/linux/dlsym.rs
Rollup merge of #101642 - SkiFire13:fix-inplace-collection-leak, r=the8472
[rust.git] / src / tools / miri / src / shims / unix / linux / dlsym.rs
1 use rustc_middle::mir;
2
3 use crate::*;
4
5 #[derive(Debug, Copy, Clone)]
6 pub enum Dlsym {}
7
8 impl Dlsym {
9     // Returns an error for unsupported symbols, and None if this symbol
10     // should become a NULL pointer (pretend it does not exist).
11     pub fn from_str<'tcx>(name: &str) -> InterpResult<'tcx, Option<Dlsym>> {
12         Ok(match name {
13             "__pthread_get_minstack" => None,
14             "getrandom" => None, // std falls back to syscall(SYS_getrandom, ...) when this is NULL.
15             "statx" => None,     // std falls back to syscall(SYS_statx, ...) when this is NULL.
16             _ => throw_unsup_format!("unsupported Linux dlsym: {}", name),
17         })
18     }
19 }
20
21 impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
22 pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
23     fn call_dlsym(
24         &mut self,
25         dlsym: Dlsym,
26         _args: &[OpTy<'tcx, Provenance>],
27         _dest: &PlaceTy<'tcx, Provenance>,
28         ret: Option<mir::BasicBlock>,
29     ) -> InterpResult<'tcx> {
30         let this = self.eval_context_mut();
31         let _ret = ret.expect("we don't support any diverging dlsym");
32         assert!(this.tcx.sess.target.os == "linux");
33
34         match dlsym {}
35
36         //trace!("{:?}", this.dump_place(**dest));
37         //this.go_to_block(ret);
38         //Ok(())
39     }
40 }