Skip to content

Commit b97de97

Browse files
Accept RTLD_GLOBAL flag in dlopen function (#1481)
We always resolve symbols in the global scope in AOT linking, so we can safely accept the `RTLD_GLOBAL` flag in the `dlopen` function.
1 parent 20874d5 commit b97de97

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

crates/wit-component/dl/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use core::{
1212

1313
const RTLD_LAZY: c_int = 1;
1414
const RTLD_NOW: c_int = 2;
15+
const RTLD_GLOBAL: c_int = 256;
1516

1617
const RTLD_NEXT: isize = -1;
1718
const RTLD_DEFAULT: isize = 0;
@@ -102,7 +103,7 @@ pub unsafe extern "C" fn dlopen(name: *const c_char, flags: c_int) -> *const c_v
102103
);
103104
}
104105

105-
if (flags & !(RTLD_LAZY | RTLD_NOW)) != 0 {
106+
if (flags & !(RTLD_LAZY | RTLD_NOW | RTLD_GLOBAL)) != 0 {
106107
// TODO
107108
ERROR = c"dlopen flags not yet supported".as_ptr();
108109
return ptr::null();

crates/wit-component/libdl.so

2 Bytes
Binary file not shown.

crates/wit-component/tests/components/link-dl-openable-builtin-libdl/component.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@
178178
block ;; label = @3
179179
block ;; label = @4
180180
local.get 1
181-
i32.const 3
182-
i32.le_u
181+
i32.const -260
182+
i32.and
183+
i32.eqz
183184
br_if 0 (;@4;)
184185
local.get 3
185186
i32.const 41

0 commit comments

Comments
 (0)