Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    int noMain()     __attribute__ (constructor);
    int noMain() {
        printf("Goodbye, main()");
    } // &etc.


This 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)


Now for more confusion, have a main function that _start doesn't call.

Now for even more confusion, have the main function (which never runs) call the _start function.


You are evil!


He should be writing some crackmes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: