4 ms·
The program entry point is actually _start (which does some setup and later calls main()) so for even more extreme TA befuddlement, write a program that doesn't
by gumby 9y ago
The program entry point is actually _start (which does some setup and later calls main()) so for even more extreme TA befuddlement, write a program that doesn't even call main()!
- mmjaa 9y agoint 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)