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; }
An entry point is a location in code where a transfer of program control (execution) occurs. The main function ( main() ) is the entry point to a C/C++ program and is called when the application starts executing. Calls to other functions, for example from the main function, provide entry points to function code.
The memory address at which a program begins executing is called the entry point. When a loader loads a program into target memory, the program counter (PC) must be initialized to the entry point; the PC then points to the beginning of the program. The linker can assign one of four values to the entry point.
The entry point of a program is where it starts executing at the machine code level. That's seldom if ever main ; instead, the entry point function does a few initialization tasks and then, for a C or C++ program, calls main .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With