Re:On self-modifying executables in Rust
by interroboink on Tuesday February 01, 2022 @11:39PM
(#30173776)
Some more good discussion here: https://stackoverflow.com/questions/63568992/can-compilers-g...
I guess it's not commonplace these days, but it is still allowed, it seems. I feel like my initial run-in with the concept was on some embedded systems stuff long ago, so maybe that was a more esoteric compiler.
You can see example here: https://godbolt.org/z/7f1qbh5r5
There are no code modifications - all compiler generated is extra byte check ("if" statement) and then acquire/release lock around constructor to be threadsafe.