@@ -11,12 +11,25 @@ pub enum Dlsym {
11
11
impl Dlsym {
12
12
// Returns an error for unsupported symbols, and None if this symbol
13
13
// should become a NULL pointer (pretend it does not exist).
14
- pub fn from_str ( name : & str ) -> InterpResult < ' static , Option < Dlsym > > {
14
+ pub fn from_str ( name : & [ u8 ] , target_os : & str ) -> InterpResult < ' static , Option < Dlsym > > {
15
15
use self :: Dlsym :: * ;
16
- Ok ( match name {
17
- "getentropy" => Some ( GetEntropy ) ,
18
- "__pthread_get_minstack" => None ,
19
- _ => throw_unsup_format ! ( "unsupported dlsym: {}" , name) ,
16
+ let name = String :: from_utf8_lossy ( name) ;
17
+ Ok ( match target_os {
18
+ "linux" => match & * name {
19
+ "__pthread_get_minstack" => None ,
20
+ _ => throw_unsup_format ! ( "unsupported Linux dlsym: {}" , name) ,
21
+ }
22
+ "macos" => match & * name {
23
+ "getentropy" => Some ( GetEntropy ) ,
24
+ _ => throw_unsup_format ! ( "unsupported macOS dlsym: {}" , name) ,
25
+ }
26
+ "windows" => match & * name {
27
+ "SetThreadStackGuarantee" => None ,
28
+ "AcquireSRWLockExclusive" => None ,
29
+ "GetSystemTimePreciseAsFileTime" => None ,
30
+ _ => throw_unsup_format ! ( "unsupported Windows dlsym: {}" , name) ,
31
+ }
32
+ os => bug ! ( "dlsym not implemented for target_os {}" , os) ,
20
33
} )
21
34
}
22
35
}
0 commit comments