Hmmm... according to the info for LD, you can use the following is used to determine what the starting point is.
Quote:
File: ld.info, Node: Entry Point, Next: File Commands, Up: Simple Commands
Setting the Entry Point
-----------------------
The first instruction to execute in a program is called the "entry
point". You can use the `ENTRY' linker script command to set the entry
point. The argument is a symbol name:
ENTRY(SYMBOL)
There are several ways to set the entry point. The linker will set
the entry point by trying each of the following methods in order, and
stopping when one of them succeeds:
* the `-e' ENTRY command-line option;
* the `ENTRY(SYMBOL)' command in a linker script;
* the value of the symbol `start', if defined;
* the address of the first byte of the `.text' section, if present;
* The address `0'.
|
However, when I try the following:
Code:
// blah.c
#include <stdio.h>
int MyMain()
{
printf("Hello\n");
return 0;
}
$ gcc -o blah -eMyMain blah.c
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../crt1.o(.text+0x18): In func
tion `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
Or I can get it to compile like so:
Code:
$ gcc -o blah.o -c blah.c
$ ld -o blah blah.o -lc -eMyMain
$ ./blah
-bash: ./blah: No such file or directory
$ ls -l blah
-rwxr-xr-x 1 deiussum users 2040 Mar 1 09:56 blah*
I tried the -mno-crt0 option and got this:
Code:
$ gcc -o blah -eMyMain blah.c -mno-crt0
cc1: invalid option `no-crt0'
So, I'm not sure anymore. VC++ has an option like /entryPoint:SomeEntryPoint, but with Windows programming you often have either a main() or a WinMain() or a DLLMain()...