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.
This commit is contained in:
Dylan MacKenzie 2020-08-25 12:11:30 -07:00
parent f07011bad8
commit aae6c0fbfe

View file

@ -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: