Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;  } 
like image 878
asitm9 Avatar asked Sep 21 '11 03:09

asitm9


People also ask

Why main () is entry point in C?

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.

What is entry point of C program?

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.

What is the entry point of every C++ program?

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 .


1 Answers

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

like image 122
Foo Bah Avatar answered Sep 19 '22 11:09

Foo Bah