2015-02-19 - 'main' is usually a function

Sławek recently sent me an awesome article. it appears that even though 'main' is usually a function, it does not have to be so… :) long story short – linker is expecting to have a non-C++-mangled symbol called main. and that's it. if not a function than what? in fact it can be an array of bytes, which represents an assembly code!

i guess main could also be a single variable, followed by a series of other variables, that represent consecutive instructions (encoded as numbers). just thinking out loud – a beer on me for whoever first finds variables representing series of integers that represent a program, that changes these variables as it executes and executes changed values again1), resulting in another (valid) program changing itself and so on ad infinitum… a sort of fractal code. extra beer if these numbers are floating point! :D

1)
watch out for icache! :P
blog/2015/02/19/main_is_usually_a_function.txt · Last modified: 2021/06/15 20:09 by 127.0.0.1
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0