Windows DllMain name is exported #67399
Labels
A-linkage
Area: linking into static, shared libraries and binaries
C-bug
Category: This is a bug.
O-windows
Operating system: Windows
O-windows-msvc
Toolchain: MSVC, Operating system: Windows
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
On Windows, Rust exports the name of
DllMain
(std
) /_DllMainCRTStartup
(no_std
), which is not standard behaviour and unwanted in most cases (that I am aware of). As far as I understand this happens because they must be marked with either#[no_mangle]
or#[export_name = ".."]
so thelink.exe
can find the symbol. Theextern
keyword must also be used to mark them asstdcall
for 32 bit targets.Example project:
Cargo.toml
lib.rs (
std
)lib.rs (
no_std
)dumpbin output
Example Windows dll file:
Rust example from above (
std
):Rust example from above (
no_std
):Expected output
DllMain
and_DllMainCRTStartup
should not be exported by name, just as in the first dumpbin output example of a Windows system dll.Tested compiler version
The text was updated successfully, but these errors were encountered: