Re:Exploring mullender.c – A deep dive into the first IOCCC ...
by monocasa on Sunday August 30, 2020 @02:48AM
(#24321815)
I think something like this gets disallowed these days as .rodata and .data gets mapped NX.
[ Parent
| on HN ]
Re:Exploring mullender.c – A deep dive into the first IOCCC ...
by ache7 on Sunday August 30, 2020 @04:55AM
(#24322243)
Using compiler hints, data can be placed directly in the code section.
Works on x86/x86_64 Linux:
char main[] __attribute__ ((section(".text"))) = "\xe8\x0d\0\0\0Hello world!\n"
#ifdef __x86_64__
"\x31\xc0\x8d\x50\x0d\xff\xc0\x89\xc7\x5e\x0f\x05\x31\xff\x8d\x47\x3c\x0f\x05";
#else
"\x31\xdb\x8d\x53\x0d\x59\x8d\x43\x04\x43\xcd\x80\x31\xdb\x8d\x43\x01\xcd\x80";
#endif