Pre-RFC: Add language support for global constructor functions

It works on all tier-1 platforms.

As a normal developer, the code you're writing is likely to last a long time; if you're writing a library, you also want other people to be able to take dependencies on you without any issues, even if they're doing something weird. So it's very beneficial to have guarantees: that your code will work even on obscure platforms, that it will continue to work in the face of compiler upgrades, that it won't have broken edge cases (like this one I previously linked).

As an attacker, you mainly care that it works in practice, on a specific target's system, in the short time window of your attack.

If there's no C compiler, the attacker could just ship static library binaries in the crate for whatever platforms they care about – not that there's a reason to do so when the link_section solution above works fine.

Possible, but unlikely, meaning that omitting #[global_constructor] would only make a difference in an edge case, even if not for the many other workarounds.

1 Like