Use RTLD_LOCAL | RTLD_LAZY as default dlopen flags

This commit is contained in:
Simonas Kazlauskas
2021-01-31 19:06:10 +02:00
parent 050f41df81
commit 5afb886574
+4 -4
View File
@@ -103,12 +103,12 @@ impl Library {
/// a file. Otherwise, platform-specific algorithms are employed to find a library with a
/// matching file name.
///
/// This is equivalent to [`Library::open`]`(filename, RTLD_NOW)`.
/// This is equivalent to [`Library::open`]`(filename, RTLD_LAZY | RTLD_LOCAL)`.
///
/// [path separator]: std::path::MAIN_SEPARATOR
#[inline]
pub fn new<P: AsRef<OsStr>>(filename: P) -> Result<Library, crate::Error> {
Library::open(Some(filename), RTLD_NOW)
Library::open(Some(filename), RTLD_LAZY | RTLD_LOCAL)
}
/// Eagerly load the `Library` representing the current executable.
@@ -124,12 +124,12 @@ impl Library {
/// Note that behaviour of `Library` loaded with this method is different from
/// Libraries loaded with [`os::windows::Library::this`].
///
/// This is equivalent to [`Library::open`]`(None, RTLD_NOW)`.
/// This is equivalent to [`Library::open`]`(None, RTLD_LAZY | RTLD_LOCAL)`.
///
/// [`os::windows::Library::this`]: crate::os::windows::Library::this
#[inline]
pub fn this() -> Library {
Library::open(None::<&OsStr>, RTLD_NOW).expect("this should never fail")
Library::open(None::<&OsStr>, RTLD_LAZY | RTLD_LOCAL).expect("this should never fail")
}
/// Find and load an executable object file (shared library).