Why does initialization of local static objects use hidden guard flags?

旧街凉风 提交于 2019-12-01 22:07:08

On most modern operating systems modifying the code loaded with the program causes issues. This can both cause performance issues (Unmodified code can share pages between many instances of a dll on some systems), and security issues (preventing the use of executable space protection technologies).

This sort of "optimization" is not safe in a multithreaded environment, and may not be safe even in a single one.

The writing of "nops" could likely take multiple instructions.

The size of the jmp instruction may not be knowable until the final code is optimized (does it need an 8, 16, or 32 bit offset?)

Instruction caching within the CPU does not pick up on a change in code bytes unless one of a subset of instructions is executed to cause the caches to be flushed.

And all that is assuming the code can be written to via the data segment.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!