Open
Description
In C++ (MSVC) un-mangling and exporting are controlled via extern "C"
and __declspec(dllexport)
respectively.
extern "C" {
namespace to_export {
__declspec(dllexport) int64_t foo() {
int64_t bar();
return bar();
}
}
namespace not_to_export {
int32_t bar() {
return 42;
}
}
}
00000000 characteristics
FFFFFFFF time date stamp
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
1 0 00001000 foo = foo
In Rust, however, all #[no_mangle]
functions are exported from the final cdylib
.
pub mod to_export {
#[no_mangle]
pub unsafe extern "system" fn foo() -> i64 {
extern "system" {
fn bar() -> i64;
}
bar()
}
}
mod not_to_export {
#[no_mangle]
extern "system" fn bar() -> i32 {
42
}
}
00000000 characteristics
FFFFFFFF time date stamp
0.00 version
1 ordinal base
2 number of functions
2 number of names
ordinal hint RVA name
1 0 00001000 bar = bar
2 1 00001010 foo = foo
It seems that it is not possible to define an un-mangled and un-exported symbol in Rust.