WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
Pages (3) [1] 2 3   ( Go to first unread post )

Tiny CC - Tiny C compiler, use it to build extremely small binaries, attached is an example project.

Vortex
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 140
Member No.: 8
Joined: 13-May 04


Hi friends,

Here is an example project created with the Tiny C Compiler. This tool creates very small C executables :

http://fabrice.bellard.free.fr/tcc

Attached File ( Number of downloads: 236 )
 Login or Register to download
PMEmail PosterUsers Website
Top
akyprian
Quote Post


Administrator
******

Group: Admins
Posts: 2307
Member No.: 1
Joined: 12-May 04


Thanks Vortex for sharing
PMEmail PosterUsers Website
Top
Vortex
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 140
Member No.: 8
Joined: 13-May 04


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: 92 )
 Login or Register to download
PMEmail PosterUsers Website
Top
samael
Quote Post


Typo-lord
******

Group: Moderators
Posts: 404
Member No.: 5187
Joined: 10-June 07


Vortex, this may sound dumb as i have never played with Tiny CC, but i thing the __declspec(naked) statement is Microsoft compiler specific. I really don't know if it's supported by Tiny CC.


Also, according to this page, the -B option specifies whether bindings of libraries for linking are static or dynamic.

-B [static|dynamic].

Hope this helps.
PM
Top
Vortex
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 140
Member No.: 8
Joined: 13-May 04


Hi Samael,

Many thanks for your help.

It's true that __declspec(naked) is specific to MS compilers but it's interesting to note that the Tiny C compiler does not display any warning message if a function is declared with __declspec(naked) The compiler ignores the statement.

The Tiny C compiler does not support the -b switch :

CODE
tcc: invalid option -- '-b'
PMEmail PosterUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Pages (3) [1] 2 3  Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google