3 ms·
I think that sets the address of main to NULL, so it segfaults as soon as `_start` jumps to `main`. It's known for being one of the smallest compilable C progra
by vortico 12y ago
I think that sets the address of main to NULL, so it segfaults as soon as `_start` jumps to `main`. It's known for being one of the smallest compilable C programs.
EDIT: Your original post contained
int main=0;
- comex 12y agoNot quite - what matters (normally) is the address of the symbol, not the bytes located there, since in the case of a real function those bytes would be the instructions. So this will either execute the bytes at &main as instructions (4 zero bytes, and whatever follows), or, more likely, crash due to memory protections, as described in the article.
- zwegner 12y agoYup. You can get a working program with the simple: const int main = 0xC3; ...which is just a return. Or you can get fancy and make it exit successfully by clearing eax first: const int main = 0xC3C031;
- firethief 12y agoIn pre-C99 C, that can be shortened to the equivalent: main=0;