cprogram-entry-pointentry-point

How to change entry point of C program with gcc?


How to change the entry point of a C program compiled with gcc ?
Just like in the following code

#include<stdio.h>
int entry()  //entry is the entry point instead of main
 {
   return 0;
 }

Solution

  • It's a linker setting:

    -Wl,-eentry
    

    the -Wl,... thing passes arguments to the linker, and the linker takes a -e argument to set the entry function