3 ms·
int noMain() __attribute__ (constructor); int noMain() { printf("Goodbye, main()"); } // &etc.
by mmjaa 9y ago
int noMain() __attribute__ (constructor);
int noMain() {
printf("Goodbye, main()");
} // &etc.
- dfox 9y agoThis actually would not link, because _start() or something it calls into (depending on implementation of CRT on given platform) would contain unresolved reference to main. (and goven the fact that all this CRT startup code is usually one .o, you cannot just patch out the part that calls main(), you have to replace it completely) On the other hand something around the lines of: void _start(){ write(1, "Hello world\n", 12); exit(0); } should probably work, given that you link it without CRT startup code (ie. gcc -nostdlib)