|
From: KJK::Hyperion <no...@li...> - 2002-05-18 20:40:11
|
At 19.17 18/05/2002, you wrote:
> > testfork.o(.text+0x43):testfork.c: undefined reference to `__main'
> > make: *** [testfork.nostrip.exe] Error 1
>well, you need your custom __main function then.
erm... why exactly? I checked, and it's the damn *compiler* that inserts a
"call ___main" just after the stack frame setup in main():
.file "testmain.c"
gcc2_compiled.:
___gnu_compiled_c:
.def ___main; .scl 2; .type 32; .endef
.text
.align 4
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp,%ebp
subl $8,%esp
call ___main
xorl %eax,%eax
jmp L2
.align 4
L2:
leave
ret
Why the hell does it do this? Why does the compiler try to be smarter than
me? How can I tell the compiler to compile *exactly* what I say, and not
generate useless/superfluous code? Borland C++ doesn't do it, for example:
.386p
ifdef ??version
if ??version GT 500H
.mmx
endif
endif
model flat
ifndef ??version
?debug macro
endm
endif
?debug S "testmain.c"
?debug T "testmain.c"
_TEXT segment dword public use32 'CODE'
_TEXT ends
_DATA segment dword public use32 'DATA'
_DATA ends
_BSS segment dword public use32 'BSS'
_BSS ends
DGROUP group _BSS,_DATA
_TEXT segment dword public use32 'CODE'
_main proc near
?live1@0:
;
; int main(void)
;
push ebp
mov ebp,esp
;
; {
; return (0);
;
@1:
xor eax,eax
;
; }
;
@3:
@2:
pop ebp
ret
_main endp
_TEXT ends
public _main
?debug D "testmain.c" 11442 44081
end
|