source: EcnlProtoTool/trunk/tcc-0.9.27/tcc-doc.html@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/html
File size: 100.0 KB
RevLine 
[331]1<HTML>
2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3<!-- Created on December, 17 2017 by texi2html 1.64 -->
4<!--
5Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
6 Karl Berry <karl@freefriends.org>
7 Olaf Bachmann <obachman@mathematik.uni-kl.de>
8 and many others.
9Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
10Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
11
[279]12-->
[331]13<HEAD>
14<TITLE>Tiny C Compiler Reference Documentation: </TITLE>
[279]15
[331]16<META NAME="description" CONTENT="Tiny C Compiler Reference Documentation: ">
17<META NAME="keywords" CONTENT="Tiny C Compiler Reference Documentation: ">
18<META NAME="resource-type" CONTENT="document">
19<META NAME="distribution" CONTENT="global">
20<META NAME="Generator" CONTENT="texi2html 1.64">
[279]21
[331]22</HEAD>
[279]23
[331]24<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
[279]25
[331]26<A NAME="SEC_Top"></A>
27<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
28<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
29<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
30<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
31<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
32</TR></TABLE>
33<H1>Tiny C Compiler Reference Documentation</H1></P><P>
[279]34
[331]35This manual documents version 0.9.27
36 of the Tiny C Compiler.
37</P><P>
[279]38
[331]39<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
40<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC1">1. Introduction</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Introduction to tcc.</TD></TR>
41<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC2">2. Command line invocation</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Invocation of tcc (command line, options).</TD></TR>
42<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC5">3. C language support</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">ANSI C and extensions.</TD></TR>
43<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC10">4. TinyCC Assembler</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Assembler syntax.</TD></TR>
44<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Output file generation and supported targets.</TD></TR>
45<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Automatic bounds-checking of C code.</TD></TR>
46<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">The libtcc library.</TD></TR>
47<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="tcc-doc.html#SEC23">8. Developer's guide</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Guide for Developers.</TD></TR>
48</TABLE></BLOCKQUOTE>
49<P>
[279]50
[331]51<HR SIZE=1>
52<A NAME="SEC1"></A>
53<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
54<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> &lt; </A>]</TD>
55<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> &gt; </A>]</TD>
56<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
57<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
58<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> &gt;&gt; </A>]</TD>
59<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
60<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
61<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
62<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
63</TR></TABLE>
64<A NAME="Introduction"></A>
65<H1> 1. Introduction </H1>
66<!--docid::SEC1::-->
67<P>
[279]68
[331]69TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C
[279]70compilers, it is meant to be self-relying: you do not need an
71external assembler or linker because TCC does that for you.
[331]72</P><P>
73
74TCC compiles so <EM>fast</EM> that even for big projects <CODE>Makefile</CODE>s may
[279]75not be necessary.
[331]76</P><P>
77
78TCC not only supports ANSI C, but also most of the new ISO C99
[279]79standard and many GNUC extensions including inline assembly.
[331]80</P><P>
81
82TCC can also be used to make <EM>C scripts</EM>, i.e. pieces of C source
[279]83that you run as a Perl or Python script. Compilation is so fast that
84your script will be as fast as if it was an executable.
[331]85</P><P>
86
87TCC can also automatically generate memory and bound checks
88(see section <A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A>) while allowing all C pointers operations. TCC can do
[279]89these checks even if non patched libraries are used.
[331]90</P><P>
[279]91
[331]92With <CODE>libtcc</CODE>, you can use TCC as a backend for dynamic code
93generation (see section <A HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A>).
94</P><P>
[279]95
[331]96TCC mainly supports the i386 target on Linux and Windows. There are alpha
97ports for the ARM (<CODE>arm-tcc</CODE>) and the TMS320C67xx targets
98(<CODE>c67-tcc</CODE>). More information about the ARM port is available at
99<A HREF="http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html">http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html</A>.
100</P><P>
[279]101
[331]102For usage on Windows, see also <A HREF="tcc-win32.txt">tcc-win32.txt</A>.
103</P><P>
104
105<A NAME="Invoke"></A>
106<HR SIZE="6">
107<A NAME="SEC2"></A>
108<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
109<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> &lt; </A>]</TD>
110<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC3"> &gt; </A>]</TD>
111<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &lt;&lt; </A>]</TD>
112<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
113<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &gt;&gt; </A>]</TD>
114<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
115<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
116<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
117<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
118</TR></TABLE>
119<H1> 2. Command line invocation </H1>
120<!--docid::SEC2::-->
121<P>
122
123<HR SIZE="6">
124<A NAME="SEC3"></A>
125<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
126<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> &lt; </A>]</TD>
127<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC4"> &gt; </A>]</TD>
128<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> &lt;&lt; </A>]</TD>
129<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> Up </A>]</TD>
130<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &gt;&gt; </A>]</TD>
131<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
132<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
133<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
134<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
135</TR></TABLE>
136<H2> 2.1 Quick start </H2>
137<!--docid::SEC3::-->
138<P>
139
140<TABLE><tr><td>&nbsp;</td><td class=example><pre>usage: tcc [options] [<VAR>infile1</VAR> <VAR>infile2</VAR><small>...</small>] [<SAMP>`-run'</SAMP> <VAR>infile</VAR> <VAR>args</VAR><small>...</small>]
141</pre></td></tr></table></P><P>
142
143TCC options are a very much like gcc options. The main difference is that TCC
[279]144can also execute directly the resulting program and give it runtime
145arguments.
[331]146</P><P>
[279]147
[331]148Here are some examples to understand the logic:
149</P><P>
[279]150
[331]151<DL COMPACT>
152<DT><CODE><SAMP>`tcc -run a.c'</SAMP></CODE>
153<DD>Compile <TT>`a.c'</TT> and execute it directly
154<P>
155
156<DT><CODE><SAMP>`tcc -run a.c arg1'</SAMP></CODE>
157<DD>Compile a.c and execute it directly. arg1 is given as first argument to
158the <CODE>main()</CODE> of a.c.
159<P>
160
161<DT><CODE><SAMP>`tcc a.c -run b.c arg1'</SAMP></CODE>
162<DD>Compile <TT>`a.c'</TT> and <TT>`b.c'</TT>, link them together and execute them. arg1 is given
163as first argument to the <CODE>main()</CODE> of the resulting program.
164<P>
165
166<DT><CODE><SAMP>`tcc -o myprog a.c b.c'</SAMP></CODE>
167<DD>Compile <TT>`a.c'</TT> and <TT>`b.c'</TT>, link them and generate the executable <TT>`myprog'</TT>.
168<P>
169
170<DT><CODE><SAMP>`tcc -o myprog a.o b.o'</SAMP></CODE>
171<DD>link <TT>`a.o'</TT> and <TT>`b.o'</TT> together and generate the executable <TT>`myprog'</TT>.
172<P>
173
174<DT><CODE><SAMP>`tcc -c a.c'</SAMP></CODE>
175<DD>Compile <TT>`a.c'</TT> and generate object file <TT>`a.o'</TT>.
176<P>
177
178<DT><CODE><SAMP>`tcc -c asmfile.S'</SAMP></CODE>
179<DD>Preprocess with C preprocess and assemble <TT>`asmfile.S'</TT> and generate
180object file <TT>`asmfile.o'</TT>.
181<P>
182
183<DT><CODE><SAMP>`tcc -c asmfile.s'</SAMP></CODE>
184<DD>Assemble (but not preprocess) <TT>`asmfile.s'</TT> and generate object file
185<TT>`asmfile.o'</TT>.
186<P>
187
188<DT><CODE><SAMP>`tcc -r -o ab.o a.c b.c'</SAMP></CODE>
189<DD>Compile <TT>`a.c'</TT> and <TT>`b.c'</TT>, link them together and generate the object file <TT>`ab.o'</TT>.
190<P>
191
192</DL>
193<P>
194
195Scripting:
196</P><P>
197
198TCC can be invoked from <EM>scripts</EM>, just as shell scripts. You just
199need to add <CODE>#!/usr/local/bin/tcc -run</CODE> at the start of your C source:
200</P><P>
201
202<TABLE><tr><td>&nbsp;</td><td class=example><pre>#!/usr/local/bin/tcc -run
203#include &#60;stdio.h&#62;
204
[279]205int main()
206{
[331]207 printf("Hello World\n");
[279]208 return 0;
209}
[331]210</pre></td></tr></table></P><P>
[279]211
[331]212TCC can read C source code from <EM>standard input</EM> when <SAMP>`-'</SAMP> is used in
213place of <SAMP>`infile'</SAMP>. Example:
214</P><P>
[279]215
[331]216<TABLE><tr><td>&nbsp;</td><td class=example><pre>echo 'main(){puts("hello");}' | tcc -run -
217</pre></td></tr></table></P><P>
[279]218
[331]219<HR SIZE="6">
220<A NAME="SEC4"></A>
221<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
222<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC3"> &lt; </A>]</TD>
223<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &gt; </A>]</TD>
224<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> &lt;&lt; </A>]</TD>
225<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> Up </A>]</TD>
226<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &gt;&gt; </A>]</TD>
227<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
228<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
229<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
230<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
231</TR></TABLE>
232<H2> 2.2 Option summary </H2>
233<!--docid::SEC4::-->
234<P>
[279]235
[331]236General Options:
237</P><P>
[279]238
[331]239<DL COMPACT>
240<DT><SAMP>`-c'</SAMP>
241<DD>Generate an object file.
242<P>
243
244<DT><SAMP>`-o outfile'</SAMP>
245<DD>Put object file, executable, or dll into output file <TT>`outfile'</TT>.
246<P>
247
248<DT><SAMP>`-run source [args...]'</SAMP>
249<DD>Compile file <VAR>source</VAR> and run it with the command line arguments
250<VAR>args</VAR>. In order to be able to give more than one argument to a
251script, several TCC options can be given <EM>after</EM> the
252<SAMP>`-run'</SAMP> option, separated by spaces:
253<TABLE><tr><td>&nbsp;</td><td class=example><pre>tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
254</pre></td></tr></table>In a script, it gives the following header:
255<TABLE><tr><td>&nbsp;</td><td class=example><pre>#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
256</pre></td></tr></table><P>
257
258<DT><SAMP>`-v'</SAMP>
259<DD>Display TCC version.
260<P>
261
262<DT><SAMP>`-vv'</SAMP>
263<DD>Show included files. As sole argument, print search dirs. -vvv shows tries too.
264<P>
265
266<DT><SAMP>`-bench'</SAMP>
267<DD>Display compilation statistics.
268<P>
269
270</DL>
271<P>
272
273Preprocessor options:
274</P><P>
275
276<DL COMPACT>
277<DT><SAMP>`-Idir'</SAMP>
278<DD>Specify an additional include path. Include paths are searched in the
[279]279order they are specified.
[331]280<P>
[279]281
[331]282System include paths are always searched after. The default system
283include paths are: <TT>`/usr/local/include'</TT>, <TT>`/usr/include'</TT>
284and <TT>`PREFIX/lib/tcc/include'</TT>. (<TT>`PREFIX'</TT> is usually
285<TT>`/usr'</TT> or <TT>`/usr/local'</TT>).
286</P><P>
[279]287
[331]288<DT><SAMP>`-Dsym[=val]'</SAMP>
289<DD>Define preprocessor symbol <SAMP>`sym'</SAMP> to
290val. If val is not present, its value is <SAMP>`1'</SAMP>. Function-like macros can
291also be defined: <SAMP>`-DF(a)=a+1'</SAMP>
292<P>
[279]293
[331]294<DT><SAMP>`-Usym'</SAMP>
295<DD>Undefine preprocessor symbol <SAMP>`sym'</SAMP>.
296<P>
[279]297
[331]298<DT><SAMP>`-E'</SAMP>
299<DD>Preprocess only, to stdout or file (with -o).
300<P>
301
302</DL>
303<P>
304
305Compilation flags:
306</P><P>
307
308Note: each of the following options has a negative form beginning with
309<SAMP>`-fno-'</SAMP>.
310</P><P>
311
312<DL COMPACT>
313<DT><SAMP>`-funsigned-char'</SAMP>
314<DD>Let the <CODE>char</CODE> type be unsigned.
315<P>
316
317<DT><SAMP>`-fsigned-char'</SAMP>
318<DD>Let the <CODE>char</CODE> type be signed.
319<P>
320
321<DT><SAMP>`-fno-common'</SAMP>
322<DD>Do not generate common symbols for uninitialized data.
323<P>
324
325<DT><SAMP>`-fleading-underscore'</SAMP>
326<DD>Add a leading underscore at the beginning of each C symbol.
327<P>
328
329<DT><SAMP>`-fms-extensions'</SAMP>
330<DD>Allow a MS C compiler extensions to the language. Currently this
331assumes a nested named structure declaration without an identifier
332behaves like an unnamed one.
333<P>
334
335<DT><SAMP>`-fdollars-in-identifiers'</SAMP>
336<DD>Allow dollar signs in identifiers
337<P>
338
339</DL>
340<P>
341
342Warning options:
343</P><P>
344
345<DL COMPACT>
346<DT><SAMP>`-w'</SAMP>
347<DD>Disable all warnings.
348<P>
349
350</DL>
351<P>
352
353Note: each of the following warning options has a negative form beginning with
354<SAMP>`-Wno-'</SAMP>.
355</P><P>
356
357<DL COMPACT>
358<DT><SAMP>`-Wimplicit-function-declaration'</SAMP>
359<DD>Warn about implicit function declaration.
360<P>
361
362<DT><SAMP>`-Wunsupported'</SAMP>
363<DD>Warn about unsupported GCC features that are ignored by TCC.
364<P>
365
366<DT><SAMP>`-Wwrite-strings'</SAMP>
367<DD>Make string constants be of type <CODE>const char *</CODE> instead of <CODE>char
368*</CODE>.
369<P>
370
371<DT><SAMP>`-Werror'</SAMP>
372<DD>Abort compilation if warnings are issued.
373<P>
374
375<DT><SAMP>`-Wall'</SAMP>
376<DD>Activate all warnings, except <SAMP>`-Werror'</SAMP>, <SAMP>`-Wunusupported'</SAMP> and
377<SAMP>`-Wwrite-strings'</SAMP>.
378<P>
379
380</DL>
381<P>
382
383Linker options:
384</P><P>
385
386<DL COMPACT>
387<DT><SAMP>`-Ldir'</SAMP>
388<DD>Specify an additional static library path for the <SAMP>`-l'</SAMP> option. The
389default library paths are <TT>`/usr/local/lib'</TT>, <TT>`/usr/lib'</TT> and <TT>`/lib'</TT>.
390<P>
391
392<DT><SAMP>`-lxxx'</SAMP>
393<DD>Link your program with dynamic library libxxx.so or static library
[279]394libxxx.a. The library is searched in the paths specified by the
[331]395<SAMP>`-L'</SAMP> option and <CODE>LIBRARY_PATH</CODE> variable.
396<P>
397
398<DT><SAMP>`-Bdir'</SAMP>
399<DD>Set the path where the tcc internal libraries (and include files) can be
400found (default is <TT>`PREFIX/lib/tcc'</TT>).
401<P>
402
403<DT><SAMP>`-shared'</SAMP>
404<DD>Generate a shared library instead of an executable.
405<P>
406
407<DT><SAMP>`-soname name'</SAMP>
408<DD>set name for shared library to be used at runtime
409<P>
410
411<DT><SAMP>`-static'</SAMP>
412<DD>Generate a statically linked executable (default is a shared linked
[279]413executable).
[331]414<P>
[279]415
[331]416<DT><SAMP>`-rdynamic'</SAMP>
417<DD>Export global symbols to the dynamic linker. It is useful when a library
418opened with <CODE>dlopen()</CODE> needs to access executable symbols.
419<P>
[279]420
[331]421<DT><SAMP>`-r'</SAMP>
422<DD>Generate an object file combining all input files.
423<P>
424
425<DT><SAMP>`-Wl,-rpath=path'</SAMP>
426<DD>Put custom search path for dynamic libraries into executable.
427<P>
428
429<DT><SAMP>`-Wl,--enable-new-dtags'</SAMP>
430<DD>When putting a custom search path for dynamic libraries into the executable,
431create the new ELF dynamic tag DT_RUNPATH instead of the old legacy DT_RPATH.
432<P>
433
434<DT><SAMP>`-Wl,--oformat=fmt'</SAMP>
435<DD>Use <VAR>fmt</VAR> as output format. The supported output formats are:
436<DL COMPACT>
437<DT><CODE>elf32-i386</CODE>
438<DD>ELF output format (default)
439<DT><CODE>binary</CODE>
440<DD>Binary image (only for executable output)
441<DT><CODE>coff</CODE>
442<DD>COFF output format (only for executable output for TMS320C67xx target)
443</DL>
444<P>
445
446<DT><SAMP>`-Wl,-subsystem=console/gui/wince/...'</SAMP>
447<DD>Set type for PE (Windows) executables.
448<P>
449
450<DT><SAMP>`-Wl,-[Ttext=# | section-alignment=# | file-alignment=# | image-base=# | stack=#]'</SAMP>
451<DD>Modify executable layout.
452<P>
453
454<DT><SAMP>`-Wl,-Bsymbolic'</SAMP>
455<DD>Set DT_SYMBOLIC tag.
456<P>
457
458<DT><SAMP>`-Wl,-(no-)whole-archive'</SAMP>
459<DD>Turn on/off linking of all objects in archives.
460<P>
461
462</DL>
463<P>
464
465Debugger options:
466</P><P>
467
468<DL COMPACT>
469<DT><SAMP>`-g'</SAMP>
470<DD>Generate run time debug information so that you get clear run time
471error messages: <CODE> test.c:68: in function 'test5()': dereferencing
472invalid pointer</CODE> instead of the laconic <CODE>Segmentation
473fault</CODE>.
474<P>
475
476<DT><SAMP>`-b'</SAMP>
477<DD>Generate additional support code to check
478memory allocations and array/pointer bounds. <SAMP>`-g'</SAMP> is implied. Note
[279]479that the generated code is slower and bigger in this case.
[331]480<P>
[279]481
[331]482Note: <SAMP>`-b'</SAMP> is only available on i386 when using libtcc for the moment.
483</P><P>
[279]484
[331]485<DT><SAMP>`-bt N'</SAMP>
486<DD>Display N callers in stack traces. This is useful with <SAMP>`-g'</SAMP> or
487<SAMP>`-b'</SAMP>.
488<P>
489
490</DL>
491<P>
492
493Misc options:
494</P><P>
495
496<DL COMPACT>
497<DT><SAMP>`-MD'</SAMP>
498<DD>Generate makefile fragment with dependencies.
499<P>
500
501<DT><SAMP>`-MF depfile'</SAMP>
502<DD>Use <TT>`depfile'</TT> as output for -MD.
503<P>
504
505<DT><SAMP>`-print-search-dirs'</SAMP>
506<DD>Print the configured installation directory and a list of library
507and include directories tcc will search.
508<P>
509
510<DT><SAMP>`-dumpversion'</SAMP>
511<DD>Print version.
512<P>
513
514</DL>
515<P>
516
517Target specific options:
518</P><P>
519
520<DL COMPACT>
521<DT><SAMP>`-mms-bitfields'</SAMP>
522<DD>Use an algorithm for bitfield alignment consistent with MSVC. Default is
523gcc's algorithm.
524<P>
525
526<DT><SAMP>`-mfloat-abi (ARM only)'</SAMP>
527<DD>Select the float ABI. Possible values: <CODE>softfp</CODE> and <CODE>hard</CODE>
528<P>
529
530<DT><SAMP>`-mno-sse'</SAMP>
531<DD>Do not use sse registers on x86_64
532<P>
533
534<DT><SAMP>`-m32, -m64'</SAMP>
535<DD>Pass command line to the i386/x86_64 cross compiler.
536<P>
537
538</DL>
539<P>
540
541Note: GCC options <SAMP>`-Ox'</SAMP>, <SAMP>`-fx'</SAMP> and <SAMP>`-mx'</SAMP> are
[279]542ignored.
[331]543</P><P>
[279]544
[331]545Environment variables that affect how tcc operates.
546</P><P>
[279]547
[331]548<DL COMPACT>
[279]549
[331]550<DT><SAMP>`CPATH'</SAMP>
551<DD><DT><SAMP>`C_INCLUDE_PATH'</SAMP>
552<DD>A colon-separated list of directories searched for include files,
553directories given with <SAMP>`-I'</SAMP> are searched first.
554<P>
[279]555
[331]556<DT><SAMP>`LIBRARY_PATH'</SAMP>
557<DD>A colon-separated list of directories searched for libraries for the
558<SAMP>`-l'</SAMP> option, directories given with <SAMP>`-L'</SAMP> are searched first.
559<P>
[279]560
[331]561</DL>
562<P>
[279]563
[331]564<A NAME="Clang"></A>
565<HR SIZE="6">
566<A NAME="SEC5"></A>
567<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
568<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC4"> &lt; </A>]</TD>
569<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC6"> &gt; </A>]</TD>
570<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &lt;&lt; </A>]</TD>
571<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
572<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &gt;&gt; </A>]</TD>
573<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
574<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
575<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
576<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
577</TR></TABLE>
578<H1> 3. C language support </H1>
579<!--docid::SEC5::-->
580<P>
581
582<HR SIZE="6">
583<A NAME="SEC6"></A>
584<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
585<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &lt; </A>]</TD>
586<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC7"> &gt; </A>]</TD>
587<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &lt;&lt; </A>]</TD>
588<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> Up </A>]</TD>
589<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &gt;&gt; </A>]</TD>
590<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
591<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
592<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
593<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
594</TR></TABLE>
595<H2> 3.1 ANSI C </H2>
596<!--docid::SEC6::-->
597<P>
598
599TCC implements all the ANSI C standard, including structure bit fields
600and floating point numbers (<CODE>long double</CODE>, <CODE>double</CODE>, and
601<CODE>float</CODE> fully supported).
602</P><P>
603
604<HR SIZE="6">
605<A NAME="SEC7"></A>
606<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
607<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC6"> &lt; </A>]</TD>
608<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC8"> &gt; </A>]</TD>
609<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC8"> &lt;&lt; </A>]</TD>
610<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> Up </A>]</TD>
611<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &gt;&gt; </A>]</TD>
612<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
613<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
614<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
615<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
616</TR></TABLE>
617<H2> 3.2 ISOC99 extensions </H2>
618<!--docid::SEC7::-->
619<P>
620
621TCC implements many features of the new C standard: ISO C99. Currently
622missing items are: complex and imaginary numbers.
623</P><P>
624
625Currently implemented ISOC99 features:
626</P><P>
627
628<UL>
629
630<LI>variable length arrays.
631<P>
632
633<LI>64 bit <CODE>long long</CODE> types are fully supported.
634<P>
635
636<LI>The boolean type <CODE>_Bool</CODE> is supported.
637<P>
638
639<LI><CODE>__func__</CODE> is a string variable containing the current
[279]640function name.
[331]641<P>
[279]642
[331]643<LI>Variadic macros: <CODE>__VA_ARGS__</CODE> can be used for
[279]644 function-like macros:
[331]645<TABLE><tr><td>&nbsp;</td><td class=example><pre> #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__)
646</pre></td></tr></table><P>
[279]647
[331]648<CODE>dprintf</CODE> can then be used with a variable number of parameters.
649</P><P>
[279]650
[331]651<LI>Declarations can appear anywhere in a block (as in C++).
652<P>
653
654<LI>Array and struct/union elements can be initialized in any order by
[279]655 using designators:
[331]656<TABLE><tr><td>&nbsp;</td><td class=example><pre> struct { int x, y; } st[10] = { [0].x = 1, [0].y = 2 };
[279]657
658 int tab[10] = { 1, 2, [5] = 5, [9] = 9};
[331]659</pre></td></tr></table>
660<LI>Compound initializers are supported:
661<TABLE><tr><td>&nbsp;</td><td class=example><pre> int *p = (int []){ 1, 2, 3 };
662</pre></td></tr></table>to initialize a pointer pointing to an initialized array. The same
[279]663works for structures and strings.
[331]664<P>
[279]665
[331]666<LI>Hexadecimal floating point constants are supported:
667<TABLE><tr><td>&nbsp;</td><td class=example><pre> double d = 0x1234p10;
668</pre></td></tr></table><P>
[279]669
[331]670is the same as writing
671<TABLE><tr><td>&nbsp;</td><td class=example><pre> double d = 4771840.0;
672</pre></td></tr></table></P><P>
[279]673
[331]674<LI><CODE>inline</CODE> keyword is ignored.
675<P>
[279]676
[331]677<LI><CODE>restrict</CODE> keyword is ignored.
678</UL>
679<P>
[279]680
[331]681<HR SIZE="6">
682<A NAME="SEC8"></A>
683<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
684<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC7"> &lt; </A>]</TD>
685<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC9"> &gt; </A>]</TD>
686<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC9"> &lt;&lt; </A>]</TD>
687<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> Up </A>]</TD>
688<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &gt;&gt; </A>]</TD>
689<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
690<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
691<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
692<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
693</TR></TABLE>
694<H2> 3.3 GNU C extensions </H2>
695<!--docid::SEC8::-->
696<P>
[279]697
[331]698TCC implements some GNU C extensions:
699</P><P>
[279]700
[331]701<UL>
[279]702
[331]703<LI>array designators can be used without '=':
704<TABLE><tr><td>&nbsp;</td><td class=example><pre> int a[10] = { [0] 1, [5] 2, 3, 4 };
705</pre></td></tr></table><P>
706
707<LI>Structure field designators can be a label:
708<TABLE><tr><td>&nbsp;</td><td class=example><pre> struct { int x, y; } st = { x: 1, y: 1};
709</pre></td></tr></table>instead of
710<TABLE><tr><td>&nbsp;</td><td class=example><pre> struct { int x, y; } st = { .x = 1, .y = 1};
711</pre></td></tr></table><P>
712
713<LI><CODE>\e</CODE> is ASCII character 27.
714<P>
715
716<LI>case ranges : ranges can be used in <CODE>case</CODE>s:
717<TABLE><tr><td>&nbsp;</td><td class=example><pre> switch(a) {
718 case 1 <small>...</small> 9:
719 printf("range 1 to 9\n");
[279]720 break;
721 default:
[331]722 printf("unexpected\n");
[279]723 break;
724 }
[331]725</pre></td></tr></table><P>
[279]726
[331]727<A NAME="IDX1"></A>
728<A NAME="IDX2"></A>
729<A NAME="IDX3"></A>
730<A NAME="IDX4"></A>
731<A NAME="IDX5"></A>
732<A NAME="IDX6"></A>
733<A NAME="IDX7"></A>
734<A NAME="IDX8"></A>
735</P><P>
[279]736
[331]737<LI>The keyword <CODE>__attribute__</CODE> is handled to specify variable or
[279]738function attributes. The following attributes are supported:
[331]739<UL>
740
741<LI><CODE>aligned(n)</CODE>: align a variable or a structure field to n bytes
[279]742(must be a power of two).
[331]743<P>
[279]744
[331]745<LI><CODE>packed</CODE>: force alignment of a variable or a structure field to
[279]746 1.
[331]747<P>
[279]748
[331]749<LI><CODE>section(name)</CODE>: generate function or data in assembly section
[279]750name (name is a string containing the section name) instead of the default
751section.
[331]752<P>
[279]753
[331]754<LI><CODE>unused</CODE>: specify that the variable or the function is unused.
755<P>
[279]756
[331]757<LI><CODE>cdecl</CODE>: use standard C calling convention (default).
758<P>
[279]759
[331]760<LI><CODE>stdcall</CODE>: use Pascal-like calling convention.
761<P>
[279]762
[331]763<LI><CODE>regparm(n)</CODE>: use fast i386 calling convention. <VAR>n</VAR> must be
764between 1 and 3. The first <VAR>n</VAR> function parameters are respectively put in
765registers <CODE>%eax</CODE>, <CODE>%edx</CODE> and <CODE>%ecx</CODE>.
766<P>
[279]767
[331]768<LI><CODE>dllexport</CODE>: export function from dll/executable (win32 only)
769<P>
[279]770
[331]771</UL>
772<P>
[279]773
[331]774Here are some examples:
775<TABLE><tr><td>&nbsp;</td><td class=example><pre> int a __attribute__ ((aligned(8), section(".mysection")));
776</pre></td></tr></table></P><P>
[279]777
[331]778align variable <CODE>a</CODE> to 8 bytes and put it in section <CODE>.mysection</CODE>.
779</P><P>
780
781<TABLE><tr><td>&nbsp;</td><td class=example><pre> int my_add(int a, int b) __attribute__ ((section(".mycodesection")))
[279]782 {
783 return a + b;
784 }
[331]785</pre></td></tr></table></P><P>
[279]786
[331]787generate function <CODE>my_add</CODE> in section <CODE>.mycodesection</CODE>.
788</P><P>
[279]789
[331]790<LI>GNU style variadic macros:
791<TABLE><tr><td>&nbsp;</td><td class=example><pre> #define dprintf(fmt, args<small>...</small>) printf(fmt, ## args)
[279]792
[331]793 dprintf("no arg\n");
794 dprintf("one arg %d\n", 1);
795</pre></td></tr></table><P>
796
797<LI><CODE>__FUNCTION__</CODE> is interpreted as C99 <CODE>__func__</CODE>
[279]798(so it has not exactly the same semantics as string literal GNUC
799where it is a string literal).
[331]800<P>
[279]801
[331]802<LI>The <CODE>__alignof__</CODE> keyword can be used as <CODE>sizeof</CODE>
[279]803to get the alignment of a type or an expression.
[331]804<P>
[279]805
[331]806<LI>The <CODE>typeof(x)</CODE> returns the type of <CODE>x</CODE>.
807<CODE>x</CODE> is an expression or a type.
808<P>
[279]809
[331]810<LI>Computed gotos: <CODE>&#38;&#38;label</CODE> returns a pointer of type
811<CODE>void *</CODE> on the goto label <CODE>label</CODE>. <CODE>goto *expr</CODE> can be
812used to jump on the pointer resulting from <CODE>expr</CODE>.
813<P>
[279]814
[331]815<LI>Inline assembly with asm instruction:
816<A NAME="IDX9"></A>
817<A NAME="IDX10"></A>
818<A NAME="IDX11"></A>
819<TABLE><tr><td>&nbsp;</td><td class=example><pre>static inline void * my_memcpy(void * to, const void * from, size_t n)
[279]820{
821int d0, d1, d2;
822__asm__ __volatile__(
[331]823 "rep ; movsl\n\t"
824 "testb $2,%b4\n\t"
825 "je 1f\n\t"
826 "movsw\n"
827 "1:\ttestb $1,%b4\n\t"
828 "je 2f\n\t"
829 "movsb\n"
830 "2:"
831 : "=&c" (d0), "=&#38;D" (d1), "=&#38;S" (d2)
832 :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
833 : "memory");
[279]834return (to);
835}
[331]836</pre></td></tr></table><P>
[279]837
[331]838<A NAME="IDX12"></A>
839TCC includes its own x86 inline assembler with a <CODE>gas</CODE>-like (GNU
[279]840assembler) syntax. No intermediate files are generated. GCC 3.x named
841operands are supported.
[331]842</P><P>
843
844<LI><CODE>__builtin_types_compatible_p()</CODE> and <CODE>__builtin_constant_p()</CODE>
[279]845are supported.
[331]846<P>
[279]847
[331]848<LI><CODE>#pragma pack</CODE> is supported for win32 compatibility.
849<P>
[279]850
[331]851</UL>
852<P>
[279]853
[331]854<HR SIZE="6">
855<A NAME="SEC9"></A>
856<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
857<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC8"> &lt; </A>]</TD>
858<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &gt; </A>]</TD>
859<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &lt;&lt; </A>]</TD>
860<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> Up </A>]</TD>
861<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &gt;&gt; </A>]</TD>
862<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
863<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
864<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
865<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
866</TR></TABLE>
867<H2> 3.4 TinyCC extensions </H2>
868<!--docid::SEC9::-->
869<P>
[279]870
[331]871<UL>
[279]872
[331]873<LI><CODE>__TINYC__</CODE> is a predefined macro to indicate that you use TCC.
874<P>
[279]875
[331]876<LI><CODE>#!</CODE> at the start of a line is ignored to allow scripting.
877<P>
[279]878
[331]879<LI>Binary digits can be entered (<CODE>0b101</CODE> instead of
880<CODE>5</CODE>).
881<P>
[279]882
[331]883<LI><CODE>__BOUNDS_CHECKING_ON</CODE> is defined if bound checking is activated.
884<P>
[279]885
[331]886</UL>
887<P>
[279]888
[331]889<A NAME="asm"></A>
890<HR SIZE="6">
891<A NAME="SEC10"></A>
892<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
893<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC9"> &lt; </A>]</TD>
894<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC11"> &gt; </A>]</TD>
895<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &lt;&lt; </A>]</TD>
896<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
897<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &gt;&gt; </A>]</TD>
898<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
899<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
900<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
901<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
902</TR></TABLE>
903<H1> 4. TinyCC Assembler </H1>
904<!--docid::SEC10::-->
905<P>
906
907Since version 0.9.16, TinyCC integrates its own assembler. TinyCC
[279]908assembler supports a gas-like syntax (GNU assembler). You can
[331]909deactivate assembler support if you want a smaller TinyCC executable
[279]910(the C compiler does not rely on the assembler).
[331]911</P><P>
[279]912
[331]913TinyCC Assembler is used to handle files with <TT>`.S'</TT> (C
914preprocessed assembler) and <TT>`.s'</TT> extensions. It is also used to
915handle the GNU inline assembler with the <CODE>asm</CODE> keyword.
916</P><P>
917
918<HR SIZE="6">
919<A NAME="SEC11"></A>
920<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
921<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &lt; </A>]</TD>
922<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC12"> &gt; </A>]</TD>
923<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &lt;&lt; </A>]</TD>
924<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
925<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &gt;&gt; </A>]</TD>
926<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
927<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
928<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
929<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
930</TR></TABLE>
931<H2> 4.1 Syntax </H2>
932<!--docid::SEC11::-->
933<P>
934
935TinyCC Assembler supports most of the gas syntax. The tokens are the
[279]936same as C.
[331]937</P><P>
[279]938
[331]939<UL>
[279]940
[331]941<LI>C and C++ comments are supported.
942<P>
[279]943
[331]944<LI>Identifiers are the same as C, so you cannot use '.' or '$'.
945<P>
[279]946
[331]947<LI>Only 32 bit integer numbers are supported.
948<P>
[279]949
[331]950</UL>
951<P>
[279]952
[331]953<HR SIZE="6">
954<A NAME="SEC12"></A>
955<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
956<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC11"> &lt; </A>]</TD>
957<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC13"> &gt; </A>]</TD>
958<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC13"> &lt;&lt; </A>]</TD>
959<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
960<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &gt;&gt; </A>]</TD>
961<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
962<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
963<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
964<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
965</TR></TABLE>
966<H2> 4.2 Expressions </H2>
967<!--docid::SEC12::-->
968<P>
[279]969
[331]970<UL>
[279]971
[331]972<LI>Integers in decimal, octal and hexa are supported.
973<P>
[279]974
[331]975<LI>Unary operators: +, -, ~.
976<P>
977
978<LI>Binary operators in decreasing priority order:
979<P>
980
981<OL>
982<LI>*, /, %
983<LI>&#38;, |, ^
984<LI>+, -
985</OL>
986<P>
987
988<LI>A value is either an absolute number or a label plus an offset.
989All operators accept absolute values except '+' and '-'. '+' or '-' can be
990used to add an offset to a label. '-' supports two labels only if they
[279]991are the same or if they are both defined and in the same section.
[331]992<P>
[279]993
[331]994</UL>
995<P>
[279]996
[331]997<HR SIZE="6">
998<A NAME="SEC13"></A>
999<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1000<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC12"> &lt; </A>]</TD>
1001<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC14"> &gt; </A>]</TD>
1002<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC14"> &lt;&lt; </A>]</TD>
1003<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
1004<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &gt;&gt; </A>]</TD>
1005<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1006<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1007<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1008<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1009</TR></TABLE>
1010<H2> 4.3 Labels </H2>
1011<!--docid::SEC13::-->
1012<P>
[279]1013
[331]1014<UL>
[279]1015
[331]1016<LI>All labels are considered as local, except undefined ones.
1017<P>
[279]1018
[331]1019<LI>Numeric labels can be used as local <CODE>gas</CODE>-like labels.
1020They can be defined several times in the same source. Use 'b'
1021(backward) or 'f' (forward) as suffix to reference them:
1022<P>
1023
1024<TABLE><tr><td>&nbsp;</td><td class=example><pre> 1:
[279]1025 jmp 1b /* jump to '1' label before */
1026 jmp 1f /* jump to '1' label after */
1027 1:
[331]1028</pre></td></tr></table></P><P>
[279]1029
[331]1030</UL>
1031<P>
[279]1032
[331]1033<HR SIZE="6">
1034<A NAME="SEC14"></A>
1035<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1036<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC13"> &lt; </A>]</TD>
1037<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC15"> &gt; </A>]</TD>
1038<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC15"> &lt;&lt; </A>]</TD>
1039<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
1040<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &gt;&gt; </A>]</TD>
1041<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1042<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1043<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1044<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1045</TR></TABLE>
1046<H2> 4.4 Directives </H2>
1047<!--docid::SEC14::-->
1048<P>
[279]1049
[331]1050All directives are preceded by a '.'. The following directives are
[279]1051supported:
[331]1052</P><P>
[279]1053
[331]1054<UL>
1055<LI>.align n[,value]
1056<LI>.skip n[,value]
1057<LI>.space n[,value]
1058<LI>.byte value1[,...]
1059<LI>.word value1[,...]
1060<LI>.short value1[,...]
1061<LI>.int value1[,...]
1062<LI>.long value1[,...]
1063<LI>.quad immediate_value1[,...]
1064<LI>.globl symbol
1065<LI>.global symbol
1066<LI>.section section
1067<LI>.text
1068<LI>.data
1069<LI>.bss
1070<LI>.fill repeat[,size[,value]]
1071<LI>.org n
1072<LI>.previous
1073<LI>.string string[,...]
1074<LI>.asciz string[,...]
1075<LI>.ascii string[,...]
1076</UL>
1077<P>
[279]1078
[331]1079<HR SIZE="6">
1080<A NAME="SEC15"></A>
1081<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1082<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC14"> &lt; </A>]</TD>
1083<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &gt; </A>]</TD>
1084<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &lt;&lt; </A>]</TD>
1085<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> Up </A>]</TD>
1086<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &gt;&gt; </A>]</TD>
1087<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1088<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1089<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1090<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1091</TR></TABLE>
1092<H2> 4.5 X86 Assembler </H2>
1093<!--docid::SEC15::-->
1094<P>
1095
1096All X86 opcodes are supported. Only ATT syntax is supported (source
[279]1097then destination operand order). If no size suffix is given, TinyCC
1098tries to guess it from the operand sizes.
[331]1099</P><P>
[279]1100
[331]1101Currently, MMX opcodes are supported but not SSE ones.
1102</P><P>
[279]1103
[331]1104<A NAME="linker"></A>
1105<HR SIZE="6">
1106<A NAME="SEC16"></A>
1107<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1108<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC15"> &lt; </A>]</TD>
1109<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC17"> &gt; </A>]</TD>
1110<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &lt;&lt; </A>]</TD>
1111<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
1112<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &gt;&gt; </A>]</TD>
1113<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1114<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1115<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1116<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1117</TR></TABLE>
1118<H1> 5. TinyCC Linker </H1>
1119<!--docid::SEC16::-->
1120<P>
1121
1122<HR SIZE="6">
1123<A NAME="SEC17"></A>
1124<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1125<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &lt; </A>]</TD>
1126<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC18"> &gt; </A>]</TD>
1127<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &lt;&lt; </A>]</TD>
1128<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> Up </A>]</TD>
1129<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &gt;&gt; </A>]</TD>
1130<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1131<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1132<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1133<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1134</TR></TABLE>
1135<H2> 5.1 ELF file generation </H2>
1136<!--docid::SEC17::-->
1137<P>
1138
1139TCC can directly output relocatable ELF files (object files),
[279]1140executable ELF files and dynamic ELF libraries without relying on an
1141external linker.
[331]1142</P><P>
1143
1144Dynamic ELF libraries can be output but the C compiler does not generate
[279]1145position independent code (PIC). It means that the dynamic library
1146code generated by TCC cannot be factorized among processes yet.
[331]1147</P><P>
1148
1149TCC linker eliminates unreferenced object code in libraries. A single pass is
[279]1150done on the object and library list, so the order in which object files and
1151libraries are specified is important (same constraint as GNU ld). No grouping
[331]1152options (<SAMP>`--start-group'</SAMP> and <SAMP>`--end-group'</SAMP>) are supported.
1153</P><P>
[279]1154
[331]1155<HR SIZE="6">
1156<A NAME="SEC18"></A>
1157<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1158<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC17"> &lt; </A>]</TD>
1159<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC19"> &gt; </A>]</TD>
1160<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC19"> &lt;&lt; </A>]</TD>
1161<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> Up </A>]</TD>
1162<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &gt;&gt; </A>]</TD>
1163<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1164<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1165<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1166<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1167</TR></TABLE>
1168<H2> 5.2 ELF file loader </H2>
1169<!--docid::SEC18::-->
1170<P>
1171
1172TCC can load ELF object files, archives (.a files) and dynamic
[279]1173libraries (.so).
[331]1174</P><P>
[279]1175
[331]1176<HR SIZE="6">
1177<A NAME="SEC19"></A>
1178<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1179<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC18"> &lt; </A>]</TD>
1180<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC20"> &gt; </A>]</TD>
1181<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC20"> &lt;&lt; </A>]</TD>
1182<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> Up </A>]</TD>
1183<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &gt;&gt; </A>]</TD>
1184<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1185<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1186<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1187<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1188</TR></TABLE>
1189<H2> 5.3 PE-i386 file generation </H2>
1190<!--docid::SEC19::-->
1191<P>
1192
1193TCC for Windows supports the native Win32 executable file format (PE-i386). It
[279]1194generates EXE files (console and gui) and DLL files.
[331]1195</P><P>
[279]1196
[331]1197For usage on Windows, see also tcc-win32.txt.
1198</P><P>
1199
1200<HR SIZE="6">
1201<A NAME="SEC20"></A>
1202<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1203<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC19"> &lt; </A>]</TD>
1204<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &gt; </A>]</TD>
1205<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &lt;&lt; </A>]</TD>
1206<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> Up </A>]</TD>
1207<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &gt;&gt; </A>]</TD>
1208<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1209<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1210<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1211<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1212</TR></TABLE>
1213<H2> 5.4 GNU Linker Scripts </H2>
1214<!--docid::SEC20::-->
1215<P>
1216
1217Because on many Linux systems some dynamic libraries (such as
1218<TT>`/usr/lib/libc.so'</TT>) are in fact GNU ld link scripts (horrible!),
[279]1219the TCC linker also supports a subset of GNU ld scripts.
[331]1220</P><P>
1221
1222The <CODE>GROUP</CODE> and <CODE>FILE</CODE> commands are supported. <CODE>OUTPUT_FORMAT</CODE>
1223and <CODE>TARGET</CODE> are ignored.
1224</P><P>
1225
1226Example from <TT>`/usr/lib/libc.so'</TT>:
1227<TABLE><tr><td>&nbsp;</td><td class=example><pre>/* GNU ld script
[279]1228 Use the shared library, but some functions are only in
1229 the static library, so try that secondarily. */
1230GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )
[331]1231</pre></td></tr></table></P><P>
[279]1232
[331]1233<A NAME="Bounds"></A>
1234<HR SIZE="6">
1235<A NAME="SEC21"></A>
1236<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1237<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC20"> &lt; </A>]</TD>
1238<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> &gt; </A>]</TD>
1239<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> &lt;&lt; </A>]</TD>
1240<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
1241<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> &gt;&gt; </A>]</TD>
1242<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1243<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1244<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1245<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1246</TR></TABLE>
1247<H1> 6. TinyCC Memory and Bound checks </H1>
1248<!--docid::SEC21::-->
1249<P>
[279]1250
[331]1251This feature is activated with the <SAMP>`-b'</SAMP> (see section <A HREF="tcc-doc.html#SEC2">2. Command line invocation</A>).
1252</P><P>
1253
1254Note that pointer size is <EM>unchanged</EM> and that code generated
1255with bound checks is <EM>fully compatible</EM> with unchecked
[279]1256code. When a pointer comes from unchecked code, it is assumed to be
1257valid. Even very obscure C code with casts should work correctly.
[331]1258</P><P>
1259
1260For more information about the ideas behind this method, see
1261<A HREF="http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html">http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html</A>.
1262</P><P>
1263
1264Here are some examples of caught errors:
1265</P><P>
1266
1267<DL COMPACT>
1268
1269<DT>Invalid range with standard string function:
1270<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
[279]1271 char tab[10];
1272 memset(tab, 0, 11);
1273}
[331]1274</pre></td></tr></table><P>
[279]1275
[331]1276<DT>Out of bounds-error in global or local arrays:
1277<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
[279]1278 int tab[10];
[331]1279 for(i=0;i&#60;11;i++) {
[279]1280 sum += tab[i];
1281 }
1282}
[331]1283</pre></td></tr></table><P>
[279]1284
[331]1285<DT>Out of bounds-error in malloc'ed data:
1286<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
[279]1287 int *tab;
1288 tab = malloc(20 * sizeof(int));
[331]1289 for(i=0;i&#60;21;i++) {
[279]1290 sum += tab4[i];
1291 }
1292 free(tab);
1293}
[331]1294</pre></td></tr></table><P>
[279]1295
[331]1296<DT>Access of freed memory:
1297<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
[279]1298 int *tab;
1299 tab = malloc(20 * sizeof(int));
1300 free(tab);
[331]1301 for(i=0;i&#60;20;i++) {
[279]1302 sum += tab4[i];
1303 }
1304}
[331]1305</pre></td></tr></table><P>
[279]1306
[331]1307<DT>Double free:
1308<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
[279]1309 int *tab;
1310 tab = malloc(20 * sizeof(int));
1311 free(tab);
1312 free(tab);
1313}
[331]1314</pre></td></tr></table><P>
[279]1315
[331]1316</DL>
1317<P>
[279]1318
[331]1319<A NAME="Libtcc"></A>
1320<HR SIZE="6">
1321<A NAME="SEC22"></A>
1322<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1323<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &lt; </A>]</TD>
1324<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> &gt; </A>]</TD>
1325<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> &lt;&lt; </A>]</TD>
1326<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
1327<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> &gt;&gt; </A>]</TD>
1328<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1329<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1330<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1331<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1332</TR></TABLE>
1333<H1> 7. The <CODE>libtcc</CODE> library </H1>
1334<!--docid::SEC22::-->
1335<P>
[279]1336
[331]1337The <CODE>libtcc</CODE> library enables you to use TCC as a backend for
[279]1338dynamic code generation.
[331]1339</P><P>
1340
1341Read the <TT>`libtcc.h'</TT> to have an overview of the API. Read
1342<TT>`libtcc_test.c'</TT> to have a very simple example.
1343</P><P>
1344
1345The idea consists in giving a C string containing the program you want
1346to compile directly to <CODE>libtcc</CODE>. Then you can access to any global
[279]1347symbol (function or variable) defined.
[331]1348</P><P>
[279]1349
[331]1350<A NAME="devel"></A>
1351<HR SIZE="6">
1352<A NAME="SEC23"></A>
1353<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1354<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> &lt; </A>]</TD>
1355<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC24"> &gt; </A>]</TD>
1356<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
1357<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
1358<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
1359<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1360<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1361<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1362<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1363</TR></TABLE>
1364<H1> 8. Developer's guide </H1>
1365<!--docid::SEC23::-->
1366<P>
1367
1368This chapter gives some hints to understand how TCC works. You can skip
[279]1369it if you do not intend to modify the TCC code.
[331]1370</P><P>
[279]1371
[331]1372<HR SIZE="6">
1373<A NAME="SEC24"></A>
1374<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1375<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> &lt; </A>]</TD>
1376<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC25"> &gt; </A>]</TD>
1377<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
1378<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
1379<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
1380<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1381<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1382<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1383<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1384</TR></TABLE>
1385<H2> 8.1 File reading </H2>
1386<!--docid::SEC24::-->
1387<P>
1388
1389The <CODE>BufferedFile</CODE> structure contains the context needed to read a
1390file, including the current line number. <CODE>tcc_open()</CODE> opens a new
1391file and <CODE>tcc_close()</CODE> closes it. <CODE>inp()</CODE> returns the next
[279]1392character.
[331]1393</P><P>
[279]1394
[331]1395<HR SIZE="6">
1396<A NAME="SEC25"></A>
1397<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1398<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC24"> &lt; </A>]</TD>
1399<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC26"> &gt; </A>]</TD>
1400<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC26"> &lt;&lt; </A>]</TD>
1401<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
1402<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
1403<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1404<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1405<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1406<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1407</TR></TABLE>
1408<H2> 8.2 Lexer </H2>
1409<!--docid::SEC25::-->
1410<P>
1411
1412<CODE>next()</CODE> reads the next token in the current
1413file. <CODE>next_nomacro()</CODE> reads the next token without macro
[279]1414expansion.
[331]1415</P><P>
1416
1417<CODE>tok</CODE> contains the current token (see <CODE>TOK_xxx</CODE>)
1418constants. Identifiers and keywords are also keywords. <CODE>tokc</CODE>
[279]1419contains additional infos about the token (for example a constant value
1420if number or string token).
[331]1421</P><P>
[279]1422
[331]1423<HR SIZE="6">
1424<A NAME="SEC26"></A>
1425<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1426<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC25"> &lt; </A>]</TD>
1427<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC27"> &gt; </A>]</TD>
1428<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC27"> &lt;&lt; </A>]</TD>
1429<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
1430<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
1431<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1432<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1433<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1434<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1435</TR></TABLE>
1436<H2> 8.3 Parser </H2>
1437<!--docid::SEC26::-->
1438<P>
1439
1440The parser is hardcoded (yacc is not necessary). It does only one pass,
[279]1441except:
[331]1442</P><P>
1443
1444<UL>
1445
1446<LI>For initialized arrays with unknown size, a first pass
[279]1447is done to count the number of elements.
[331]1448<P>
[279]1449
[331]1450<LI>For architectures where arguments are evaluated in
[279]1451reverse order, a first pass is done to reverse the argument order.
[331]1452<P>
[279]1453
[331]1454</UL>
1455<P>
[279]1456
[331]1457<HR SIZE="6">
1458<A NAME="SEC27"></A>
1459<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1460<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC26"> &lt; </A>]</TD>
1461<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> &gt; </A>]</TD>
1462<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> &lt;&lt; </A>]</TD>
1463<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
1464<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
1465<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1466<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1467<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1468<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1469</TR></TABLE>
1470<H2> 8.4 Types </H2>
1471<!--docid::SEC27::-->
1472<P>
[279]1473
[331]1474The types are stored in a single 'int' variable. It was chosen in the
[279]1475first stages of development when tcc was much simpler. Now, it may not
1476be the best solution.
[331]1477</P><P>
1478
1479<TABLE><tr><td>&nbsp;</td><td class=example><pre>#define VT_INT 0 /* integer type */
[279]1480#define VT_BYTE 1 /* signed byte type */
1481#define VT_SHORT 2 /* short type */
1482#define VT_VOID 3 /* void type */
1483#define VT_PTR 4 /* pointer */
1484#define VT_ENUM 5 /* enum definition */
1485#define VT_FUNC 6 /* function type */
1486#define VT_STRUCT 7 /* struct/union definition */
1487#define VT_FLOAT 8 /* IEEE float */
1488#define VT_DOUBLE 9 /* IEEE double */
1489#define VT_LDOUBLE 10 /* IEEE long double */
1490#define VT_BOOL 11 /* ISOC99 boolean type */
1491#define VT_LLONG 12 /* 64 bit integer */
1492#define VT_LONG 13 /* long integer (NEVER USED as type, only
1493 during parsing) */
1494#define VT_BTYPE 0x000f /* mask for basic type */
1495#define VT_UNSIGNED 0x0010 /* unsigned type */
1496#define VT_ARRAY 0x0020 /* array type (also has VT_PTR) */
1497#define VT_VLA 0x20000 /* VLA type (also has VT_PTR and VT_ARRAY) */
1498#define VT_BITFIELD 0x0040 /* bitfield modifier */
1499#define VT_CONSTANT 0x0800 /* const modifier */
1500#define VT_VOLATILE 0x1000 /* volatile modifier */
[331]1501#define VT_DEFSIGN 0x2000 /* signed type */
[279]1502
1503#define VT_STRUCT_SHIFT 18 /* structure/enum name shift (14 bits left) */
[331]1504</pre></td></tr></table></P><P>
[279]1505
[331]1506When a reference to another type is needed (for pointers, functions and
1507structures), the <CODE>32 - VT_STRUCT_SHIFT</CODE> high order bits are used to
[279]1508store an identifier reference.
[331]1509</P><P>
1510
1511The <CODE>VT_UNSIGNED</CODE> flag can be set for chars, shorts, ints and long
[279]1512longs.
[331]1513</P><P>
1514
1515Arrays are considered as pointers <CODE>VT_PTR</CODE> with the flag
1516<CODE>VT_ARRAY</CODE> set. Variable length arrays are considered as special
1517arrays and have flag <CODE>VT_VLA</CODE> set instead of <CODE>VT_ARRAY</CODE>.
1518</P><P>
1519
1520The <CODE>VT_BITFIELD</CODE> flag can be set for chars, shorts, ints and long
[279]1521longs. If it is set, then the bitfield position is stored from bits
1522VT_STRUCT_SHIFT to VT_STRUCT_SHIFT + 5 and the bit field size is stored
1523from bits VT_STRUCT_SHIFT + 6 to VT_STRUCT_SHIFT + 11.
[331]1524</P><P>
1525
1526<CODE>VT_LONG</CODE> is never used except during parsing.
1527</P><P>
1528
1529During parsing, the storage of an object is also stored in the type
[279]1530integer:
[331]1531</P><P>
1532
1533<TABLE><tr><td>&nbsp;</td><td class=example><pre>#define VT_EXTERN 0x00000080 /* extern definition */
[279]1534#define VT_STATIC 0x00000100 /* static variable */
1535#define VT_TYPEDEF 0x00000200 /* typedef definition */
1536#define VT_INLINE 0x00000400 /* inline definition */
1537#define VT_IMPORT 0x00004000 /* win32: extern data imported from dll */
1538#define VT_EXPORT 0x00008000 /* win32: data exported from dll */
1539#define VT_WEAK 0x00010000 /* win32: data exported from dll */
[331]1540</pre></td></tr></table></P><P>
[279]1541
[331]1542<HR SIZE="6">
1543<A NAME="SEC28"></A>
1544<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1545<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC27"> &lt; </A>]</TD>
1546<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> &gt; </A>]</TD>
1547<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> &lt;&lt; </A>]</TD>
1548<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
1549<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
1550<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1551<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1552<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1553<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1554</TR></TABLE>
1555<H2> 8.5 Symbols </H2>
1556<!--docid::SEC28::-->
1557<P>
[279]1558
[331]1559All symbols are stored in hashed symbol stacks. Each symbol stack
1560contains <CODE>Sym</CODE> structures.
1561</P><P>
1562
1563<CODE>Sym.v</CODE> contains the symbol name (remember
1564an identifier is also a token, so a string is never necessary to store
1565it). <CODE>Sym.t</CODE> gives the type of the symbol. <CODE>Sym.r</CODE> is usually
1566the register in which the corresponding variable is stored. <CODE>Sym.c</CODE> is
[279]1567usually a constant associated to the symbol like its address for normal
1568symbols, and the number of entries for symbols representing arrays.
[331]1569Variable length array types use <CODE>Sym.c</CODE> as a location on the stack
[279]1570which holds the runtime sizeof for the type.
[331]1571</P><P>
[279]1572
[331]1573Four main symbol stacks are defined:
1574</P><P>
1575
1576<DL COMPACT>
1577
1578<DT><CODE>define_stack</CODE>
1579<DD>for the macros (<CODE>#define</CODE>s).
1580<P>
1581
1582<DT><CODE>global_stack</CODE>
1583<DD>for the global variables, functions and types.
1584<P>
1585
1586<DT><CODE>local_stack</CODE>
1587<DD>for the local variables, functions and types.
1588<P>
1589
1590<DT><CODE>global_label_stack</CODE>
1591<DD>for the local labels (for <CODE>goto</CODE>).
1592<P>
1593
1594<DT><CODE>label_stack</CODE>
1595<DD>for GCC block local labels (see the <CODE>__label__</CODE> keyword).
1596<P>
1597
1598</DL>
1599<P>
1600
1601<CODE>sym_push()</CODE> is used to add a new symbol in the local symbol
[279]1602stack. If no local symbol stack is active, it is added in the global
1603symbol stack.
[331]1604</P><P>
1605
1606<CODE>sym_pop(st,b)</CODE> pops symbols from the symbol stack <VAR>st</VAR> until
1607the symbol <VAR>b</VAR> is on the top of stack. If <VAR>b</VAR> is NULL, the stack
[279]1608is emptied.
[331]1609</P><P>
1610
1611<CODE>sym_find(v)</CODE> return the symbol associated to the identifier
1612<VAR>v</VAR>. The local stack is searched first from top to bottom, then the
[279]1613global stack.
[331]1614</P><P>
[279]1615
[331]1616<HR SIZE="6">
1617<A NAME="SEC29"></A>
1618<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1619<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> &lt; </A>]</TD>
1620<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> &gt; </A>]</TD>
1621<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> &lt;&lt; </A>]</TD>
1622<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
1623<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
1624<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1625<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1626<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1627<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1628</TR></TABLE>
1629<H2> 8.6 Sections </H2>
1630<!--docid::SEC29::-->
1631<P>
1632
1633The generated code and data are written in sections. The structure
1634<CODE>Section</CODE> contains all the necessary information for a given
1635section. <CODE>new_section()</CODE> creates a new section. ELF file semantics
[279]1636is assumed for each section.
[331]1637</P><P>
1638
1639The following sections are predefined:
1640</P><P>
1641
1642<DL COMPACT>
1643
1644<DT><CODE>text_section</CODE>
1645<DD>is the section containing the generated code. <VAR>ind</VAR> contains the
[279]1646current position in the code section.
[331]1647<P>
[279]1648
[331]1649<DT><CODE>data_section</CODE>
1650<DD>contains initialized data
1651<P>
[279]1652
[331]1653<DT><CODE>bss_section</CODE>
1654<DD>contains uninitialized data
1655<P>
[279]1656
[331]1657<DT><CODE>bounds_section</CODE>
1658<DD><DT><CODE>lbounds_section</CODE>
1659<DD>are used when bound checking is activated
1660<P>
1661
1662<DT><CODE>stab_section</CODE>
1663<DD><DT><CODE>stabstr_section</CODE>
1664<DD>are used when debugging is active to store debug information
1665<P>
1666
1667<DT><CODE>symtab_section</CODE>
1668<DD><DT><CODE>strtab_section</CODE>
1669<DD>contain the exported symbols (currently only used for debugging).
1670<P>
1671
1672</DL>
1673<P>
1674
1675<HR SIZE="6">
1676<A NAME="SEC30"></A>
1677<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1678<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> &lt; </A>]</TD>
1679<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC31"> &gt; </A>]</TD>
1680<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &lt;&lt; </A>]</TD>
1681<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
1682<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &gt;&gt; </A>]</TD>
1683<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1684<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1685<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1686<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1687</TR></TABLE>
1688<H2> 8.7 Code generation </H2>
1689<!--docid::SEC30::-->
1690<P>
1691
1692<HR SIZE="6">
1693<A NAME="SEC31"></A>
1694<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1695<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> &lt; </A>]</TD>
1696<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC32"> &gt; </A>]</TD>
1697<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &lt;&lt; </A>]</TD>
1698<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> Up </A>]</TD>
1699<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &gt;&gt; </A>]</TD>
1700<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1701<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1702<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1703<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1704</TR></TABLE>
1705<H3> 8.7.1 Introduction </H3>
1706<!--docid::SEC31::-->
1707<P>
1708
1709The TCC code generator directly generates linked binary code in one
[279]1710pass. It is rather unusual these days (see gcc for example which
1711generates text assembly), but it can be very fast and surprisingly
1712little complicated.
[331]1713</P><P>
1714
1715The TCC code generator is register based. Optimization is only done at
[279]1716the expression level. No intermediate representation of expression is
[331]1717kept except the current values stored in the <EM>value stack</EM>.
1718</P><P>
1719
1720On x86, three temporary registers are used. When more registers are
[279]1721needed, one register is spilled into a new temporary variable on the stack.
[331]1722</P><P>
[279]1723
[331]1724<HR SIZE="6">
1725<A NAME="SEC32"></A>
1726<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1727<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC31"> &lt; </A>]</TD>
1728<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC33"> &gt; </A>]</TD>
1729<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC33"> &lt;&lt; </A>]</TD>
1730<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> Up </A>]</TD>
1731<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &gt;&gt; </A>]</TD>
1732<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1733<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1734<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1735<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1736</TR></TABLE>
1737<H3> 8.7.2 The value stack </H3>
1738<!--docid::SEC32::-->
1739<P>
1740
1741When an expression is parsed, its value is pushed on the value stack
1742(<VAR>vstack</VAR>). The top of the value stack is <VAR>vtop</VAR>. Each value
1743stack entry is the structure <CODE>SValue</CODE>.
1744</P><P>
1745
1746<CODE>SValue.t</CODE> is the type. <CODE>SValue.r</CODE> indicates how the value is
[279]1747currently stored in the generated code. It is usually a CPU register
[331]1748index (<CODE>REG_xxx</CODE> constants), but additional values and flags are
[279]1749defined:
[331]1750</P><P>
1751
1752<TABLE><tr><td>&nbsp;</td><td class=example><pre>#define VT_CONST 0x00f0
[279]1753#define VT_LLOCAL 0x00f1
1754#define VT_LOCAL 0x00f2
1755#define VT_CMP 0x00f3
1756#define VT_JMP 0x00f4
1757#define VT_JMPI 0x00f5
1758#define VT_LVAL 0x0100
1759#define VT_SYM 0x0200
1760#define VT_MUSTCAST 0x0400
1761#define VT_MUSTBOUND 0x0800
1762#define VT_BOUNDED 0x8000
1763#define VT_LVAL_BYTE 0x1000
1764#define VT_LVAL_SHORT 0x2000
1765#define VT_LVAL_UNSIGNED 0x4000
1766#define VT_LVAL_TYPE (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)
[331]1767</pre></td></tr></table></P><P>
[279]1768
[331]1769<DL COMPACT>
1770
1771<DT><CODE>VT_CONST</CODE>
1772<DD>indicates that the value is a constant. It is stored in the union
1773<CODE>SValue.c</CODE>, depending on its type.
1774<P>
1775
1776<DT><CODE>VT_LOCAL</CODE>
1777<DD>indicates a local variable pointer at offset <CODE>SValue.c.i</CODE> in the
[279]1778stack.
[331]1779<P>
1780
1781<DT><CODE>VT_CMP</CODE>
1782<DD>indicates that the value is actually stored in the CPU flags (i.e. the
[279]1783value is the consequence of a test). The value is either 0 or 1. The
[331]1784actual CPU flags used is indicated in <CODE>SValue.c.i</CODE>.
1785<P>
1786
1787If any code is generated which destroys the CPU flags, this value MUST be
[279]1788put in a normal register.
[331]1789</P><P>
1790
1791<DT><CODE>VT_JMP</CODE>
1792<DD><DT><CODE>VT_JMPI</CODE>
1793<DD>indicates that the value is the consequence of a conditional jump. For VT_JMP,
[279]1794it is 1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.
[331]1795<P>
1796
1797These values are used to compile the <CODE>||</CODE> and <CODE>&#38;&#38;</CODE> logical
[279]1798operators.
[331]1799</P><P>
1800
1801If any code is generated, this value MUST be put in a normal
1802register. Otherwise, the generated code won't be executed if the jump is
[279]1803taken.
[331]1804</P><P>
1805
1806<DT><CODE>VT_LVAL</CODE>
1807<DD>is a flag indicating that the value is actually an lvalue (left value of
[279]1808an assignment). It means that the value stored is actually a pointer to
1809the wanted value.
[331]1810<P>
1811
1812Understanding the use <CODE>VT_LVAL</CODE> is very important if you want to
[279]1813understand how TCC works.
[331]1814</P><P>
1815
1816<DT><CODE>VT_LVAL_BYTE</CODE>
1817<DD><DT><CODE>VT_LVAL_SHORT</CODE>
1818<DD><DT><CODE>VT_LVAL_UNSIGNED</CODE>
1819<DD>if the lvalue has an integer type, then these flags give its real
[279]1820type. The type alone is not enough in case of cast optimisations.
[331]1821<P>
1822
1823<DT><CODE>VT_LLOCAL</CODE>
1824<DD>is a saved lvalue on the stack. <CODE>VT_LVAL</CODE> must also be set with
1825<CODE>VT_LLOCAL</CODE>. <CODE>VT_LLOCAL</CODE> can arise when a <CODE>VT_LVAL</CODE> in
1826a register has to be saved to the stack, or it can come from an
1827architecture-specific calling convention.
1828<P>
1829
1830<DT><CODE>VT_MUSTCAST</CODE>
1831<DD>indicates that a cast to the value type must be performed if the value
[279]1832is used (lazy casting).
[331]1833<P>
[279]1834
[331]1835<DT><CODE>VT_SYM</CODE>
1836<DD>indicates that the symbol <CODE>SValue.sym</CODE> must be added to the constant.
1837<P>
[279]1838
[331]1839<DT><CODE>VT_MUSTBOUND</CODE>
1840<DD><DT><CODE>VT_BOUNDED</CODE>
1841<DD>are only used for optional bound checking.
1842<P>
1843
1844</DL>
1845<P>
1846
1847<HR SIZE="6">
1848<A NAME="SEC33"></A>
1849<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1850<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC32"> &lt; </A>]</TD>
1851<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC34"> &gt; </A>]</TD>
1852<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC34"> &lt;&lt; </A>]</TD>
1853<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> Up </A>]</TD>
1854<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &gt;&gt; </A>]</TD>
1855<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1856<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1857<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1858<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1859</TR></TABLE>
1860<H3> 8.7.3 Manipulating the value stack </H3>
1861<!--docid::SEC33::-->
1862<P>
1863
1864<CODE>vsetc()</CODE> and <CODE>vset()</CODE> pushes a new value on the value
1865stack. If the previous <VAR>vtop</VAR> was stored in a very unsafe place(for
[279]1866example in the CPU flags), then some code is generated to put the
[331]1867previous <VAR>vtop</VAR> in a safe storage.
1868</P><P>
1869
1870<CODE>vpop()</CODE> pops <VAR>vtop</VAR>. In some cases, it also generates cleanup
[279]1871code (for example if stacked floating point registers are used as on
1872x86).
[331]1873</P><P>
1874
1875The <CODE>gv(rc)</CODE> function generates code to evaluate <VAR>vtop</VAR> (the
1876top value of the stack) into registers. <VAR>rc</VAR> selects in which
1877register class the value should be put. <CODE>gv()</CODE> is the <EM>most
1878important function</EM> of the code generator.
1879</P><P>
1880
1881<CODE>gv2()</CODE> is the same as <CODE>gv()</CODE> but for the top two stack
[279]1882entries.
[331]1883</P><P>
1884
1885<HR SIZE="6">
1886<A NAME="SEC34"></A>
1887<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1888<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC33"> &lt; </A>]</TD>
1889<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &gt; </A>]</TD>
1890<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &lt;&lt; </A>]</TD>
1891<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> Up </A>]</TD>
1892<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &gt;&gt; </A>]</TD>
1893<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1894<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1895<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1896<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1897</TR></TABLE>
1898<H3> 8.7.4 CPU dependent code generation </H3>
1899<!--docid::SEC34::-->
1900See the <TT>`i386-gen.c'</TT> file to have an example.
1901<P>
1902
1903<DL COMPACT>
1904
1905<DT><CODE>load()</CODE>
1906<DD>must generate the code needed to load a stack value into a register.
1907<P>
1908
1909<DT><CODE>store()</CODE>
1910<DD>must generate the code needed to store a register into a stack value
[279]1911lvalue.
[331]1912<P>
1913
1914<DT><CODE>gfunc_start()</CODE>
1915<DD><DT><CODE>gfunc_param()</CODE>
1916<DD><DT><CODE>gfunc_call()</CODE>
1917<DD>should generate a function call
1918<P>
1919
1920<DT><CODE>gfunc_prolog()</CODE>
1921<DD><DT><CODE>gfunc_epilog()</CODE>
1922<DD>should generate a function prolog/epilog.
1923<P>
1924
1925<DT><CODE>gen_opi(op)</CODE>
1926<DD>must generate the binary integer operation <VAR>op</VAR> on the two top
1927entries of the stack which are guaranteed to contain integer types.
1928<P>
1929
1930The result value should be put on the stack.
1931</P><P>
1932
1933<DT><CODE>gen_opf(op)</CODE>
1934<DD>same as <CODE>gen_opi()</CODE> for floating point operations. The two top
1935entries of the stack are guaranteed to contain floating point values of
[279]1936same types.
[331]1937<P>
[279]1938
[331]1939<DT><CODE>gen_cvt_itof()</CODE>
1940<DD>integer to floating point conversion.
1941<P>
1942
1943<DT><CODE>gen_cvt_ftoi()</CODE>
1944<DD>floating point to integer conversion.
1945<P>
1946
1947<DT><CODE>gen_cvt_ftof()</CODE>
1948<DD>floating point to floating point of different size conversion.
1949<P>
1950
1951<DT><CODE>gen_bounded_ptr_add()</CODE>
1952<DD><DT><CODE>gen_bounded_ptr_deref()</CODE>
1953<DD>are only used for bounds checking.
1954<P>
1955
1956</DL>
1957<P>
1958
1959<HR SIZE="6">
1960<A NAME="SEC35"></A>
1961<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1962<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC34"> &lt; </A>]</TD>
1963<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36"> &gt; </A>]</TD>
1964<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
1965<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> Up </A>]</TD>
1966<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
1967<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1968<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1969<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1970<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1971</TR></TABLE>
1972<H2> 8.8 Optimizations done </H2>
1973<!--docid::SEC35::-->
1974Constant propagation is done for all operations. Multiplications and
[279]1975divisions are optimized to shifts when appropriate. Comparison
1976operators are optimized by maintaining a special cache for the
[331]1977processor flags. &#38;&#38;, || and ! are optimized by maintaining a special
1978'jump target' value. No other jump optimization is currently performed
[279]1979because it would require to store the code in a more abstract fashion.
[331]1980<P>
1981
1982<HR SIZE="6">
1983<A NAME="SEC36"></A>
1984<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
1985<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &lt; </A>]</TD>
1986<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt; ]</TD>
1987<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
1988<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top"> Up </A>]</TD>
1989<TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
1990<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
1991<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
1992<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
1993<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
1994</TR></TABLE>
1995<H1> Concept Index </H1>
1996<!--docid::SEC36::-->
1997<table><tr><th valign=top>Jump to: &nbsp; </th><td><A HREF="tcc-doc.html#cp__" style="text-decoration:none"><b>_</b></A>
[279]1998 &nbsp;
[331]1999<BR>
2000<A HREF="tcc-doc.html#cp_A" style="text-decoration:none"><b>A</b></A>
[279]2001 &nbsp;
[331]2002<A HREF="tcc-doc.html#cp_B" style="text-decoration:none"><b>B</b></A>
[279]2003 &nbsp;
[331]2004<A HREF="tcc-doc.html#cp_C" style="text-decoration:none"><b>C</b></A>
[279]2005 &nbsp;
[331]2006<A HREF="tcc-doc.html#cp_D" style="text-decoration:none"><b>D</b></A>
[279]2007 &nbsp;
[331]2008<A HREF="tcc-doc.html#cp_E" style="text-decoration:none"><b>E</b></A>
[279]2009 &nbsp;
[331]2010<A HREF="tcc-doc.html#cp_F" style="text-decoration:none"><b>F</b></A>
[279]2011 &nbsp;
[331]2012<A HREF="tcc-doc.html#cp_G" style="text-decoration:none"><b>G</b></A>
[279]2013 &nbsp;
[331]2014<A HREF="tcc-doc.html#cp_I" style="text-decoration:none"><b>I</b></A>
[279]2015 &nbsp;
[331]2016<A HREF="tcc-doc.html#cp_J" style="text-decoration:none"><b>J</b></A>
[279]2017 &nbsp;
[331]2018<A HREF="tcc-doc.html#cp_L" style="text-decoration:none"><b>L</b></A>
[279]2019 &nbsp;
[331]2020<A HREF="tcc-doc.html#cp_M" style="text-decoration:none"><b>M</b></A>
[279]2021 &nbsp;
[331]2022<A HREF="tcc-doc.html#cp_O" style="text-decoration:none"><b>O</b></A>
[279]2023 &nbsp;
[331]2024<A HREF="tcc-doc.html#cp_P" style="text-decoration:none"><b>P</b></A>
[279]2025 &nbsp;
[331]2026<A HREF="tcc-doc.html#cp_Q" style="text-decoration:none"><b>Q</b></A>
[279]2027 &nbsp;
[331]2028<A HREF="tcc-doc.html#cp_R" style="text-decoration:none"><b>R</b></A>
[279]2029 &nbsp;
[331]2030<A HREF="tcc-doc.html#cp_S" style="text-decoration:none"><b>S</b></A>
[279]2031 &nbsp;
[331]2032<A HREF="tcc-doc.html#cp_T" style="text-decoration:none"><b>T</b></A>
[279]2033 &nbsp;
[331]2034<A HREF="tcc-doc.html#cp_U" style="text-decoration:none"><b>U</b></A>
[279]2035 &nbsp;
[331]2036<A HREF="tcc-doc.html#cp_V" style="text-decoration:none"><b>V</b></A>
[279]2037 &nbsp;
[331]2038<A HREF="tcc-doc.html#cp_W" style="text-decoration:none"><b>W</b></A>
[279]2039 &nbsp;
[331]2040</td></tr></table><br><P></P>
2041<TABLE border=0>
2042<TR><TD></TD><TH ALIGN=LEFT>Index Entry</TH><TH ALIGN=LEFT> Section</TH></TR>
2043<TR><TD COLSPAN=3> <HR></TD></TR>
2044<TR><TH><A NAME="cp__"></A>_</TH><TD></TD><TD></TD></TR>
2045<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX11">__asm__</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2046<TR><TD COLSPAN=3> <HR></TD></TR>
2047<TR><TH><A NAME="cp_A"></A>A</TH><TD></TD><TD></TD></TR>
2048<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">align directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2049<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX1">aligned attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2050<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">ascii directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2051<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">asciz directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2052<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC15">assembler</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC15">4.5 X86 Assembler</A></TD></TR>
2053<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">assembler directives</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2054<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX10">assembly, inline</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2055<TR><TD COLSPAN=3> <HR></TD></TR>
2056<TR><TH><A NAME="cp_B"></A>B</TH><TD></TD><TD></TD></TR>
2057<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">bound checks</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A></TD></TR>
2058<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">bss directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2059<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">byte directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2060<TR><TD COLSPAN=3> <HR></TD></TR>
2061<TR><TH><A NAME="cp_C"></A>C</TH><TD></TD><TD></TD></TR>
2062<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">caching processor flags</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
2063<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX5">cdecl attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2064<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC30">code generation</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC30">8.7 Code generation</A></TD></TR>
2065<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">comparison operators</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
2066<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">constant propagation</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
2067<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC34">CPU dependent</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC34">8.7.4 CPU dependent code generation</A></TD></TR>
2068<TR><TD COLSPAN=3> <HR></TD></TR>
2069<TR><TH><A NAME="cp_D"></A>D</TH><TD></TD><TD></TD></TR>
2070<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">data directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2071<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">directives, assembler</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2072<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX8">dllexport attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2073<TR><TD COLSPAN=3> <HR></TD></TR>
2074<TR><TH><A NAME="cp_E"></A>E</TH><TD></TD><TD></TD></TR>
2075<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC17">ELF</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC17">5.1 ELF file generation</A></TD></TR>
2076<TR><TD COLSPAN=3> <HR></TD></TR>
2077<TR><TH><A NAME="cp_F"></A>F</TH><TD></TD><TD></TD></TR>
2078<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">FILE, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
2079<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">fill directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2080<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">flags, caching</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
2081<TR><TD COLSPAN=3> <HR></TD></TR>
2082<TR><TH><A NAME="cp_G"></A>G</TH><TD></TD><TD></TD></TR>
2083<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX12">gas</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2084<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">global directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2085<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">globl directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2086<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">GROUP, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
2087<TR><TD COLSPAN=3> <HR></TD></TR>
2088<TR><TH><A NAME="cp_I"></A>I</TH><TD></TD><TD></TD></TR>
2089<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX9">inline assembly</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2090<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">int directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2091<TR><TD COLSPAN=3> <HR></TD></TR>
2092<TR><TH><A NAME="cp_J"></A>J</TH><TD></TD><TD></TD></TR>
2093<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">jump optimization</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
2094<TR><TD COLSPAN=3> <HR></TD></TR>
2095<TR><TH><A NAME="cp_L"></A>L</TH><TD></TD><TD></TD></TR>
2096<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC16">linker</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A></TD></TR>
2097<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">linker scripts</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
2098<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">long directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2099<TR><TD COLSPAN=3> <HR></TD></TR>
2100<TR><TH><A NAME="cp_M"></A>M</TH><TD></TD><TD></TD></TR>
2101<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">memory checks</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A></TD></TR>
2102<TR><TD COLSPAN=3> <HR></TD></TR>
2103<TR><TH><A NAME="cp_O"></A>O</TH><TD></TD><TD></TD></TR>
2104<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">optimizations</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
2105<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">org directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2106<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">OUTPUT_FORMAT, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
2107<TR><TD COLSPAN=3> <HR></TD></TR>
2108<TR><TH><A NAME="cp_P"></A>P</TH><TD></TD><TD></TD></TR>
2109<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX2">packed attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2110<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC19">PE-i386</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC19">5.3 PE-i386 file generation</A></TD></TR>
2111<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">previous directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2112<TR><TD COLSPAN=3> <HR></TD></TR>
2113<TR><TH><A NAME="cp_Q"></A>Q</TH><TD></TD><TD></TD></TR>
2114<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">quad directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2115<TR><TD COLSPAN=3> <HR></TD></TR>
2116<TR><TH><A NAME="cp_R"></A>R</TH><TD></TD><TD></TD></TR>
2117<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX7">regparm attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2118<TR><TD COLSPAN=3> <HR></TD></TR>
2119<TR><TH><A NAME="cp_S"></A>S</TH><TD></TD><TD></TD></TR>
2120<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">scripts, linker</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
2121<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX3">section attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2122<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">section directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2123<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">short directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2124<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">skip directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2125<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">space directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2126<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX6">stdcall attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2127<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">strength reduction</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
2128<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">string directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2129<TR><TD COLSPAN=3> <HR></TD></TR>
2130<TR><TH><A NAME="cp_T"></A>T</TH><TD></TD><TD></TD></TR>
2131<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">TARGET, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
2132<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">text directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2133<TR><TD COLSPAN=3> <HR></TD></TR>
2134<TR><TH><A NAME="cp_U"></A>U</TH><TD></TD><TD></TD></TR>
2135<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX4">unused attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
2136<TR><TD COLSPAN=3> <HR></TD></TR>
2137<TR><TH><A NAME="cp_V"></A>V</TH><TD></TD><TD></TD></TR>
2138<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC33">value stack</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC33">8.7.3 Manipulating the value stack</A></TD></TR>
2139<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC32">value stack, introduction</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC32">8.7.2 The value stack</A></TD></TR>
2140<TR><TD COLSPAN=3> <HR></TD></TR>
2141<TR><TH><A NAME="cp_W"></A>W</TH><TD></TD><TD></TD></TR>
2142<TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">word directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
2143<TR><TD COLSPAN=3> <HR></TD></TR>
2144</TABLE><P></P><table><tr><th valign=top>Jump to: &nbsp; </th><td><A HREF="tcc-doc.html#cp__" style="text-decoration:none"><b>_</b></A>
[279]2145 &nbsp;
[331]2146<BR>
2147<A HREF="tcc-doc.html#cp_A" style="text-decoration:none"><b>A</b></A>
[279]2148 &nbsp;
[331]2149<A HREF="tcc-doc.html#cp_B" style="text-decoration:none"><b>B</b></A>
[279]2150 &nbsp;
[331]2151<A HREF="tcc-doc.html#cp_C" style="text-decoration:none"><b>C</b></A>
[279]2152 &nbsp;
[331]2153<A HREF="tcc-doc.html#cp_D" style="text-decoration:none"><b>D</b></A>
[279]2154 &nbsp;
[331]2155<A HREF="tcc-doc.html#cp_E" style="text-decoration:none"><b>E</b></A>
[279]2156 &nbsp;
[331]2157<A HREF="tcc-doc.html#cp_F" style="text-decoration:none"><b>F</b></A>
[279]2158 &nbsp;
[331]2159<A HREF="tcc-doc.html#cp_G" style="text-decoration:none"><b>G</b></A>
[279]2160 &nbsp;
[331]2161<A HREF="tcc-doc.html#cp_I" style="text-decoration:none"><b>I</b></A>
[279]2162 &nbsp;
[331]2163<A HREF="tcc-doc.html#cp_J" style="text-decoration:none"><b>J</b></A>
[279]2164 &nbsp;
[331]2165<A HREF="tcc-doc.html#cp_L" style="text-decoration:none"><b>L</b></A>
[279]2166 &nbsp;
[331]2167<A HREF="tcc-doc.html#cp_M" style="text-decoration:none"><b>M</b></A>
[279]2168 &nbsp;
[331]2169<A HREF="tcc-doc.html#cp_O" style="text-decoration:none"><b>O</b></A>
[279]2170 &nbsp;
[331]2171<A HREF="tcc-doc.html#cp_P" style="text-decoration:none"><b>P</b></A>
[279]2172 &nbsp;
[331]2173<A HREF="tcc-doc.html#cp_Q" style="text-decoration:none"><b>Q</b></A>
[279]2174 &nbsp;
[331]2175<A HREF="tcc-doc.html#cp_R" style="text-decoration:none"><b>R</b></A>
[279]2176 &nbsp;
[331]2177<A HREF="tcc-doc.html#cp_S" style="text-decoration:none"><b>S</b></A>
[279]2178 &nbsp;
[331]2179<A HREF="tcc-doc.html#cp_T" style="text-decoration:none"><b>T</b></A>
[279]2180 &nbsp;
[331]2181<A HREF="tcc-doc.html#cp_U" style="text-decoration:none"><b>U</b></A>
[279]2182 &nbsp;
[331]2183<A HREF="tcc-doc.html#cp_V" style="text-decoration:none"><b>V</b></A>
[279]2184 &nbsp;
[331]2185<A HREF="tcc-doc.html#cp_W" style="text-decoration:none"><b>W</b></A>
[279]2186 &nbsp;
[331]2187</td></tr></table><br><P>
[279]2188
[331]2189<HR SIZE="6">
2190<A NAME="SEC_Contents"></A>
2191<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
2192<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
2193<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
2194<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
2195<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
2196</TR></TABLE>
2197<H1>Table of Contents</H1>
2198<UL>
2199<A NAME="TOC1" HREF="tcc-doc.html#SEC1">1. Introduction</A>
2200<BR>
2201<A NAME="TOC2" HREF="tcc-doc.html#SEC2">2. Command line invocation</A>
2202<BR>
2203<UL>
2204<A NAME="TOC3" HREF="tcc-doc.html#SEC3">2.1 Quick start</A>
2205<BR>
2206<A NAME="TOC4" HREF="tcc-doc.html#SEC4">2.2 Option summary</A>
2207<BR>
2208</UL>
2209<A NAME="TOC5" HREF="tcc-doc.html#SEC5">3. C language support</A>
2210<BR>
2211<UL>
2212<A NAME="TOC6" HREF="tcc-doc.html#SEC6">3.1 ANSI C</A>
2213<BR>
2214<A NAME="TOC7" HREF="tcc-doc.html#SEC7">3.2 ISOC99 extensions</A>
2215<BR>
2216<A NAME="TOC8" HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A>
2217<BR>
2218<A NAME="TOC9" HREF="tcc-doc.html#SEC9">3.4 TinyCC extensions</A>
2219<BR>
2220</UL>
2221<A NAME="TOC10" HREF="tcc-doc.html#SEC10">4. TinyCC Assembler</A>
2222<BR>
2223<UL>
2224<A NAME="TOC11" HREF="tcc-doc.html#SEC11">4.1 Syntax</A>
2225<BR>
2226<A NAME="TOC12" HREF="tcc-doc.html#SEC12">4.2 Expressions</A>
2227<BR>
2228<A NAME="TOC13" HREF="tcc-doc.html#SEC13">4.3 Labels</A>
2229<BR>
2230<A NAME="TOC14" HREF="tcc-doc.html#SEC14">4.4 Directives</A>
2231<BR>
2232<A NAME="TOC15" HREF="tcc-doc.html#SEC15">4.5 X86 Assembler</A>
2233<BR>
2234</UL>
2235<A NAME="TOC16" HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A>
2236<BR>
2237<UL>
2238<A NAME="TOC17" HREF="tcc-doc.html#SEC17">5.1 ELF file generation</A>
2239<BR>
2240<A NAME="TOC18" HREF="tcc-doc.html#SEC18">5.2 ELF file loader</A>
2241<BR>
2242<A NAME="TOC19" HREF="tcc-doc.html#SEC19">5.3 PE-i386 file generation</A>
2243<BR>
2244<A NAME="TOC20" HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A>
2245<BR>
2246</UL>
2247<A NAME="TOC21" HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A>
2248<BR>
2249<A NAME="TOC22" HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A>
2250<BR>
2251<A NAME="TOC23" HREF="tcc-doc.html#SEC23">8. Developer's guide</A>
2252<BR>
2253<UL>
2254<A NAME="TOC24" HREF="tcc-doc.html#SEC24">8.1 File reading</A>
2255<BR>
2256<A NAME="TOC25" HREF="tcc-doc.html#SEC25">8.2 Lexer</A>
2257<BR>
2258<A NAME="TOC26" HREF="tcc-doc.html#SEC26">8.3 Parser</A>
2259<BR>
2260<A NAME="TOC27" HREF="tcc-doc.html#SEC27">8.4 Types</A>
2261<BR>
2262<A NAME="TOC28" HREF="tcc-doc.html#SEC28">8.5 Symbols</A>
2263<BR>
2264<A NAME="TOC29" HREF="tcc-doc.html#SEC29">8.6 Sections</A>
2265<BR>
2266<A NAME="TOC30" HREF="tcc-doc.html#SEC30">8.7 Code generation</A>
2267<BR>
2268<UL>
2269<A NAME="TOC31" HREF="tcc-doc.html#SEC31">8.7.1 Introduction</A>
2270<BR>
2271<A NAME="TOC32" HREF="tcc-doc.html#SEC32">8.7.2 The value stack</A>
2272<BR>
2273<A NAME="TOC33" HREF="tcc-doc.html#SEC33">8.7.3 Manipulating the value stack</A>
2274<BR>
2275<A NAME="TOC34" HREF="tcc-doc.html#SEC34">8.7.4 CPU dependent code generation</A>
2276<BR>
2277</UL>
2278<A NAME="TOC35" HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A>
2279<BR>
2280</UL>
2281<A NAME="TOC36" HREF="tcc-doc.html#SEC36">Concept Index</A>
2282<BR>
2283</UL>
2284<HR SIZE=1>
2285<A NAME="SEC_OVERVIEW"></A>
2286<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
2287<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
2288<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
2289<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
2290<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
2291</TR></TABLE>
2292<H1>Short Table of Contents</H1>
2293<BLOCKQUOTE>
2294<A NAME="TOC1" HREF="tcc-doc.html#SEC1">1. Introduction</A>
2295<BR>
2296<A NAME="TOC2" HREF="tcc-doc.html#SEC2">2. Command line invocation</A>
2297<BR>
2298<A NAME="TOC5" HREF="tcc-doc.html#SEC5">3. C language support</A>
2299<BR>
2300<A NAME="TOC10" HREF="tcc-doc.html#SEC10">4. TinyCC Assembler</A>
2301<BR>
2302<A NAME="TOC16" HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A>
2303<BR>
2304<A NAME="TOC21" HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A>
2305<BR>
2306<A NAME="TOC22" HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A>
2307<BR>
2308<A NAME="TOC23" HREF="tcc-doc.html#SEC23">8. Developer's guide</A>
2309<BR>
2310<A NAME="TOC36" HREF="tcc-doc.html#SEC36">Concept Index</A>
2311<BR>
[279]2312
[331]2313</BLOCKQUOTE>
2314<HR SIZE=1>
2315<A NAME="SEC_About"></A>
2316<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
2317<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Top">Top</A>]</TD>
2318<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
2319<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
2320<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
2321</TR></TABLE>
2322<H1>About this document</H1>
2323This document was generated on <I>December, 17 2017</I>
2324using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
2325"><I>texi2html</I></A>
2326<P></P>
2327The buttons in the navigation panels have the following meaning:
2328<P></P>
2329<table border = "1">
2330<TR>
2331<TH> Button </TH>
2332<TH> Name </TH>
2333<TH> Go to </TH>
2334<TH> From 1.2.3 go to</TH>
2335</TR>
2336<TR>
2337<TD ALIGN="CENTER">
2338 [ &lt; ] </TD>
2339<TD ALIGN="CENTER">
2340Back
2341</TD>
2342<TD>
2343previous section in reading order
2344</TD>
2345<TD>
23461.2.2
2347</TD>
2348</TR>
2349<TR>
2350<TD ALIGN="CENTER">
2351 [ &gt; ] </TD>
2352<TD ALIGN="CENTER">
2353Forward
2354</TD>
2355<TD>
2356next section in reading order
2357</TD>
2358<TD>
23591.2.4
2360</TD>
2361</TR>
2362<TR>
2363<TD ALIGN="CENTER">
2364 [ &lt;&lt; ] </TD>
2365<TD ALIGN="CENTER">
2366FastBack
2367</TD>
2368<TD>
2369previous or up-and-previous section
2370</TD>
2371<TD>
23721.1
2373</TD>
2374</TR>
2375<TR>
2376<TD ALIGN="CENTER">
2377 [ Up ] </TD>
2378<TD ALIGN="CENTER">
2379Up
2380</TD>
2381<TD>
2382up section
2383</TD>
2384<TD>
23851.2
2386</TD>
2387</TR>
2388<TR>
2389<TD ALIGN="CENTER">
2390 [ &gt;&gt; ] </TD>
2391<TD ALIGN="CENTER">
2392FastForward
2393</TD>
2394<TD>
2395next or up-and-next section
2396</TD>
2397<TD>
23981.3
2399</TD>
2400</TR>
2401<TR>
2402<TD ALIGN="CENTER">
2403 [Top] </TD>
2404<TD ALIGN="CENTER">
2405Top
2406</TD>
2407<TD>
2408cover (top) of document
2409</TD>
2410<TD>
2411 &nbsp;
2412</TD>
2413</TR>
2414<TR>
2415<TD ALIGN="CENTER">
2416 [Contents] </TD>
2417<TD ALIGN="CENTER">
2418Contents
2419</TD>
2420<TD>
2421table of contents
2422</TD>
2423<TD>
2424 &nbsp;
2425</TD>
2426</TR>
2427<TR>
2428<TD ALIGN="CENTER">
2429 [Index] </TD>
2430<TD ALIGN="CENTER">
2431Index
2432</TD>
2433<TD>
2434concept index
2435</TD>
2436<TD>
2437 &nbsp;
2438</TD>
2439</TR>
2440<TR>
2441<TD ALIGN="CENTER">
2442 [ ? ] </TD>
2443<TD ALIGN="CENTER">
2444About
2445</TD>
2446<TD>
2447this page
2448</TD>
2449<TD>
2450 &nbsp;
2451</TD>
2452</TR>
2453</TABLE>
2454<P></P>
2455where the <STRONG> Example </STRONG> assumes that the current position
2456is at <STRONG> Subsubsection One-Two-Three </STRONG> of a document of
2457the following structure:
2458<UL>
2459<LI> 1. Section One </LI>
2460<UL>
2461<LI>1.1 Subsection One-One</LI>
2462<UL>
2463<LI> ... </LI>
2464</UL>
2465<LI>1.2 Subsection One-Two</LI>
2466<UL>
2467<LI>1.2.1 Subsubsection One-Two-One
2468</LI><LI>1.2.2 Subsubsection One-Two-Two
2469</LI><LI>1.2.3 Subsubsection One-Two-Three &nbsp; &nbsp; <STRONG>
2470&lt;== Current Position </STRONG>
2471</LI><LI>1.2.4 Subsubsection One-Two-Four
2472</LI></UL>
2473<LI>1.3 Subsection One-Three</LI>
2474<UL>
2475<LI> ... </LI>
2476</UL>
2477<LI>1.4 Subsection One-Four</LI>
2478</UL>
2479</UL>
[279]2480
[331]2481<HR SIZE=1>
2482<BR>
2483<FONT SIZE="-1">
2484This document was generated
2485on <I>December, 17 2017</I>
2486using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
2487"><I>texi2html</I></A>
[279]2488
[331]2489</BODY>
2490</HTML>
Note: See TracBrowser for help on using the repository browser.