@@ -11,12 +11,25 @@ pub enum Dlsym {
1111impl Dlsym {
1212 // Returns an error for unsupported symbols, and None if this symbol
1313 // 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 > > {
1515 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) ,
2033 } )
2134 }
2235}
0 commit comments