News for hackers. Stuff that matters.
Re:Writing a Self-Mutating x86_64 C Program (2013) by shakna on Friday January 11, 2019 @07:09AM (#18882934)
Any _good_ reason? Probably not.

Any use? ... Yes.

Obfuscation. It might be a terrible practice, but has spawned entire languages, including some that have been used on occasion by industry, as well as the puzzle-solving community at large. (Say, integrate it into a `compile --release` flag.)

Right off the back of obfuscation, DRM. If the code modifies itself, especially in unexpected ways, then breaking it becomes harder. (`compile --protect`?)

Re:Writing a Self-Mutating x86_64 C Program (2013) by JoachimS on Friday January 11, 2019 @09:41AM (#18883830)
A lot of the later demo effects on the c64 is using so called "speedcode" which basically is code generating code on the fly to achieve things like dynamically copying data areas. In effect intelligent loop unrolling i asm.

http://codebase64.org/doku.php?id=base:speedcode

Re:Writing a Self-Mutating x86_64 C Program (2013) by darkmighty on Friday January 11, 2019 @04:46PM (#18887463)
Fascinating! I assume this kind of technique has been obsoleted by branch prediction, or are there imaginable modern applications?
Re:Writing a Self-Mutating x86_64 C Program (2013) by shakna on Friday January 11, 2019 @07:05PM (#18888453)
One of the reasons we needed extremely aggressive unrolling was the size/lack of a stack, making recursion or anything that might look like it difficult/limited/impossible, due to needing to store a location to jump back to.

Anything you could do to minimise the amount of things needed to store, and their size, wasn't wasted time.

And though it might very ocassionally be similarly necessary on some chips today, it's more likely you'll work in assembly on those.