|
libtcc1.a, the C runtime startup library supplied with TinyCC has two entry points _start and _winstart for console and GUI applications respectively. The compiler emits ELF object files so I decided to translate my own tiny C runtime startup modules to C modules with inline assembly. TinyCC accepts only the AT&T syntax to write inline assembly. Unfortunately, the compiler ignores the __declspec(naked) statement disabling the standard prologue\epilogue code. The solution was to patch the object modules to remove the overhead. Without removing the prologue\epilogue code, I could not terminate the modules with the ExitProcess function. Finally, I was able to eliminate the msvcrt.dll dependency and the size of the demo executable hello_win.exe decreased from 3584 bytes to 3072 bytes :
| CODE | | \tcc\tcc\tcc -ID:\tcc\include\winapi -ID:\tcc\include -L..\lib -lkernel32 -luser32 -lgdi32 hello_win.c ..\crt0ELF\crt0ELF.a -o hello_win.exe |
I could not find a way to use my static library crt0ELF.a with TinyCC. The compiler emits the following error message :
| CODE | \tcc\tcc\tcc -ID:\tcc\include\winapi -ID:\tcc\include -L..\lib -lkernel32 -luser32 -lgdi32 hello_win.c ..\crt0ELF\crt0ELF.a -o hello_win.exe
tcc: undefined symbol '_winstart' |
crt0ELF.a is a static library including the two startup modules for console and GUI applications. I used the librarian ar.exe supplied with the MinGW package to build the static library :
| CODE | | \MinGW\bin\ar rc crt0ELF.a crt0cons.o crt0gui.o |
Is there a way to use static libraries with TinyCC?
Attached File ( Number of downloads: 1 )
tcc_crt0.zip
|