This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

how to get rid of __main


Hi all,
I discovered an important difference between Linux gcc and Win32 gcc which prevents nlmconv from sucessful linking: on Win32 gcc always puts in __main, not only with C++. I've stopped compilation with -S to see the assembler code:

***** Linux compiled *****

	.file	"hello.c"
	.version	"01.01"
gcc2_compiled.:
.section	.rodata
	.align 32
.LC0:
	.string	"\r*\n Hello World from GCC on Linux platform!\n"
	.align 32
.LC1:
	.string	"\r This NLM is linked with self compiled prelude.obj!\n"
.LC2:
	.string	"\r*\n"
.text
	.align 16
.globl main
	.type	 main,@function
main:
	pushl %ebp
	movl %esp,%ebp
	pushl $.LC0
	call printf
	pushl $.LC1
	call printf
	pushl $.LC2
	call printf
	xorl %eax,%eax
	movl %ebp,%esp
	popl %ebp
	ret
.Lfe1:
	.size	 main,.Lfe1-main
	.ident	"GCC: (GNU) egcs-2.91.60 19981201 (egcs-1.1.1 release)"


***** Win32 compiled *****

	.file	"hello.c"
gcc2_compiled.:
___gnu_compiled_c:
	.def	___main;	.scl	2;	.type	32;	.endef
.text
	.align 32
LC0:
	.ascii "\15*\12 Hello World from GCC on Win32 platform!\12\0"
	.align 32
LC1:
	.ascii "\15This NLM is linked with self compiled prelude.obj!!\12\0"
LC2:
	.ascii "\15*\12\0"
	.align 4
.globl _main
	.def	_main;	.scl	2;	.type	32;	.endef
_main:
	pushl %ebp
	movl %esp,%ebp
	subl $8,%esp
	call ___main
	addl $-12,%esp
	pushl $LC0
	call _printf
	addl $-12,%esp
	pushl $LC1
	call _printf
	addl $32,%esp
	addl $-12,%esp
	pushl $LC2
	call _printf
	movl %ebp,%esp
	xorl %eax,%eax
	popl %ebp
	ret
	.def	_printf;	.scl	2;	.type	32;	.endef

*********
The leading underscore is no problem; objcopy has a switch for removing this:

	objcopy -O elf32-i386 --remove-leading-char $(TARGET).o

so after this the only unresolved symbol is __main ...

Does anybody know how to get rid of this?? Is there a switch which I didnt find yet? Or is it possible to build a Win32 gcc with an additional switch which turns off this behavior?
How can I get the same behavior as on Linux??

greets, Guenter.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]