From aae6c0fbfe3051e5539f47d0e9d84ddee53f72bd Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Tue, 25 Aug 2020 12:11:30 -0700 Subject: [PATCH] Explicitly pass `RTLD_LOCAL` to `dlopen` This happens to be the default on Linux, but the default is unspecified in the POSIX standard. Also switches to `cast` to keep line lengths in check. --- src/librustc_metadata/dynamic_lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_metadata/dynamic_lib.rs b/src/librustc_metadata/dynamic_lib.rs index 8c3c7b70f6c..bdb53e3f75a 100644 --- a/src/librustc_metadata/dynamic_lib.rs +++ b/src/librustc_metadata/dynamic_lib.rs @@ -99,10 +99,10 @@ mod dl { let s = CString::new(filename.as_bytes()).unwrap(); let mut dlerror = error::lock(); - let ret = unsafe { libc::dlopen(s.as_ptr(), libc::RTLD_LAZY) } as *mut u8; + let ret = unsafe { libc::dlopen(s.as_ptr(), libc::RTLD_LAZY | libc::RTLD_LOCAL) }; if !ret.is_null() { - return Ok(ret); + return Ok(ret.cast()); } // A NULL return from `dlopen` indicates that an error has definitely occurred, so if @@ -122,10 +122,10 @@ mod dl { // error message by accident. dlerror.clear(); - let ret = libc::dlsym(handle as *mut libc::c_void, symbol) as *mut u8; + let ret = libc::dlsym(handle as *mut libc::c_void, symbol); if !ret.is_null() { - return Ok(ret); + return Ok(ret.cast()); } // If `dlsym` returns NULL but there is nothing in `dlerror` it means one of two things: