From: <no...@so...> - 2002-05-18 17:12:25
|
Bugs item #557700, was opened at 2002-05-18 17:12 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=557700&group_id=2435 Category: gcc Group: None Status: Open Resolution: None Priority: 5 Submitted By: KJK::Hyperion (kjkhyperion) Assigned to: Danny Smith (dannysmith) Summary: -nostartfiles ignored if main() exists Initial Comment: The program, "testfork", is composed by two source files: - crthybrid.c, containing the EXE's (true) entry point: NTSTATUS STDCALL _PdxLdrEntry(PPEB Peb); _PdxLdrEntry() sets up the file descriptors table, environment and parameters (it's a test program for a POSIX-on-NT system), and calls: exit(main(argc, argv, 0)); - testfork.c, containing a standard C main() function: int main(int argc, char ** argv) { /* ... */ } gcc - I../../../include -nostdinc -fno-builtin -I./ - I../../../../../include -pipe -march=i386 -c crthybrid.c -o crthybrid.o gcc -I../../../include -nostdinc -fno-builtin -I./ - I../../../../../include -pipe -march=i386 -c testfork.c -o testfork.o gcc -nostartfiles -Wl,--subsystem,console \ -Wl,-- entry,___PdxLdrEntry@4 \ -o testfork.nostrip.exe \ crthybrid.o testfork.o ../../../../../dk/w32/lib/ntdll.a ../../../../../dk/w32/lib/kernel32.a ../../../lib/psxdll/psxdll.a ../../../../../tools/rdel temp.exp nm --numeric-sort testfork.nostrip.exe > testfork.sym ../../../../../tools/rcopy testfork.nostrip.exe testfork.exe If testfork.c contains a function named main, testfork.exe is 15.7 KB, and it imports MSVCRT!atexit. If the function is named, for example, mymain, testfork.exe is 7.44 KB, and imports only functions I actually use. If I use -nostdlib, that doesn't stop gcc from trying to slip in its static library, but the compilation fails: gcc - I../../../include -nostdinc -fno-builtin -I./ - I../../../../../include -pipe -march=i386 -c crthybrid.c -o crthybrid.o gcc -I../../../include -nostdinc -fno-builtin -I./ - I../../../../../include -pipe -march=i386 -c testfork.c -o testfork.o gcc -nostartfiles -nostdlib -Wl,--subsystem,console \ -Wl,--entry,___PdxLdrEntry@4 \ -o testfork.nostrip.exe \ crthybrid.o testfork.o ../../../../../dk/w32/lib/ntdll.a ../../../../../dk/w32/lib/kernel32.a ../../../lib/psxdll/psxdll.a testfork.o(.text+0x43):testfork.c: undefined reference to `__main' make: *** [testfork.nostrip.exe] Error 1 ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=557700&group_id=2435 |