Open
Description
When importing a function via raw-dylib
, if an exported function has the same name, the compiler will use the exported version in all cases.
mod user32 {
#[link(name = "user32", kind="raw-dylib")]
extern "C" {
pub fn MessageBoxA();
}
}
#[no_mangle]
pub unsafe extern "C" fn MessageBoxA() {
user32::MessageBoxA()
}
I would expect my exported MessageBoxA
function to compile to a jmp
or a call
to the one imported via IAT.
Instead, in Debug mode it compiles to a call of my function, and in Release mode, an infinite loop (x64 assembly eb fe: jmp 0x0
).
The DLL does not even have an IAT entry for user32.dll
.
If I name my function my_MessageBoxA
and then rename it using a .def
file during linking, the behaviour is as expected.
Meta
rustc --version --verbose
:
rustc 1.72.0-nightly (8084f397c 2023-06-25)
binary: rustc
commit-hash: 8084f397c6710e4748994dd1488b1f399283d469
commit-date: 2023-06-25
host: x86_64-pc-windows-msvc
release: 1.72.0-nightly
LLVM version: 16.0.5
Relates to: #58713