Closed
Description
Using #![no_main]
, and a #[no_mange] pub static main
array the linker will assume that the main array is actually the main function and execute whatever is in there. Outside of a warning for nonstandard naming this compiles fine on stable and nightly on both debug and release mode.
This example will print the text Main is usually a function\n
on x64 linux and probably crash violently on anything else.
It's rather hard to trigger this behavior without trying, but it should probably not compile without errors. Maybe add a check for #![no_main]
crates that whatever's declared as #[no_mangle] main
is actually a function with the correct signature.
Meta
The issue exists on rustc 1.25.0-nightly
, rustc 1.23.0
and anything in between.