tcc 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +35 -0
- data/README.md +196 -0
- data/ext/tcc/extconf.rb +25 -0
- data/ext/tcc/tcc-0.9.26.patch +30 -0
- data/ext/tcc/tcc-0.9.26/COPYING +504 -0
- data/ext/tcc/tcc-0.9.26/Changelog +396 -0
- data/ext/tcc/tcc-0.9.26/Makefile +349 -0
- data/ext/tcc/tcc-0.9.26/README +101 -0
- data/ext/tcc/tcc-0.9.26/TODO +93 -0
- data/ext/tcc/tcc-0.9.26/VERSION +1 -0
- data/ext/tcc/tcc-0.9.26/arm-gen.c +2005 -0
- data/ext/tcc/tcc-0.9.26/c67-gen.c +2560 -0
- data/ext/tcc/tcc-0.9.26/coff.h +446 -0
- data/ext/tcc/tcc-0.9.26/config.h +8 -0
- data/ext/tcc/tcc-0.9.26/config.mak +28 -0
- data/ext/tcc/tcc-0.9.26/config.texi +1 -0
- data/ext/tcc/tcc-0.9.26/configure +540 -0
- data/ext/tcc/tcc-0.9.26/conftest.c +71 -0
- data/ext/tcc/tcc-0.9.26/elf.h +1731 -0
- data/ext/tcc/tcc-0.9.26/examples/ex1.c +8 -0
- data/ext/tcc/tcc-0.9.26/examples/ex2.c +98 -0
- data/ext/tcc/tcc-0.9.26/examples/ex3.c +24 -0
- data/ext/tcc/tcc-0.9.26/examples/ex4.c +26 -0
- data/ext/tcc/tcc-0.9.26/examples/ex5.c +8 -0
- data/ext/tcc/tcc-0.9.26/i386-asm.c +1498 -0
- data/ext/tcc/tcc-0.9.26/i386-asm.h +473 -0
- data/ext/tcc/tcc-0.9.26/i386-gen.c +1096 -0
- data/ext/tcc/tcc-0.9.26/i386-tok.h +243 -0
- data/ext/tcc/tcc-0.9.26/il-gen.c +667 -0
- data/ext/tcc/tcc-0.9.26/il-opcodes.h +251 -0
- data/ext/tcc/tcc-0.9.26/include/float.h +57 -0
- data/ext/tcc/tcc-0.9.26/include/stdarg.h +41 -0
- data/ext/tcc/tcc-0.9.26/include/stdbool.h +10 -0
- data/ext/tcc/tcc-0.9.26/include/stddef.h +28 -0
- data/ext/tcc/tcc-0.9.26/include/tcclib.h +78 -0
- data/ext/tcc/tcc-0.9.26/include/varargs.h +12 -0
- data/ext/tcc/tcc-0.9.26/lib/Makefile +102 -0
- data/ext/tcc/tcc-0.9.26/lib/alloca86-bt.S +47 -0
- data/ext/tcc/tcc-0.9.26/lib/alloca86.S +35 -0
- data/ext/tcc/tcc-0.9.26/lib/alloca86_64.S +42 -0
- data/ext/tcc/tcc-0.9.26/lib/bcheck.c +875 -0
- data/ext/tcc/tcc-0.9.26/lib/libtcc1.c +691 -0
- data/ext/tcc/tcc-0.9.26/libtcc.c +1941 -0
- data/ext/tcc/tcc-0.9.26/libtcc.h +103 -0
- data/ext/tcc/tcc-0.9.26/stab.def +234 -0
- data/ext/tcc/tcc-0.9.26/stab.h +17 -0
- data/ext/tcc/tcc-0.9.26/tcc-doc.html +2332 -0
- data/ext/tcc/tcc-0.9.26/tcc-doc.info +1151 -0
- data/ext/tcc/tcc-0.9.26/tcc-doc.texi +1268 -0
- data/ext/tcc/tcc-0.9.26/tcc.1 +415 -0
- data/ext/tcc/tcc-0.9.26/tcc.c +352 -0
- data/ext/tcc/tcc-0.9.26/tcc.h +1379 -0
- data/ext/tcc/tcc-0.9.26/tccasm.c +1118 -0
- data/ext/tcc/tcc-0.9.26/tcccoff.c +948 -0
- data/ext/tcc/tcc-0.9.26/tccelf.c +3129 -0
- data/ext/tcc/tcc-0.9.26/tccgen.c +5841 -0
- data/ext/tcc/tcc-0.9.26/tccpe.c +1887 -0
- data/ext/tcc/tcc-0.9.26/tccpp.c +3128 -0
- data/ext/tcc/tcc-0.9.26/tccrun.c +737 -0
- data/ext/tcc/tcc-0.9.26/tcctok.h +278 -0
- data/ext/tcc/tcc-0.9.26/tests/Makefile +199 -0
- data/ext/tcc/tcc-0.9.26/tests/asmtest.S +609 -0
- data/ext/tcc/tcc-0.9.26/tests/boundtest.c +233 -0
- data/ext/tcc/tcc-0.9.26/tests/gcctestsuite.sh +33 -0
- data/ext/tcc/tcc-0.9.26/tests/libtcc_test.c +76 -0
- data/ext/tcc/tcc-0.9.26/tests/tcctest.c +2713 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/00_assignment.c +18 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/00_assignment.expect +3 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/01_comment.c +14 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/01_comment.expect +5 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/02_printf.c +18 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/02_printf.expect +15 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/03_struct.c +31 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/03_struct.expect +6 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/04_for.c +15 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/04_for.expect +10 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/05_array.c +21 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/05_array.expect +10 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/06_case.c +29 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/06_case.expect +8 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/07_function.c +30 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/07_function.expect +4 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/08_while.c +24 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/08_while.expect +11 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/09_do_while.c +24 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/09_do_while.expect +11 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/10_pointer.c +40 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/10_pointer.expect +8 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/11_precedence.c +40 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/11_precedence.expect +15 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/12_hashdefine.c +14 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/12_hashdefine.expect +2 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/13_integer_literals.c +20 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/13_integer_literals.expect +5 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/14_if.c +21 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/14_if.expect +2 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/15_recursion.c +21 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/15_recursion.expect +10 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/16_nesting.c +21 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/16_nesting.expect +18 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/17_enum.c +29 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/17_enum.expect +3 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/18_include.c +12 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/18_include.expect +3 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/18_include.h +1 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.c +28 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.expect +3 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/20_pointer_comparison.c +24 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/20_pointer_comparison.expect +6 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/21_char_array.c +33 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/21_char_array.expect +7 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/22_floating_point.c +50 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/22_floating_point.expect +16 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/23_type_coercion.c +54 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/23_type_coercion.expect +12 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/24_math_library.c +28 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/24_math_library.expect +18 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/25_quicksort.c +83 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/25_quicksort.expect +2 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/26_character_constants.c +17 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/26_character_constants.expect +8 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/27_sizeof.c +16 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/27_sizeof.expect +3 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/28_strings.c +46 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/28_strings.expect +19 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/29_array_address.c +13 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/29_array_address.expect +1 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/30_hanoi.c +122 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/30_hanoi.expect +71 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/31_args.c +14 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/31_args.expect +7 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/32_led.c +266 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/32_led.expect +4 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/33_ternary_op.c +15 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/33_ternary_op.expect +10 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/34_array_assignment.c +23 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/34_array_assignment.expect +2 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/35_sizeof.c +14 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/35_sizeof.expect +2 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/36_array_initialisers.c +21 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/36_array_initialisers.expect +20 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/37_sprintf.c +17 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/37_sprintf.expect +20 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/38_multiple_array_index.c +32 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/38_multiple_array_index.expect +4 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/39_typedef.c +31 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/39_typedef.expect +3 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/40_stdio.c +52 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/40_stdio.expect +27 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/41_hashif.c +85 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/41_hashif.expect +6 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/42_function_pointer.c +18 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/42_function_pointer.expect +2 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/43_void_param.c +15 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/43_void_param.expect +1 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/44_scoped_declarations.c +17 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/44_scoped_declarations.expect +1 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/45_empty_for.c +18 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/45_empty_for.expect +10 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/46_grep.c +564 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/47_switch_return.c +24 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/47_switch_return.expect +4 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/48_nested_break.c +26 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/48_nested_break.expect +1 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/49_bracket_evaluation.c +23 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/49_bracket_evaluation.expect +1 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/50_logical_second_arg.c +29 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/50_logical_second_arg.expect +20 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/51_static.c +30 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/51_static.expect +8 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/52_unnamed_enum.c +27 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/52_unnamed_enum.expect +9 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/54_goto.c +56 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/54_goto.expect +8 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/55_lshift_type.c +52 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/55_lshift_type.expect +1 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/LICENSE +37 -0
- data/ext/tcc/tcc-0.9.26/tests/tests2/Makefile +98 -0
- data/ext/tcc/tcc-0.9.26/texi2pod.pl +427 -0
- data/ext/tcc/tcc-0.9.26/win32/build-tcc.bat +60 -0
- data/ext/tcc/tcc-0.9.26/win32/examples/dll.c +12 -0
- data/ext/tcc/tcc-0.9.26/win32/examples/fib.c +23 -0
- data/ext/tcc/tcc-0.9.26/win32/examples/hello_dll.c +19 -0
- data/ext/tcc/tcc-0.9.26/win32/examples/hello_win.c +163 -0
- data/ext/tcc/tcc-0.9.26/win32/include/_mingw.h +139 -0
- data/ext/tcc/tcc-0.9.26/win32/include/assert.h +54 -0
- data/ext/tcc/tcc-0.9.26/win32/include/conio.h +409 -0
- data/ext/tcc/tcc-0.9.26/win32/include/ctype.h +281 -0
- data/ext/tcc/tcc-0.9.26/win32/include/dir.h +31 -0
- data/ext/tcc/tcc-0.9.26/win32/include/direct.h +68 -0
- data/ext/tcc/tcc-0.9.26/win32/include/dirent.h +135 -0
- data/ext/tcc/tcc-0.9.26/win32/include/dos.h +55 -0
- data/ext/tcc/tcc-0.9.26/win32/include/errno.h +75 -0
- data/ext/tcc/tcc-0.9.26/win32/include/excpt.h +123 -0
- data/ext/tcc/tcc-0.9.26/win32/include/fcntl.h +52 -0
- data/ext/tcc/tcc-0.9.26/win32/include/fenv.h +108 -0
- data/ext/tcc/tcc-0.9.26/win32/include/inttypes.h +297 -0
- data/ext/tcc/tcc-0.9.26/win32/include/io.h +418 -0
- data/ext/tcc/tcc-0.9.26/win32/include/limits.h +111 -0
- data/ext/tcc/tcc-0.9.26/win32/include/locale.h +91 -0
- data/ext/tcc/tcc-0.9.26/win32/include/malloc.h +175 -0
- data/ext/tcc/tcc-0.9.26/win32/include/math.h +777 -0
- data/ext/tcc/tcc-0.9.26/win32/include/mem.h +13 -0
- data/ext/tcc/tcc-0.9.26/win32/include/memory.h +40 -0
- data/ext/tcc/tcc-0.9.26/win32/include/process.h +176 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/conio_s.h +42 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/crtdbg_s.h +19 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/io_s.h +33 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/mbstring_s.h +52 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/search_s.h +25 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/stdio_s.h +145 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/stdlib_s.h +67 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/stralign_s.h +30 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/string_s.h +41 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/sys/timeb_s.h +34 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/tchar_s.h +266 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/time_s.h +61 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sec_api/wchar_s.h +128 -0
- data/ext/tcc/tcc-0.9.26/win32/include/setjmp.h +160 -0
- data/ext/tcc/tcc-0.9.26/win32/include/share.h +28 -0
- data/ext/tcc/tcc-0.9.26/win32/include/signal.h +63 -0
- data/ext/tcc/tcc-0.9.26/win32/include/stdint.h +209 -0
- data/ext/tcc/tcc-0.9.26/win32/include/stdio.h +429 -0
- data/ext/tcc/tcc-0.9.26/win32/include/stdlib.h +580 -0
- data/ext/tcc/tcc-0.9.26/win32/include/string.h +164 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sys/fcntl.h +13 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sys/file.h +14 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sys/locking.h +30 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sys/stat.h +290 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sys/time.h +69 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sys/timeb.h +133 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sys/types.h +118 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sys/unistd.h +14 -0
- data/ext/tcc/tcc-0.9.26/win32/include/sys/utime.h +146 -0
- data/ext/tcc/tcc-0.9.26/win32/include/tchar.h +1102 -0
- data/ext/tcc/tcc-0.9.26/win32/include/time.h +287 -0
- data/ext/tcc/tcc-0.9.26/win32/include/vadefs.h +11 -0
- data/ext/tcc/tcc-0.9.26/win32/include/values.h +4 -0
- data/ext/tcc/tcc-0.9.26/win32/include/wchar.h +871 -0
- data/ext/tcc/tcc-0.9.26/win32/include/wctype.h +172 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/basetsd.h +149 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/basetyps.h +85 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/guiddef.h +151 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/intrin.h +11 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/poppack.h +8 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack1.h +8 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack2.h +8 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack4.h +8 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack8.h +8 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/reason.h +80 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/specstrings.h +7 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/stralign.h +154 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/tvout.h +79 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/winbase.h +2951 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/wincon.h +301 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/windef.h +293 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/windows.h +123 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/winerror.h +3166 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/wingdi.h +4080 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/winnetwk.h +476 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/winnls.h +765 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/winnt.h +5770 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/winreg.h +272 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/winuser.h +5651 -0
- data/ext/tcc/tcc-0.9.26/win32/include/winapi/winver.h +160 -0
- data/ext/tcc/tcc-0.9.26/win32/lib/chkstk.S +191 -0
- data/ext/tcc/tcc-0.9.26/win32/lib/crt1.c +34 -0
- data/ext/tcc/tcc-0.9.26/win32/lib/dllcrt1.c +13 -0
- data/ext/tcc/tcc-0.9.26/win32/lib/dllmain.c +9 -0
- data/ext/tcc/tcc-0.9.26/win32/lib/gdi32.def +337 -0
- data/ext/tcc/tcc-0.9.26/win32/lib/kernel32.def +765 -0
- data/ext/tcc/tcc-0.9.26/win32/lib/msvcrt.def +1399 -0
- data/ext/tcc/tcc-0.9.26/win32/lib/user32.def +654 -0
- data/ext/tcc/tcc-0.9.26/win32/lib/wincrt1.c +64 -0
- data/ext/tcc/tcc-0.9.26/win32/tcc-win32.txt +156 -0
- data/ext/tcc/tcc-0.9.26/win32/tools/tiny_impdef.c +243 -0
- data/ext/tcc/tcc-0.9.26/win32/tools/tiny_libmaker.c +258 -0
- data/ext/tcc/tcc-0.9.26/x86_64-asm.h +448 -0
- data/ext/tcc/tcc-0.9.26/x86_64-gen.c +1701 -0
- data/lib/tcc.rb +291 -0
- data/tcc.gemspec +15 -0
- metadata +343 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
#ifndef LIBTCC_H
|
2
|
+
#define LIBTCC_H
|
3
|
+
|
4
|
+
#ifndef LIBTCCAPI
|
5
|
+
# define LIBTCCAPI
|
6
|
+
#endif
|
7
|
+
|
8
|
+
#ifdef __cplusplus
|
9
|
+
extern "C" {
|
10
|
+
#endif
|
11
|
+
|
12
|
+
struct TCCState;
|
13
|
+
|
14
|
+
typedef struct TCCState TCCState;
|
15
|
+
|
16
|
+
/* create a new TCC compilation context */
|
17
|
+
LIBTCCAPI TCCState *tcc_new(void);
|
18
|
+
|
19
|
+
/* free a TCC compilation context */
|
20
|
+
LIBTCCAPI void tcc_delete(TCCState *s);
|
21
|
+
|
22
|
+
/* set CONFIG_TCCDIR at runtime */
|
23
|
+
LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path);
|
24
|
+
|
25
|
+
/* set error/warning display callback */
|
26
|
+
LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque,
|
27
|
+
void (*error_func)(void *opaque, const char *msg));
|
28
|
+
|
29
|
+
/* set options as from command line (multiple supported) */
|
30
|
+
LIBTCCAPI int tcc_set_options(TCCState *s, const char *str);
|
31
|
+
|
32
|
+
/*****************************/
|
33
|
+
/* preprocessor */
|
34
|
+
|
35
|
+
/* add include path */
|
36
|
+
LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
|
37
|
+
|
38
|
+
/* add in system include path */
|
39
|
+
LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname);
|
40
|
+
|
41
|
+
/* define preprocessor symbol 'sym'. Can put optional value */
|
42
|
+
LIBTCCAPI void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
|
43
|
+
|
44
|
+
/* undefine preprocess symbol 'sym' */
|
45
|
+
LIBTCCAPI void tcc_undefine_symbol(TCCState *s, const char *sym);
|
46
|
+
|
47
|
+
/*****************************/
|
48
|
+
/* compiling */
|
49
|
+
|
50
|
+
/* add a file (C file, dll, object, library, ld script). Return -1 if error. */
|
51
|
+
LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename);
|
52
|
+
|
53
|
+
/* compile a string containing a C source. Return -1 if error. */
|
54
|
+
LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf);
|
55
|
+
|
56
|
+
/*****************************/
|
57
|
+
/* linking commands */
|
58
|
+
|
59
|
+
/* set output type. MUST BE CALLED before any compilation */
|
60
|
+
LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type);
|
61
|
+
#define TCC_OUTPUT_MEMORY 0 /* output will be run in memory (default) */
|
62
|
+
#define TCC_OUTPUT_EXE 1 /* executable file */
|
63
|
+
#define TCC_OUTPUT_DLL 2 /* dynamic library */
|
64
|
+
#define TCC_OUTPUT_OBJ 3 /* object file */
|
65
|
+
#define TCC_OUTPUT_PREPROCESS 4 /* only preprocess (used internally) */
|
66
|
+
|
67
|
+
/* equivalent to -Lpath option */
|
68
|
+
LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname);
|
69
|
+
|
70
|
+
/* the library name is the same as the argument of the '-l' option */
|
71
|
+
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
|
72
|
+
|
73
|
+
/* add a symbol to the compiled program */
|
74
|
+
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val);
|
75
|
+
|
76
|
+
/* output an executable, library or object file. DO NOT call
|
77
|
+
tcc_relocate() before. */
|
78
|
+
LIBTCCAPI int tcc_output_file(TCCState *s, const char *filename);
|
79
|
+
|
80
|
+
/* link and run main() function and return its value. DO NOT call
|
81
|
+
tcc_relocate() before. */
|
82
|
+
LIBTCCAPI int tcc_run(TCCState *s, int argc, char **argv);
|
83
|
+
|
84
|
+
/* do all relocations (needed before using tcc_get_symbol()) */
|
85
|
+
LIBTCCAPI int tcc_relocate(TCCState *s1, void *ptr);
|
86
|
+
/* possible values for 'ptr':
|
87
|
+
- TCC_RELOCATE_AUTO : Allocate and manage memory internally
|
88
|
+
- NULL : return required memory size for the step below
|
89
|
+
- memory address : copy code to memory passed by the caller
|
90
|
+
returns -1 if error. */
|
91
|
+
#define TCC_RELOCATE_AUTO (void*)1
|
92
|
+
|
93
|
+
/* Same as `tcc_relocate(s1, TCC_RELOCATE_AUTO)` */
|
94
|
+
LIBTCCAPI int tcc_relocate_auto(TCCState *s1);
|
95
|
+
|
96
|
+
/* return symbol value or NULL if not found */
|
97
|
+
LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name);
|
98
|
+
|
99
|
+
#ifdef __cplusplus
|
100
|
+
}
|
101
|
+
#endif
|
102
|
+
|
103
|
+
#endif
|
@@ -0,0 +1,234 @@
|
|
1
|
+
/* Table of DBX symbol codes for the GNU system.
|
2
|
+
Copyright (C) 1988, 1997 Free Software Foundation, Inc.
|
3
|
+
This file is part of the GNU C Library.
|
4
|
+
|
5
|
+
The GNU C Library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Library General Public License as
|
7
|
+
published by the Free Software Foundation; either version 2 of the
|
8
|
+
License, or (at your option) any later version.
|
9
|
+
|
10
|
+
The GNU C Library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Library General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Library General Public
|
16
|
+
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
17
|
+
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
18
|
+
Boston, MA 02111-1307, USA. */
|
19
|
+
|
20
|
+
/* This contains contribution from Cygnus Support. */
|
21
|
+
|
22
|
+
/* Global variable. Only the name is significant.
|
23
|
+
To find the address, look in the corresponding external symbol. */
|
24
|
+
__define_stab (N_GSYM, 0x20, "GSYM")
|
25
|
+
|
26
|
+
/* Function name for BSD Fortran. Only the name is significant.
|
27
|
+
To find the address, look in the corresponding external symbol. */
|
28
|
+
__define_stab (N_FNAME, 0x22, "FNAME")
|
29
|
+
|
30
|
+
/* Function name or text-segment variable for C. Value is its address.
|
31
|
+
Desc is supposedly starting line number, but GCC doesn't set it
|
32
|
+
and DBX seems not to miss it. */
|
33
|
+
__define_stab (N_FUN, 0x24, "FUN")
|
34
|
+
|
35
|
+
/* Data-segment variable with internal linkage. Value is its address.
|
36
|
+
"Static Sym". */
|
37
|
+
__define_stab (N_STSYM, 0x26, "STSYM")
|
38
|
+
|
39
|
+
/* BSS-segment variable with internal linkage. Value is its address. */
|
40
|
+
__define_stab (N_LCSYM, 0x28, "LCSYM")
|
41
|
+
|
42
|
+
/* Name of main routine. Only the name is significant.
|
43
|
+
This is not used in C. */
|
44
|
+
__define_stab (N_MAIN, 0x2a, "MAIN")
|
45
|
+
|
46
|
+
/* Global symbol in Pascal.
|
47
|
+
Supposedly the value is its line number; I'm skeptical. */
|
48
|
+
__define_stab (N_PC, 0x30, "PC")
|
49
|
+
|
50
|
+
/* Number of symbols: 0, files,,funcs,lines according to Ultrix V4.0. */
|
51
|
+
__define_stab (N_NSYMS, 0x32, "NSYMS")
|
52
|
+
|
53
|
+
/* "No DST map for sym: name, ,0,type,ignored" according to Ultrix V4.0. */
|
54
|
+
__define_stab (N_NOMAP, 0x34, "NOMAP")
|
55
|
+
|
56
|
+
/* New stab from Solaris. I don't know what it means, but it
|
57
|
+
don't seem to contain useful information. */
|
58
|
+
__define_stab (N_OBJ, 0x38, "OBJ")
|
59
|
+
|
60
|
+
/* New stab from Solaris. I don't know what it means, but it
|
61
|
+
don't seem to contain useful information. Possibly related to the
|
62
|
+
optimization flags used in this module. */
|
63
|
+
__define_stab (N_OPT, 0x3c, "OPT")
|
64
|
+
|
65
|
+
/* Register variable. Value is number of register. */
|
66
|
+
__define_stab (N_RSYM, 0x40, "RSYM")
|
67
|
+
|
68
|
+
/* Modula-2 compilation unit. Can someone say what info it contains? */
|
69
|
+
__define_stab (N_M2C, 0x42, "M2C")
|
70
|
+
|
71
|
+
/* Line number in text segment. Desc is the line number;
|
72
|
+
value is corresponding address. */
|
73
|
+
__define_stab (N_SLINE, 0x44, "SLINE")
|
74
|
+
|
75
|
+
/* Similar, for data segment. */
|
76
|
+
__define_stab (N_DSLINE, 0x46, "DSLINE")
|
77
|
+
|
78
|
+
/* Similar, for bss segment. */
|
79
|
+
__define_stab (N_BSLINE, 0x48, "BSLINE")
|
80
|
+
|
81
|
+
/* Sun's source-code browser stabs. ?? Don't know what the fields are.
|
82
|
+
Supposedly the field is "path to associated .cb file". THIS VALUE
|
83
|
+
OVERLAPS WITH N_BSLINE! */
|
84
|
+
__define_stab (N_BROWS, 0x48, "BROWS")
|
85
|
+
|
86
|
+
/* GNU Modula-2 definition module dependency. Value is the modification time
|
87
|
+
of the definition file. Other is non-zero if it is imported with the
|
88
|
+
GNU M2 keyword %INITIALIZE. Perhaps N_M2C can be used if there
|
89
|
+
are enough empty fields? */
|
90
|
+
__define_stab(N_DEFD, 0x4a, "DEFD")
|
91
|
+
|
92
|
+
/* THE FOLLOWING TWO STAB VALUES CONFLICT. Happily, one is for Modula-2
|
93
|
+
and one is for C++. Still,... */
|
94
|
+
/* GNU C++ exception variable. Name is variable name. */
|
95
|
+
__define_stab (N_EHDECL, 0x50, "EHDECL")
|
96
|
+
/* Modula2 info "for imc": name,,0,0,0 according to Ultrix V4.0. */
|
97
|
+
__define_stab (N_MOD2, 0x50, "MOD2")
|
98
|
+
|
99
|
+
/* GNU C++ `catch' clause. Value is its address. Desc is nonzero if
|
100
|
+
this entry is immediately followed by a CAUGHT stab saying what exception
|
101
|
+
was caught. Multiple CAUGHT stabs means that multiple exceptions
|
102
|
+
can be caught here. If Desc is 0, it means all exceptions are caught
|
103
|
+
here. */
|
104
|
+
__define_stab (N_CATCH, 0x54, "CATCH")
|
105
|
+
|
106
|
+
/* Structure or union element. Value is offset in the structure. */
|
107
|
+
__define_stab (N_SSYM, 0x60, "SSYM")
|
108
|
+
|
109
|
+
/* Name of main source file.
|
110
|
+
Value is starting text address of the compilation. */
|
111
|
+
__define_stab (N_SO, 0x64, "SO")
|
112
|
+
|
113
|
+
/* Automatic variable in the stack. Value is offset from frame pointer.
|
114
|
+
Also used for type descriptions. */
|
115
|
+
__define_stab (N_LSYM, 0x80, "LSYM")
|
116
|
+
|
117
|
+
/* Beginning of an include file. Only Sun uses this.
|
118
|
+
In an object file, only the name is significant.
|
119
|
+
The Sun linker puts data into some of the other fields. */
|
120
|
+
__define_stab (N_BINCL, 0x82, "BINCL")
|
121
|
+
|
122
|
+
/* Name of sub-source file (#include file).
|
123
|
+
Value is starting text address of the compilation. */
|
124
|
+
__define_stab (N_SOL, 0x84, "SOL")
|
125
|
+
|
126
|
+
/* Parameter variable. Value is offset from argument pointer.
|
127
|
+
(On most machines the argument pointer is the same as the frame pointer. */
|
128
|
+
__define_stab (N_PSYM, 0xa0, "PSYM")
|
129
|
+
|
130
|
+
/* End of an include file. No name.
|
131
|
+
This and N_BINCL act as brackets around the file's output.
|
132
|
+
In an object file, there is no significant data in this entry.
|
133
|
+
The Sun linker puts data into some of the fields. */
|
134
|
+
__define_stab (N_EINCL, 0xa2, "EINCL")
|
135
|
+
|
136
|
+
/* Alternate entry point. Value is its address. */
|
137
|
+
__define_stab (N_ENTRY, 0xa4, "ENTRY")
|
138
|
+
|
139
|
+
/* Beginning of lexical block.
|
140
|
+
The desc is the nesting level in lexical blocks.
|
141
|
+
The value is the address of the start of the text for the block.
|
142
|
+
The variables declared inside the block *precede* the N_LBRAC symbol. */
|
143
|
+
__define_stab (N_LBRAC, 0xc0, "LBRAC")
|
144
|
+
|
145
|
+
/* Place holder for deleted include file. Replaces a N_BINCL and everything
|
146
|
+
up to the corresponding N_EINCL. The Sun linker generates these when
|
147
|
+
it finds multiple identical copies of the symbols from an include file.
|
148
|
+
This appears only in output from the Sun linker. */
|
149
|
+
__define_stab (N_EXCL, 0xc2, "EXCL")
|
150
|
+
|
151
|
+
/* Modula-2 scope information. Can someone say what info it contains? */
|
152
|
+
__define_stab (N_SCOPE, 0xc4, "SCOPE")
|
153
|
+
|
154
|
+
/* End of a lexical block. Desc matches the N_LBRAC's desc.
|
155
|
+
The value is the address of the end of the text for the block. */
|
156
|
+
__define_stab (N_RBRAC, 0xe0, "RBRAC")
|
157
|
+
|
158
|
+
/* Begin named common block. Only the name is significant. */
|
159
|
+
__define_stab (N_BCOMM, 0xe2, "BCOMM")
|
160
|
+
|
161
|
+
/* End named common block. Only the name is significant
|
162
|
+
(and it should match the N_BCOMM). */
|
163
|
+
__define_stab (N_ECOMM, 0xe4, "ECOMM")
|
164
|
+
|
165
|
+
/* End common (local name): value is address.
|
166
|
+
I'm not sure how this is used. */
|
167
|
+
__define_stab (N_ECOML, 0xe8, "ECOML")
|
168
|
+
|
169
|
+
/* These STAB's are used on Gould systems for Non-Base register symbols
|
170
|
+
or something like that. FIXME. I have assigned the values at random
|
171
|
+
since I don't have a Gould here. Fixups from Gould folk welcome... */
|
172
|
+
__define_stab (N_NBTEXT, 0xF0, "NBTEXT")
|
173
|
+
__define_stab (N_NBDATA, 0xF2, "NBDATA")
|
174
|
+
__define_stab (N_NBBSS, 0xF4, "NBBSS")
|
175
|
+
__define_stab (N_NBSTS, 0xF6, "NBSTS")
|
176
|
+
__define_stab (N_NBLCS, 0xF8, "NBLCS")
|
177
|
+
|
178
|
+
/* Second symbol entry containing a length-value for the preceding entry.
|
179
|
+
The value is the length. */
|
180
|
+
__define_stab (N_LENG, 0xfe, "LENG")
|
181
|
+
|
182
|
+
/* The above information, in matrix format.
|
183
|
+
|
184
|
+
STAB MATRIX
|
185
|
+
_________________________________________________
|
186
|
+
| 00 - 1F are not dbx stab symbols |
|
187
|
+
| In most cases, the low bit is the EXTernal bit|
|
188
|
+
|
189
|
+
| 00 UNDEF | 02 ABS | 04 TEXT | 06 DATA |
|
190
|
+
| 01 |EXT | 03 |EXT | 05 |EXT | 07 |EXT |
|
191
|
+
|
192
|
+
| 08 BSS | 0A INDR | 0C FN_SEQ | 0E |
|
193
|
+
| 09 |EXT | 0B | 0D | 0F |
|
194
|
+
|
195
|
+
| 10 | 12 COMM | 14 SETA | 16 SETT |
|
196
|
+
| 11 | 13 | 15 | 17 |
|
197
|
+
|
198
|
+
| 18 SETD | 1A SETB | 1C SETV | 1E WARNING|
|
199
|
+
| 19 | 1B | 1D | 1F FN |
|
200
|
+
|
201
|
+
|_______________________________________________|
|
202
|
+
| Debug entries with bit 01 set are unused. |
|
203
|
+
| 20 GSYM | 22 FNAME | 24 FUN | 26 STSYM |
|
204
|
+
| 28 LCSYM | 2A MAIN | 2C | 2E |
|
205
|
+
| 30 PC | 32 NSYMS | 34 NOMAP | 36 |
|
206
|
+
| 38 OBJ | 3A | 3C OPT | 3E |
|
207
|
+
| 40 RSYM | 42 M2C | 44 SLINE | 46 DSLINE |
|
208
|
+
| 48 BSLINE*| 4A DEFD | 4C | 4E |
|
209
|
+
| 50 EHDECL*| 52 | 54 CATCH | 56 |
|
210
|
+
| 58 | 5A | 5C | 5E |
|
211
|
+
| 60 SSYM | 62 | 64 SO | 66 |
|
212
|
+
| 68 | 6A | 6C | 6E |
|
213
|
+
| 70 | 72 | 74 | 76 |
|
214
|
+
| 78 | 7A | 7C | 7E |
|
215
|
+
| 80 LSYM | 82 BINCL | 84 SOL | 86 |
|
216
|
+
| 88 | 8A | 8C | 8E |
|
217
|
+
| 90 | 92 | 94 | 96 |
|
218
|
+
| 98 | 9A | 9C | 9E |
|
219
|
+
| A0 PSYM | A2 EINCL | A4 ENTRY | A6 |
|
220
|
+
| A8 | AA | AC | AE |
|
221
|
+
| B0 | B2 | B4 | B6 |
|
222
|
+
| B8 | BA | BC | BE |
|
223
|
+
| C0 LBRAC | C2 EXCL | C4 SCOPE | C6 |
|
224
|
+
| C8 | CA | CC | CE |
|
225
|
+
| D0 | D2 | D4 | D6 |
|
226
|
+
| D8 | DA | DC | DE |
|
227
|
+
| E0 RBRAC | E2 BCOMM | E4 ECOMM | E6 |
|
228
|
+
| E8 ECOML | EA | EC | EE |
|
229
|
+
| F0 | F2 | F4 | F6 |
|
230
|
+
| F8 | FA | FC | FE LENG |
|
231
|
+
+-----------------------------------------------+
|
232
|
+
* 50 EHDECL is also MOD2.
|
233
|
+
* 48 BSLINE is also BROWS.
|
234
|
+
*/
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#ifndef __GNU_STAB__
|
2
|
+
|
3
|
+
/* Indicate the GNU stab.h is in use. */
|
4
|
+
|
5
|
+
#define __GNU_STAB__
|
6
|
+
|
7
|
+
#define __define_stab(NAME, CODE, STRING) NAME=CODE,
|
8
|
+
|
9
|
+
enum __stab_debug_code
|
10
|
+
{
|
11
|
+
#include "stab.def"
|
12
|
+
LAST_UNUSED_STAB_CODE
|
13
|
+
};
|
14
|
+
|
15
|
+
#undef __define_stab
|
16
|
+
|
17
|
+
#endif /* __GNU_STAB_ */
|
@@ -0,0 +1,2332 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
|
2
|
+
<html>
|
3
|
+
<!-- Created on February 15, 2013 by texi2html 1.82
|
4
|
+
texi2html was written by:
|
5
|
+
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.
|
9
|
+
Maintained by: Many creative people.
|
10
|
+
Send bugs and suggestions to <texi2html-bug@nongnu.org>
|
11
|
+
-->
|
12
|
+
<head>
|
13
|
+
<title>Tiny C Compiler Reference Documentation</title>
|
14
|
+
|
15
|
+
<meta name="description" content="Tiny C Compiler Reference Documentation">
|
16
|
+
<meta name="keywords" content="Tiny C Compiler Reference Documentation">
|
17
|
+
<meta name="resource-type" content="document">
|
18
|
+
<meta name="distribution" content="global">
|
19
|
+
<meta name="Generator" content="texi2html 1.82">
|
20
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
21
|
+
<style type="text/css">
|
22
|
+
<!--
|
23
|
+
a.summary-letter {text-decoration: none}
|
24
|
+
blockquote.smallquotation {font-size: smaller}
|
25
|
+
pre.display {font-family: serif}
|
26
|
+
pre.format {font-family: serif}
|
27
|
+
pre.menu-comment {font-family: serif}
|
28
|
+
pre.menu-preformatted {font-family: serif}
|
29
|
+
pre.smalldisplay {font-family: serif; font-size: smaller}
|
30
|
+
pre.smallexample {font-size: smaller}
|
31
|
+
pre.smallformat {font-family: serif; font-size: smaller}
|
32
|
+
pre.smalllisp {font-size: smaller}
|
33
|
+
span.roman {font-family:serif; font-weight:normal;}
|
34
|
+
span.sansserif {font-family:sans-serif; font-weight:normal;}
|
35
|
+
ul.toc {list-style: none}
|
36
|
+
-->
|
37
|
+
</style>
|
38
|
+
|
39
|
+
|
40
|
+
</head>
|
41
|
+
|
42
|
+
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
|
43
|
+
|
44
|
+
<a name="Top"></a>
|
45
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
46
|
+
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
47
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
48
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
49
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
50
|
+
</tr></table>
|
51
|
+
<a name="Tiny-C-Compiler-Reference-Documentation"></a>
|
52
|
+
<h1 class="settitle">Tiny C Compiler Reference Documentation</h1>
|
53
|
+
|
54
|
+
<p>This manual documents version 0.9.26 of the Tiny C Compiler.
|
55
|
+
</p>
|
56
|
+
<table class="menu" border="0" cellspacing="0">
|
57
|
+
<tr><td align="left" valign="top"><a href="#Introduction">1. Introduction</a></td><td> </td><td align="left" valign="top"> Introduction to tcc.
|
58
|
+
</td></tr>
|
59
|
+
<tr><td align="left" valign="top"><a href="#Invoke">2. Command line invocation</a></td><td> </td><td align="left" valign="top"> Invocation of tcc (command line, options).
|
60
|
+
</td></tr>
|
61
|
+
<tr><td align="left" valign="top"><a href="#Clang">3. C language support</a></td><td> </td><td align="left" valign="top"> ANSI C and extensions.
|
62
|
+
</td></tr>
|
63
|
+
<tr><td align="left" valign="top"><a href="#asm">4. TinyCC Assembler</a></td><td> </td><td align="left" valign="top"> Assembler syntax.
|
64
|
+
</td></tr>
|
65
|
+
<tr><td align="left" valign="top"><a href="#linker">5. TinyCC Linker</a></td><td> </td><td align="left" valign="top"> Output file generation and supported targets.
|
66
|
+
</td></tr>
|
67
|
+
<tr><td align="left" valign="top"><a href="#Bounds">6. TinyCC Memory and Bound checks</a></td><td> </td><td align="left" valign="top"> Automatic bounds-checking of C code.
|
68
|
+
</td></tr>
|
69
|
+
<tr><td align="left" valign="top"><a href="#Libtcc">7. The <code>libtcc</code> library</a></td><td> </td><td align="left" valign="top"> The libtcc library.
|
70
|
+
</td></tr>
|
71
|
+
<tr><td align="left" valign="top"><a href="#devel">8. Developer’s guide</a></td><td> </td><td align="left" valign="top"> Guide for Developers.
|
72
|
+
</td></tr>
|
73
|
+
</table>
|
74
|
+
|
75
|
+
|
76
|
+
<hr size="1">
|
77
|
+
<a name="Introduction"></a>
|
78
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
79
|
+
<tr><td valign="middle" align="left">[<a href="#Top" title="Previous section in reading order"> < </a>]</td>
|
80
|
+
<td valign="middle" align="left">[<a href="#Invoke" title="Next section in reading order"> > </a>]</td>
|
81
|
+
<td valign="middle" align="left"> </td>
|
82
|
+
<td valign="middle" align="left">[<a href="#Top" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
83
|
+
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
|
84
|
+
<td valign="middle" align="left">[<a href="#Invoke" title="Next chapter"> >> </a>]</td>
|
85
|
+
<td valign="middle" align="left"> </td>
|
86
|
+
<td valign="middle" align="left"> </td>
|
87
|
+
<td valign="middle" align="left"> </td>
|
88
|
+
<td valign="middle" align="left"> </td>
|
89
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
90
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
91
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
92
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
93
|
+
</tr></table>
|
94
|
+
<a name="Introduction-1"></a>
|
95
|
+
<h1 class="chapter">1. Introduction</h1>
|
96
|
+
|
97
|
+
<p>TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C
|
98
|
+
compilers, it is meant to be self-relying: you do not need an
|
99
|
+
external assembler or linker because TCC does that for you.
|
100
|
+
</p>
|
101
|
+
<p>TCC compiles so <em>fast</em> that even for big projects <code>Makefile</code>s may
|
102
|
+
not be necessary.
|
103
|
+
</p>
|
104
|
+
<p>TCC not only supports ANSI C, but also most of the new ISO C99
|
105
|
+
standard and many GNUC extensions including inline assembly.
|
106
|
+
</p>
|
107
|
+
<p>TCC can also be used to make <em>C scripts</em>, i.e. pieces of C source
|
108
|
+
that you run as a Perl or Python script. Compilation is so fast that
|
109
|
+
your script will be as fast as if it was an executable.
|
110
|
+
</p>
|
111
|
+
<p>TCC can also automatically generate memory and bound checks
|
112
|
+
(see section <a href="#Bounds">TinyCC Memory and Bound checks</a>) while allowing all C pointers operations. TCC can do
|
113
|
+
these checks even if non patched libraries are used.
|
114
|
+
</p>
|
115
|
+
<p>With <code>libtcc</code>, you can use TCC as a backend for dynamic code
|
116
|
+
generation (see section <a href="#Libtcc">The <code>libtcc</code> library</a>).
|
117
|
+
</p>
|
118
|
+
<p>TCC mainly supports the i386 target on Linux and Windows. There are alpha
|
119
|
+
ports for the ARM (<code>arm-tcc</code>) and the TMS320C67xx targets
|
120
|
+
(<code>c67-tcc</code>). More information about the ARM port is available at
|
121
|
+
<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>.
|
122
|
+
</p>
|
123
|
+
<p>For usage on Windows, see also <a href="tcc-win32.txt">tcc-win32.txt</a>.
|
124
|
+
</p>
|
125
|
+
<hr size="6">
|
126
|
+
<a name="Invoke"></a>
|
127
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
128
|
+
<tr><td valign="middle" align="left">[<a href="#Introduction" title="Previous section in reading order"> < </a>]</td>
|
129
|
+
<td valign="middle" align="left">[<a href="#Quick-start" title="Next section in reading order"> > </a>]</td>
|
130
|
+
<td valign="middle" align="left"> </td>
|
131
|
+
<td valign="middle" align="left">[<a href="#Introduction" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
132
|
+
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
|
133
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Next chapter"> >> </a>]</td>
|
134
|
+
<td valign="middle" align="left"> </td>
|
135
|
+
<td valign="middle" align="left"> </td>
|
136
|
+
<td valign="middle" align="left"> </td>
|
137
|
+
<td valign="middle" align="left"> </td>
|
138
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
139
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
140
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
141
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
142
|
+
</tr></table>
|
143
|
+
<a name="Command-line-invocation"></a>
|
144
|
+
<h1 class="chapter">2. Command line invocation</h1>
|
145
|
+
|
146
|
+
<hr size="6">
|
147
|
+
<a name="Quick-start"></a>
|
148
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
149
|
+
<tr><td valign="middle" align="left">[<a href="#Invoke" title="Previous section in reading order"> < </a>]</td>
|
150
|
+
<td valign="middle" align="left">[<a href="#Option-summary" title="Next section in reading order"> > </a>]</td>
|
151
|
+
<td valign="middle" align="left"> </td>
|
152
|
+
<td valign="middle" align="left">[<a href="#Invoke" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
153
|
+
<td valign="middle" align="left">[<a href="#Invoke" title="Up section"> Up </a>]</td>
|
154
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Next chapter"> >> </a>]</td>
|
155
|
+
<td valign="middle" align="left"> </td>
|
156
|
+
<td valign="middle" align="left"> </td>
|
157
|
+
<td valign="middle" align="left"> </td>
|
158
|
+
<td valign="middle" align="left"> </td>
|
159
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
160
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
161
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
162
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
163
|
+
</tr></table>
|
164
|
+
<h2 class="section">2.1 Quick start</h2>
|
165
|
+
|
166
|
+
<table><tr><td> </td><td><pre class="example">usage: tcc [options] [<var>infile1</var> <var>infile2</var>…] [‘<samp>-run</samp>’ <var>infile</var> <var>args</var>…]
|
167
|
+
</pre></td></tr></table>
|
168
|
+
|
169
|
+
<p>TCC options are a very much like gcc options. The main difference is that TCC
|
170
|
+
can also execute directly the resulting program and give it runtime
|
171
|
+
arguments.
|
172
|
+
</p>
|
173
|
+
<p>Here are some examples to understand the logic:
|
174
|
+
</p>
|
175
|
+
<dl compact="compact">
|
176
|
+
<dt> <code>‘<samp>tcc -run a.c</samp>’</code></dt>
|
177
|
+
<dd><p>Compile ‘<tt>a.c</tt>’ and execute it directly
|
178
|
+
</p>
|
179
|
+
</dd>
|
180
|
+
<dt> <code>‘<samp>tcc -run a.c arg1</samp>’</code></dt>
|
181
|
+
<dd><p>Compile a.c and execute it directly. arg1 is given as first argument to
|
182
|
+
the <code>main()</code> of a.c.
|
183
|
+
</p>
|
184
|
+
</dd>
|
185
|
+
<dt> <code>‘<samp>tcc a.c -run b.c arg1</samp>’</code></dt>
|
186
|
+
<dd><p>Compile ‘<tt>a.c</tt>’ and ‘<tt>b.c</tt>’, link them together and execute them. arg1 is given
|
187
|
+
as first argument to the <code>main()</code> of the resulting program.
|
188
|
+
</p>
|
189
|
+
</dd>
|
190
|
+
<dt> <code>‘<samp>tcc -o myprog a.c b.c</samp>’</code></dt>
|
191
|
+
<dd><p>Compile ‘<tt>a.c</tt>’ and ‘<tt>b.c</tt>’, link them and generate the executable ‘<tt>myprog</tt>’.
|
192
|
+
</p>
|
193
|
+
</dd>
|
194
|
+
<dt> <code>‘<samp>tcc -o myprog a.o b.o</samp>’</code></dt>
|
195
|
+
<dd><p>link ‘<tt>a.o</tt>’ and ‘<tt>b.o</tt>’ together and generate the executable ‘<tt>myprog</tt>’.
|
196
|
+
</p>
|
197
|
+
</dd>
|
198
|
+
<dt> <code>‘<samp>tcc -c a.c</samp>’</code></dt>
|
199
|
+
<dd><p>Compile ‘<tt>a.c</tt>’ and generate object file ‘<tt>a.o</tt>’.
|
200
|
+
</p>
|
201
|
+
</dd>
|
202
|
+
<dt> <code>‘<samp>tcc -c asmfile.S</samp>’</code></dt>
|
203
|
+
<dd><p>Preprocess with C preprocess and assemble ‘<tt>asmfile.S</tt>’ and generate
|
204
|
+
object file ‘<tt>asmfile.o</tt>’.
|
205
|
+
</p>
|
206
|
+
</dd>
|
207
|
+
<dt> <code>‘<samp>tcc -c asmfile.s</samp>’</code></dt>
|
208
|
+
<dd><p>Assemble (but not preprocess) ‘<tt>asmfile.s</tt>’ and generate object file
|
209
|
+
‘<tt>asmfile.o</tt>’.
|
210
|
+
</p>
|
211
|
+
</dd>
|
212
|
+
<dt> <code>‘<samp>tcc -r -o ab.o a.c b.c</samp>’</code></dt>
|
213
|
+
<dd><p>Compile ‘<tt>a.c</tt>’ and ‘<tt>b.c</tt>’, link them together and generate the object file ‘<tt>ab.o</tt>’.
|
214
|
+
</p>
|
215
|
+
</dd>
|
216
|
+
</dl>
|
217
|
+
|
218
|
+
<p>Scripting:
|
219
|
+
</p>
|
220
|
+
<p>TCC can be invoked from <em>scripts</em>, just as shell scripts. You just
|
221
|
+
need to add <code>#!/usr/local/bin/tcc -run</code> at the start of your C source:
|
222
|
+
</p>
|
223
|
+
<table><tr><td> </td><td><pre class="example">#!/usr/local/bin/tcc -run
|
224
|
+
#include <stdio.h>
|
225
|
+
|
226
|
+
int main()
|
227
|
+
{
|
228
|
+
printf("Hello World\n");
|
229
|
+
return 0;
|
230
|
+
}
|
231
|
+
</pre></td></tr></table>
|
232
|
+
|
233
|
+
<p>TCC can read C source code from <em>standard input</em> when ‘<samp>-</samp>’ is used in
|
234
|
+
place of ‘<samp>infile</samp>’. Example:
|
235
|
+
</p>
|
236
|
+
<table><tr><td> </td><td><pre class="example">echo 'main(){puts("hello");}' | tcc -run -
|
237
|
+
</pre></td></tr></table>
|
238
|
+
|
239
|
+
<hr size="6">
|
240
|
+
<a name="Option-summary"></a>
|
241
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
242
|
+
<tr><td valign="middle" align="left">[<a href="#Quick-start" title="Previous section in reading order"> < </a>]</td>
|
243
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Next section in reading order"> > </a>]</td>
|
244
|
+
<td valign="middle" align="left"> </td>
|
245
|
+
<td valign="middle" align="left">[<a href="#Invoke" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
246
|
+
<td valign="middle" align="left">[<a href="#Invoke" title="Up section"> Up </a>]</td>
|
247
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Next chapter"> >> </a>]</td>
|
248
|
+
<td valign="middle" align="left"> </td>
|
249
|
+
<td valign="middle" align="left"> </td>
|
250
|
+
<td valign="middle" align="left"> </td>
|
251
|
+
<td valign="middle" align="left"> </td>
|
252
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
253
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
254
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
255
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
256
|
+
</tr></table>
|
257
|
+
<h2 class="section">2.2 Option summary</h2>
|
258
|
+
|
259
|
+
<p>General Options:
|
260
|
+
</p>
|
261
|
+
<dl compact="compact">
|
262
|
+
<dt> ‘<samp>-c</samp>’</dt>
|
263
|
+
<dd><p>Generate an object file.
|
264
|
+
</p>
|
265
|
+
</dd>
|
266
|
+
<dt> ‘<samp>-o outfile</samp>’</dt>
|
267
|
+
<dd><p>Put object file, executable, or dll into output file ‘<tt>outfile</tt>’.
|
268
|
+
</p>
|
269
|
+
</dd>
|
270
|
+
<dt> ‘<samp>-run source [args...]</samp>’</dt>
|
271
|
+
<dd><p>Compile file <var>source</var> and run it with the command line arguments
|
272
|
+
<var>args</var>. In order to be able to give more than one argument to a
|
273
|
+
script, several TCC options can be given <em>after</em> the
|
274
|
+
‘<samp>-run</samp>’ option, separated by spaces:
|
275
|
+
</p><table><tr><td> </td><td><pre class="example">tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
|
276
|
+
</pre></td></tr></table>
|
277
|
+
<p>In a script, it gives the following header:
|
278
|
+
</p><table><tr><td> </td><td><pre class="example">#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
|
279
|
+
</pre></td></tr></table>
|
280
|
+
|
281
|
+
</dd>
|
282
|
+
<dt> ‘<samp>-dumpversion</samp>’</dt>
|
283
|
+
<dd><p>Print only the compiler version and nothing else.
|
284
|
+
</p>
|
285
|
+
</dd>
|
286
|
+
<dt> ‘<samp>-v</samp>’</dt>
|
287
|
+
<dd><p>Display TCC version.
|
288
|
+
</p>
|
289
|
+
</dd>
|
290
|
+
<dt> ‘<samp>-vv</samp>’</dt>
|
291
|
+
<dd><p>Show included files. As sole argument, print search dirs (as below).
|
292
|
+
</p>
|
293
|
+
</dd>
|
294
|
+
<dt> ‘<samp>-bench</samp>’</dt>
|
295
|
+
<dd><p>Display compilation statistics.
|
296
|
+
</p>
|
297
|
+
</dd>
|
298
|
+
<dt> ‘<samp>-print-search-dirs</samp>’</dt>
|
299
|
+
<dd><p>Print the configured installation directory and a list of library
|
300
|
+
and include directories tcc will search.
|
301
|
+
</p>
|
302
|
+
</dd>
|
303
|
+
</dl>
|
304
|
+
|
305
|
+
<p>Preprocessor options:
|
306
|
+
</p>
|
307
|
+
<dl compact="compact">
|
308
|
+
<dt> ‘<samp>-Idir</samp>’</dt>
|
309
|
+
<dd><p>Specify an additional include path. Include paths are searched in the
|
310
|
+
order they are specified.
|
311
|
+
</p>
|
312
|
+
<p>System include paths are always searched after. The default system
|
313
|
+
include paths are: ‘<tt>/usr/local/include</tt>’, ‘<tt>/usr/include</tt>’
|
314
|
+
and ‘<tt>PREFIX/lib/tcc/include</tt>’. (‘<tt>PREFIX</tt>’ is usually
|
315
|
+
‘<tt>/usr</tt>’ or ‘<tt>/usr/local</tt>’).
|
316
|
+
</p>
|
317
|
+
</dd>
|
318
|
+
<dt> ‘<samp>-Dsym[=val]</samp>’</dt>
|
319
|
+
<dd><p>Define preprocessor symbol ‘<samp>sym</samp>’ to
|
320
|
+
val. If val is not present, its value is ‘<samp>1</samp>’. Function-like macros can
|
321
|
+
also be defined: ‘<samp>-DF(a)=a+1</samp>’
|
322
|
+
</p>
|
323
|
+
</dd>
|
324
|
+
<dt> ‘<samp>-Usym</samp>’</dt>
|
325
|
+
<dd><p>Undefine preprocessor symbol ‘<samp>sym</samp>’.
|
326
|
+
</p></dd>
|
327
|
+
</dl>
|
328
|
+
|
329
|
+
<p>Compilation flags:
|
330
|
+
</p>
|
331
|
+
<p>Note: each of the following warning options has a negative form beginning with
|
332
|
+
‘<samp>-fno-</samp>’.
|
333
|
+
</p>
|
334
|
+
<dl compact="compact">
|
335
|
+
<dt> ‘<samp>-funsigned-char</samp>’</dt>
|
336
|
+
<dd><p>Let the <code>char</code> type be unsigned.
|
337
|
+
</p>
|
338
|
+
</dd>
|
339
|
+
<dt> ‘<samp>-fsigned-char</samp>’</dt>
|
340
|
+
<dd><p>Let the <code>char</code> type be signed.
|
341
|
+
</p>
|
342
|
+
</dd>
|
343
|
+
<dt> ‘<samp>-fno-common</samp>’</dt>
|
344
|
+
<dd><p>Do not generate common symbols for uninitialized data.
|
345
|
+
</p>
|
346
|
+
</dd>
|
347
|
+
<dt> ‘<samp>-fleading-underscore</samp>’</dt>
|
348
|
+
<dd><p>Add a leading underscore at the beginning of each C symbol.
|
349
|
+
</p>
|
350
|
+
</dd>
|
351
|
+
</dl>
|
352
|
+
|
353
|
+
<p>Warning options:
|
354
|
+
</p>
|
355
|
+
<dl compact="compact">
|
356
|
+
<dt> ‘<samp>-w</samp>’</dt>
|
357
|
+
<dd><p>Disable all warnings.
|
358
|
+
</p>
|
359
|
+
</dd>
|
360
|
+
</dl>
|
361
|
+
|
362
|
+
<p>Note: each of the following warning options has a negative form beginning with
|
363
|
+
‘<samp>-Wno-</samp>’.
|
364
|
+
</p>
|
365
|
+
<dl compact="compact">
|
366
|
+
<dt> ‘<samp>-Wimplicit-function-declaration</samp>’</dt>
|
367
|
+
<dd><p>Warn about implicit function declaration.
|
368
|
+
</p>
|
369
|
+
</dd>
|
370
|
+
<dt> ‘<samp>-Wunsupported</samp>’</dt>
|
371
|
+
<dd><p>Warn about unsupported GCC features that are ignored by TCC.
|
372
|
+
</p>
|
373
|
+
</dd>
|
374
|
+
<dt> ‘<samp>-Wwrite-strings</samp>’</dt>
|
375
|
+
<dd><p>Make string constants be of type <code>const char *</code> instead of <code>char
|
376
|
+
*</code>.
|
377
|
+
</p>
|
378
|
+
</dd>
|
379
|
+
<dt> ‘<samp>-Werror</samp>’</dt>
|
380
|
+
<dd><p>Abort compilation if warnings are issued.
|
381
|
+
</p>
|
382
|
+
</dd>
|
383
|
+
<dt> ‘<samp>-Wall</samp>’ </dt>
|
384
|
+
<dd><p>Activate all warnings, except ‘<samp>-Werror</samp>’, ‘<samp>-Wunusupported</samp>’ and
|
385
|
+
‘<samp>-Wwrite-strings</samp>’.
|
386
|
+
</p>
|
387
|
+
</dd>
|
388
|
+
</dl>
|
389
|
+
|
390
|
+
<p>Linker options:
|
391
|
+
</p>
|
392
|
+
<dl compact="compact">
|
393
|
+
<dt> ‘<samp>-Ldir</samp>’</dt>
|
394
|
+
<dd><p>Specify an additional static library path for the ‘<samp>-l</samp>’ option. The
|
395
|
+
default library paths are ‘<tt>/usr/local/lib</tt>’, ‘<tt>/usr/lib</tt>’ and ‘<tt>/lib</tt>’.
|
396
|
+
</p>
|
397
|
+
</dd>
|
398
|
+
<dt> ‘<samp>-lxxx</samp>’</dt>
|
399
|
+
<dd><p>Link your program with dynamic library libxxx.so or static library
|
400
|
+
libxxx.a. The library is searched in the paths specified by the
|
401
|
+
‘<samp>-L</samp>’ option.
|
402
|
+
</p>
|
403
|
+
</dd>
|
404
|
+
<dt> ‘<samp>-Bdir</samp>’</dt>
|
405
|
+
<dd><p>Set the path where the tcc internal libraries (and include files) can be
|
406
|
+
found (default is ‘<tt>PREFIX/lib/tcc</tt>’).
|
407
|
+
</p>
|
408
|
+
</dd>
|
409
|
+
<dt> ‘<samp>-shared</samp>’</dt>
|
410
|
+
<dd><p>Generate a shared library instead of an executable.
|
411
|
+
</p>
|
412
|
+
</dd>
|
413
|
+
<dt> ‘<samp>-soname name</samp>’</dt>
|
414
|
+
<dd><p>set name for shared library to be used at runtime
|
415
|
+
</p>
|
416
|
+
</dd>
|
417
|
+
<dt> ‘<samp>-static</samp>’</dt>
|
418
|
+
<dd><p>Generate a statically linked executable (default is a shared linked
|
419
|
+
executable).
|
420
|
+
</p>
|
421
|
+
</dd>
|
422
|
+
<dt> ‘<samp>-rdynamic</samp>’</dt>
|
423
|
+
<dd><p>Export global symbols to the dynamic linker. It is useful when a library
|
424
|
+
opened with <code>dlopen()</code> needs to access executable symbols.
|
425
|
+
</p>
|
426
|
+
</dd>
|
427
|
+
<dt> ‘<samp>-r</samp>’</dt>
|
428
|
+
<dd><p>Generate an object file combining all input files.
|
429
|
+
</p>
|
430
|
+
</dd>
|
431
|
+
<dt> ‘<samp>-Wl,-rpath=path</samp>’</dt>
|
432
|
+
<dd><p>Put custom seatch path for dynamic libraries into executable.
|
433
|
+
</p>
|
434
|
+
</dd>
|
435
|
+
<dt> ‘<samp>-Wl,--oformat=fmt</samp>’</dt>
|
436
|
+
<dd><p>Use <var>fmt</var> as output format. The supported output formats are:
|
437
|
+
</p><dl compact="compact">
|
438
|
+
<dt> <code>elf32-i386</code></dt>
|
439
|
+
<dd><p>ELF output format (default)
|
440
|
+
</p></dd>
|
441
|
+
<dt> <code>binary</code></dt>
|
442
|
+
<dd><p>Binary image (only for executable output)
|
443
|
+
</p></dd>
|
444
|
+
<dt> <code>coff</code></dt>
|
445
|
+
<dd><p>COFF output format (only for executable output for TMS320C67xx target)
|
446
|
+
</p></dd>
|
447
|
+
</dl>
|
448
|
+
|
449
|
+
</dd>
|
450
|
+
<dt> ‘<samp>-Wl,-subsystem=console/gui/wince/...</samp>’</dt>
|
451
|
+
<dd><p>Set type for PE (Windows) executables.
|
452
|
+
</p>
|
453
|
+
</dd>
|
454
|
+
<dt> ‘<samp>-Wl,-[Ttext=# | section-alignment=# | file-alignment=# | image-base=# | stack=#]</samp>’</dt>
|
455
|
+
<dd><p>Modify executable layout.
|
456
|
+
</p>
|
457
|
+
</dd>
|
458
|
+
<dt> ‘<samp>-Wl,-Bsymbolic</samp>’</dt>
|
459
|
+
<dd><p>Set DT_SYMBOLIC tag.
|
460
|
+
</p>
|
461
|
+
</dd>
|
462
|
+
</dl>
|
463
|
+
|
464
|
+
<p>Debugger options:
|
465
|
+
</p>
|
466
|
+
<dl compact="compact">
|
467
|
+
<dt> ‘<samp>-g</samp>’</dt>
|
468
|
+
<dd><p>Generate run time debug information so that you get clear run time
|
469
|
+
error messages: <code> test.c:68: in function 'test5()': dereferencing
|
470
|
+
invalid pointer</code> instead of the laconic <code>Segmentation
|
471
|
+
fault</code>.
|
472
|
+
</p>
|
473
|
+
</dd>
|
474
|
+
<dt> ‘<samp>-b</samp>’</dt>
|
475
|
+
<dd><p>Generate additional support code to check
|
476
|
+
memory allocations and array/pointer bounds. ‘<samp>-g</samp>’ is implied. Note
|
477
|
+
that the generated code is slower and bigger in this case.
|
478
|
+
</p>
|
479
|
+
<p>Note: ‘<samp>-b</samp>’ is only available on i386 for the moment.
|
480
|
+
</p>
|
481
|
+
</dd>
|
482
|
+
<dt> ‘<samp>-bt N</samp>’</dt>
|
483
|
+
<dd><p>Display N callers in stack traces. This is useful with ‘<samp>-g</samp>’ or
|
484
|
+
‘<samp>-b</samp>’.
|
485
|
+
</p>
|
486
|
+
</dd>
|
487
|
+
</dl>
|
488
|
+
|
489
|
+
<p>Misc options:
|
490
|
+
</p>
|
491
|
+
<dl compact="compact">
|
492
|
+
<dt> ‘<samp>-MD</samp>’</dt>
|
493
|
+
<dd><p>Generate makefile fragment with dependencies.
|
494
|
+
</p>
|
495
|
+
</dd>
|
496
|
+
<dt> ‘<samp>-MF depfile</samp>’</dt>
|
497
|
+
<dd><p>Use ‘<tt>depfile</tt>’ as output for -MD.
|
498
|
+
</p>
|
499
|
+
</dd>
|
500
|
+
</dl>
|
501
|
+
|
502
|
+
<p>Note: GCC options ‘<samp>-Ox</samp>’, ‘<samp>-fx</samp>’ and ‘<samp>-mx</samp>’ are
|
503
|
+
ignored.
|
504
|
+
</p>
|
505
|
+
|
506
|
+
<hr size="6">
|
507
|
+
<a name="Clang"></a>
|
508
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
509
|
+
<tr><td valign="middle" align="left">[<a href="#Option-summary" title="Previous section in reading order"> < </a>]</td>
|
510
|
+
<td valign="middle" align="left">[<a href="#ANSI-C" title="Next section in reading order"> > </a>]</td>
|
511
|
+
<td valign="middle" align="left"> </td>
|
512
|
+
<td valign="middle" align="left">[<a href="#Invoke" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
513
|
+
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
|
514
|
+
<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> >> </a>]</td>
|
515
|
+
<td valign="middle" align="left"> </td>
|
516
|
+
<td valign="middle" align="left"> </td>
|
517
|
+
<td valign="middle" align="left"> </td>
|
518
|
+
<td valign="middle" align="left"> </td>
|
519
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
520
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
521
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
522
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
523
|
+
</tr></table>
|
524
|
+
<a name="C-language-support"></a>
|
525
|
+
<h1 class="chapter">3. C language support</h1>
|
526
|
+
|
527
|
+
<hr size="6">
|
528
|
+
<a name="ANSI-C"></a>
|
529
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
530
|
+
<tr><td valign="middle" align="left">[<a href="#Clang" title="Previous section in reading order"> < </a>]</td>
|
531
|
+
<td valign="middle" align="left">[<a href="#ISOC99-extensions" title="Next section in reading order"> > </a>]</td>
|
532
|
+
<td valign="middle" align="left"> </td>
|
533
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
534
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Up section"> Up </a>]</td>
|
535
|
+
<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> >> </a>]</td>
|
536
|
+
<td valign="middle" align="left"> </td>
|
537
|
+
<td valign="middle" align="left"> </td>
|
538
|
+
<td valign="middle" align="left"> </td>
|
539
|
+
<td valign="middle" align="left"> </td>
|
540
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
541
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
542
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
543
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
544
|
+
</tr></table>
|
545
|
+
<h2 class="section">3.1 ANSI C</h2>
|
546
|
+
|
547
|
+
<p>TCC implements all the ANSI C standard, including structure bit fields
|
548
|
+
and floating point numbers (<code>long double</code>, <code>double</code>, and
|
549
|
+
<code>float</code> fully supported).
|
550
|
+
</p>
|
551
|
+
<hr size="6">
|
552
|
+
<a name="ISOC99-extensions"></a>
|
553
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
554
|
+
<tr><td valign="middle" align="left">[<a href="#ANSI-C" title="Previous section in reading order"> < </a>]</td>
|
555
|
+
<td valign="middle" align="left">[<a href="#GNU-C-extensions" title="Next section in reading order"> > </a>]</td>
|
556
|
+
<td valign="middle" align="left"> </td>
|
557
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
558
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Up section"> Up </a>]</td>
|
559
|
+
<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> >> </a>]</td>
|
560
|
+
<td valign="middle" align="left"> </td>
|
561
|
+
<td valign="middle" align="left"> </td>
|
562
|
+
<td valign="middle" align="left"> </td>
|
563
|
+
<td valign="middle" align="left"> </td>
|
564
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
565
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
566
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
567
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
568
|
+
</tr></table>
|
569
|
+
<h2 class="section">3.2 ISOC99 extensions</h2>
|
570
|
+
|
571
|
+
<p>TCC implements many features of the new C standard: ISO C99. Currently
|
572
|
+
missing items are: complex and imaginary numbers and variable length
|
573
|
+
arrays.
|
574
|
+
</p>
|
575
|
+
<p>Currently implemented ISOC99 features:
|
576
|
+
</p>
|
577
|
+
<ul>
|
578
|
+
<li> 64 bit <code>long long</code> types are fully supported.
|
579
|
+
|
580
|
+
</li><li> The boolean type <code>_Bool</code> is supported.
|
581
|
+
|
582
|
+
</li><li> <code>__func__</code> is a string variable containing the current
|
583
|
+
function name.
|
584
|
+
|
585
|
+
</li><li> Variadic macros: <code>__VA_ARGS__</code> can be used for
|
586
|
+
function-like macros:
|
587
|
+
<table><tr><td> </td><td><pre class="example"> #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__)
|
588
|
+
</pre></td></tr></table>
|
589
|
+
|
590
|
+
<p><code>dprintf</code> can then be used with a variable number of parameters.
|
591
|
+
</p>
|
592
|
+
</li><li> Declarations can appear anywhere in a block (as in C++).
|
593
|
+
|
594
|
+
</li><li> Array and struct/union elements can be initialized in any order by
|
595
|
+
using designators:
|
596
|
+
<table><tr><td> </td><td><pre class="example"> struct { int x, y; } st[10] = { [0].x = 1, [0].y = 2 };
|
597
|
+
|
598
|
+
int tab[10] = { 1, 2, [5] = 5, [9] = 9};
|
599
|
+
</pre></td></tr></table>
|
600
|
+
|
601
|
+
</li><li> Compound initializers are supported:
|
602
|
+
<table><tr><td> </td><td><pre class="example"> int *p = (int []){ 1, 2, 3 };
|
603
|
+
</pre></td></tr></table>
|
604
|
+
<p>to initialize a pointer pointing to an initialized array. The same
|
605
|
+
works for structures and strings.
|
606
|
+
</p>
|
607
|
+
</li><li> Hexadecimal floating point constants are supported:
|
608
|
+
<table><tr><td> </td><td><pre class="example"> double d = 0x1234p10;
|
609
|
+
</pre></td></tr></table>
|
610
|
+
|
611
|
+
<p>is the same as writing
|
612
|
+
</p><table><tr><td> </td><td><pre class="example"> double d = 4771840.0;
|
613
|
+
</pre></td></tr></table>
|
614
|
+
|
615
|
+
</li><li> <code>inline</code> keyword is ignored.
|
616
|
+
|
617
|
+
</li><li> <code>restrict</code> keyword is ignored.
|
618
|
+
</li></ul>
|
619
|
+
|
620
|
+
<hr size="6">
|
621
|
+
<a name="GNU-C-extensions"></a>
|
622
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
623
|
+
<tr><td valign="middle" align="left">[<a href="#ISOC99-extensions" title="Previous section in reading order"> < </a>]</td>
|
624
|
+
<td valign="middle" align="left">[<a href="#TinyCC-extensions" title="Next section in reading order"> > </a>]</td>
|
625
|
+
<td valign="middle" align="left"> </td>
|
626
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
627
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Up section"> Up </a>]</td>
|
628
|
+
<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> >> </a>]</td>
|
629
|
+
<td valign="middle" align="left"> </td>
|
630
|
+
<td valign="middle" align="left"> </td>
|
631
|
+
<td valign="middle" align="left"> </td>
|
632
|
+
<td valign="middle" align="left"> </td>
|
633
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
634
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
635
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
636
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
637
|
+
</tr></table>
|
638
|
+
<h2 class="section">3.3 GNU C extensions</h2>
|
639
|
+
|
640
|
+
<p>TCC implements some GNU C extensions:
|
641
|
+
</p>
|
642
|
+
<ul>
|
643
|
+
<li> array designators can be used without ’=’:
|
644
|
+
<table><tr><td> </td><td><pre class="example"> int a[10] = { [0] 1, [5] 2, 3, 4 };
|
645
|
+
</pre></td></tr></table>
|
646
|
+
|
647
|
+
</li><li> Structure field designators can be a label:
|
648
|
+
<table><tr><td> </td><td><pre class="example"> struct { int x, y; } st = { x: 1, y: 1};
|
649
|
+
</pre></td></tr></table>
|
650
|
+
<p>instead of
|
651
|
+
</p><table><tr><td> </td><td><pre class="example"> struct { int x, y; } st = { .x = 1, .y = 1};
|
652
|
+
</pre></td></tr></table>
|
653
|
+
|
654
|
+
</li><li> <code>\e</code> is ASCII character 27.
|
655
|
+
|
656
|
+
</li><li> case ranges : ranges can be used in <code>case</code>s:
|
657
|
+
<table><tr><td> </td><td><pre class="example"> switch(a) {
|
658
|
+
case 1 … 9:
|
659
|
+
printf("range 1 to 9\n");
|
660
|
+
break;
|
661
|
+
default:
|
662
|
+
printf("unexpected\n");
|
663
|
+
break;
|
664
|
+
}
|
665
|
+
</pre></td></tr></table>
|
666
|
+
|
667
|
+
<a name="index-aligned-attribute"></a>
|
668
|
+
<a name="index-packed-attribute"></a>
|
669
|
+
<a name="index-section-attribute"></a>
|
670
|
+
<a name="index-unused-attribute"></a>
|
671
|
+
<a name="index-cdecl-attribute"></a>
|
672
|
+
<a name="index-stdcall-attribute"></a>
|
673
|
+
<a name="index-regparm-attribute"></a>
|
674
|
+
<a name="index-dllexport-attribute"></a>
|
675
|
+
|
676
|
+
</li><li> The keyword <code>__attribute__</code> is handled to specify variable or
|
677
|
+
function attributes. The following attributes are supported:
|
678
|
+
<ul>
|
679
|
+
<li> <code>aligned(n)</code>: align a variable or a structure field to n bytes
|
680
|
+
(must be a power of two).
|
681
|
+
|
682
|
+
</li><li> <code>packed</code>: force alignment of a variable or a structure field to
|
683
|
+
1.
|
684
|
+
|
685
|
+
</li><li> <code>section(name)</code>: generate function or data in assembly section
|
686
|
+
name (name is a string containing the section name) instead of the default
|
687
|
+
section.
|
688
|
+
|
689
|
+
</li><li> <code>unused</code>: specify that the variable or the function is unused.
|
690
|
+
|
691
|
+
</li><li> <code>cdecl</code>: use standard C calling convention (default).
|
692
|
+
|
693
|
+
</li><li> <code>stdcall</code>: use Pascal-like calling convention.
|
694
|
+
|
695
|
+
</li><li> <code>regparm(n)</code>: use fast i386 calling convention. <var>n</var> must be
|
696
|
+
between 1 and 3. The first <var>n</var> function parameters are respectively put in
|
697
|
+
registers <code>%eax</code>, <code>%edx</code> and <code>%ecx</code>.
|
698
|
+
|
699
|
+
</li><li> <code>dllexport</code>: export function from dll/executable (win32 only)
|
700
|
+
|
701
|
+
</li></ul>
|
702
|
+
|
703
|
+
<p>Here are some examples:
|
704
|
+
</p><table><tr><td> </td><td><pre class="example"> int a __attribute__ ((aligned(8), section(".mysection")));
|
705
|
+
</pre></td></tr></table>
|
706
|
+
|
707
|
+
<p>align variable <code>a</code> to 8 bytes and put it in section <code>.mysection</code>.
|
708
|
+
</p>
|
709
|
+
<table><tr><td> </td><td><pre class="example"> int my_add(int a, int b) __attribute__ ((section(".mycodesection")))
|
710
|
+
{
|
711
|
+
return a + b;
|
712
|
+
}
|
713
|
+
</pre></td></tr></table>
|
714
|
+
|
715
|
+
<p>generate function <code>my_add</code> in section <code>.mycodesection</code>.
|
716
|
+
</p>
|
717
|
+
</li><li> GNU style variadic macros:
|
718
|
+
<table><tr><td> </td><td><pre class="example"> #define dprintf(fmt, args…) printf(fmt, ## args)
|
719
|
+
|
720
|
+
dprintf("no arg\n");
|
721
|
+
dprintf("one arg %d\n", 1);
|
722
|
+
</pre></td></tr></table>
|
723
|
+
|
724
|
+
</li><li> <code>__FUNCTION__</code> is interpreted as C99 <code>__func__</code>
|
725
|
+
(so it has not exactly the same semantics as string literal GNUC
|
726
|
+
where it is a string literal).
|
727
|
+
|
728
|
+
</li><li> The <code>__alignof__</code> keyword can be used as <code>sizeof</code>
|
729
|
+
to get the alignment of a type or an expression.
|
730
|
+
|
731
|
+
</li><li> The <code>typeof(x)</code> returns the type of <code>x</code>.
|
732
|
+
<code>x</code> is an expression or a type.
|
733
|
+
|
734
|
+
</li><li> Computed gotos: <code>&&label</code> returns a pointer of type
|
735
|
+
<code>void *</code> on the goto label <code>label</code>. <code>goto *expr</code> can be
|
736
|
+
used to jump on the pointer resulting from <code>expr</code>.
|
737
|
+
|
738
|
+
</li><li> Inline assembly with asm instruction:
|
739
|
+
<a name="index-inline-assembly"></a>
|
740
|
+
<a name="index-assembly_002c-inline"></a>
|
741
|
+
<a name="index-_005f_005fasm_005f_005f"></a>
|
742
|
+
<table><tr><td> </td><td><pre class="example">static inline void * my_memcpy(void * to, const void * from, size_t n)
|
743
|
+
{
|
744
|
+
int d0, d1, d2;
|
745
|
+
__asm__ __volatile__(
|
746
|
+
"rep ; movsl\n\t"
|
747
|
+
"testb $2,%b4\n\t"
|
748
|
+
"je 1f\n\t"
|
749
|
+
"movsw\n"
|
750
|
+
"1:\ttestb $1,%b4\n\t"
|
751
|
+
"je 2f\n\t"
|
752
|
+
"movsb\n"
|
753
|
+
"2:"
|
754
|
+
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
|
755
|
+
:"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
|
756
|
+
: "memory");
|
757
|
+
return (to);
|
758
|
+
}
|
759
|
+
</pre></td></tr></table>
|
760
|
+
|
761
|
+
<a name="index-gas"></a>
|
762
|
+
<p>TCC includes its own x86 inline assembler with a <code>gas</code>-like (GNU
|
763
|
+
assembler) syntax. No intermediate files are generated. GCC 3.x named
|
764
|
+
operands are supported.
|
765
|
+
</p>
|
766
|
+
</li><li> <code>__builtin_types_compatible_p()</code> and <code>__builtin_constant_p()</code>
|
767
|
+
are supported.
|
768
|
+
|
769
|
+
</li><li> <code>#pragma pack</code> is supported for win32 compatibility.
|
770
|
+
|
771
|
+
</li></ul>
|
772
|
+
|
773
|
+
<hr size="6">
|
774
|
+
<a name="TinyCC-extensions"></a>
|
775
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
776
|
+
<tr><td valign="middle" align="left">[<a href="#GNU-C-extensions" title="Previous section in reading order"> < </a>]</td>
|
777
|
+
<td valign="middle" align="left">[<a href="#asm" title="Next section in reading order"> > </a>]</td>
|
778
|
+
<td valign="middle" align="left"> </td>
|
779
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
780
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Up section"> Up </a>]</td>
|
781
|
+
<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> >> </a>]</td>
|
782
|
+
<td valign="middle" align="left"> </td>
|
783
|
+
<td valign="middle" align="left"> </td>
|
784
|
+
<td valign="middle" align="left"> </td>
|
785
|
+
<td valign="middle" align="left"> </td>
|
786
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
787
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
788
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
789
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
790
|
+
</tr></table>
|
791
|
+
<h2 class="section">3.4 TinyCC extensions</h2>
|
792
|
+
|
793
|
+
<ul>
|
794
|
+
<li> <code>__TINYC__</code> is a predefined macro to <code>1</code> to
|
795
|
+
indicate that you use TCC.
|
796
|
+
|
797
|
+
</li><li> <code>#!</code> at the start of a line is ignored to allow scripting.
|
798
|
+
|
799
|
+
</li><li> Binary digits can be entered (<code>0b101</code> instead of
|
800
|
+
<code>5</code>).
|
801
|
+
|
802
|
+
</li><li> <code>__BOUNDS_CHECKING_ON</code> is defined if bound checking is activated.
|
803
|
+
|
804
|
+
</li></ul>
|
805
|
+
|
806
|
+
<hr size="6">
|
807
|
+
<a name="asm"></a>
|
808
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
809
|
+
<tr><td valign="middle" align="left">[<a href="#TinyCC-extensions" title="Previous section in reading order"> < </a>]</td>
|
810
|
+
<td valign="middle" align="left">[<a href="#Syntax" title="Next section in reading order"> > </a>]</td>
|
811
|
+
<td valign="middle" align="left"> </td>
|
812
|
+
<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
813
|
+
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
|
814
|
+
<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> >> </a>]</td>
|
815
|
+
<td valign="middle" align="left"> </td>
|
816
|
+
<td valign="middle" align="left"> </td>
|
817
|
+
<td valign="middle" align="left"> </td>
|
818
|
+
<td valign="middle" align="left"> </td>
|
819
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
820
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
821
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
822
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
823
|
+
</tr></table>
|
824
|
+
<a name="TinyCC-Assembler"></a>
|
825
|
+
<h1 class="chapter">4. TinyCC Assembler</h1>
|
826
|
+
|
827
|
+
<p>Since version 0.9.16, TinyCC integrates its own assembler. TinyCC
|
828
|
+
assembler supports a gas-like syntax (GNU assembler). You can
|
829
|
+
desactivate assembler support if you want a smaller TinyCC executable
|
830
|
+
(the C compiler does not rely on the assembler).
|
831
|
+
</p>
|
832
|
+
<p>TinyCC Assembler is used to handle files with ‘<tt>.S</tt>’ (C
|
833
|
+
preprocessed assembler) and ‘<tt>.s</tt>’ extensions. It is also used to
|
834
|
+
handle the GNU inline assembler with the <code>asm</code> keyword.
|
835
|
+
</p>
|
836
|
+
<hr size="6">
|
837
|
+
<a name="Syntax"></a>
|
838
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
839
|
+
<tr><td valign="middle" align="left">[<a href="#asm" title="Previous section in reading order"> < </a>]</td>
|
840
|
+
<td valign="middle" align="left">[<a href="#Expressions" title="Next section in reading order"> > </a>]</td>
|
841
|
+
<td valign="middle" align="left"> </td>
|
842
|
+
<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
843
|
+
<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
|
844
|
+
<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> >> </a>]</td>
|
845
|
+
<td valign="middle" align="left"> </td>
|
846
|
+
<td valign="middle" align="left"> </td>
|
847
|
+
<td valign="middle" align="left"> </td>
|
848
|
+
<td valign="middle" align="left"> </td>
|
849
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
850
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
851
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
852
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
853
|
+
</tr></table>
|
854
|
+
<h2 class="section">4.1 Syntax</h2>
|
855
|
+
|
856
|
+
<p>TinyCC Assembler supports most of the gas syntax. The tokens are the
|
857
|
+
same as C.
|
858
|
+
</p>
|
859
|
+
<ul>
|
860
|
+
<li> C and C++ comments are supported.
|
861
|
+
|
862
|
+
</li><li> Identifiers are the same as C, so you cannot use ’.’ or ’$’.
|
863
|
+
|
864
|
+
</li><li> Only 32 bit integer numbers are supported.
|
865
|
+
|
866
|
+
</li></ul>
|
867
|
+
|
868
|
+
<hr size="6">
|
869
|
+
<a name="Expressions"></a>
|
870
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
871
|
+
<tr><td valign="middle" align="left">[<a href="#Syntax" title="Previous section in reading order"> < </a>]</td>
|
872
|
+
<td valign="middle" align="left">[<a href="#Labels" title="Next section in reading order"> > </a>]</td>
|
873
|
+
<td valign="middle" align="left"> </td>
|
874
|
+
<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
875
|
+
<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
|
876
|
+
<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> >> </a>]</td>
|
877
|
+
<td valign="middle" align="left"> </td>
|
878
|
+
<td valign="middle" align="left"> </td>
|
879
|
+
<td valign="middle" align="left"> </td>
|
880
|
+
<td valign="middle" align="left"> </td>
|
881
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
882
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
883
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
884
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
885
|
+
</tr></table>
|
886
|
+
<h2 class="section">4.2 Expressions</h2>
|
887
|
+
|
888
|
+
<ul>
|
889
|
+
<li> Integers in decimal, octal and hexa are supported.
|
890
|
+
|
891
|
+
</li><li> Unary operators: +, -, ~.
|
892
|
+
|
893
|
+
</li><li> Binary operators in decreasing priority order:
|
894
|
+
|
895
|
+
<ol>
|
896
|
+
<li> *, /, %
|
897
|
+
</li><li> &, |, ^
|
898
|
+
</li><li> +, -
|
899
|
+
</li></ol>
|
900
|
+
|
901
|
+
</li><li> A value is either an absolute number or a label plus an offset.
|
902
|
+
All operators accept absolute values except ’+’ and ’-’. ’+’ or ’-’ can be
|
903
|
+
used to add an offset to a label. ’-’ supports two labels only if they
|
904
|
+
are the same or if they are both defined and in the same section.
|
905
|
+
|
906
|
+
</li></ul>
|
907
|
+
|
908
|
+
<hr size="6">
|
909
|
+
<a name="Labels"></a>
|
910
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
911
|
+
<tr><td valign="middle" align="left">[<a href="#Expressions" title="Previous section in reading order"> < </a>]</td>
|
912
|
+
<td valign="middle" align="left">[<a href="#Directives" title="Next section in reading order"> > </a>]</td>
|
913
|
+
<td valign="middle" align="left"> </td>
|
914
|
+
<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
915
|
+
<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
|
916
|
+
<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> >> </a>]</td>
|
917
|
+
<td valign="middle" align="left"> </td>
|
918
|
+
<td valign="middle" align="left"> </td>
|
919
|
+
<td valign="middle" align="left"> </td>
|
920
|
+
<td valign="middle" align="left"> </td>
|
921
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
922
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
923
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
924
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
925
|
+
</tr></table>
|
926
|
+
<h2 class="section">4.3 Labels</h2>
|
927
|
+
|
928
|
+
<ul>
|
929
|
+
<li> All labels are considered as local, except undefined ones.
|
930
|
+
|
931
|
+
</li><li> Numeric labels can be used as local <code>gas</code>-like labels.
|
932
|
+
They can be defined several times in the same source. Use ’b’
|
933
|
+
(backward) or ’f’ (forward) as suffix to reference them:
|
934
|
+
|
935
|
+
<table><tr><td> </td><td><pre class="example"> 1:
|
936
|
+
jmp 1b /* jump to '1' label before */
|
937
|
+
jmp 1f /* jump to '1' label after */
|
938
|
+
1:
|
939
|
+
</pre></td></tr></table>
|
940
|
+
|
941
|
+
</li></ul>
|
942
|
+
|
943
|
+
<hr size="6">
|
944
|
+
<a name="Directives"></a>
|
945
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
946
|
+
<tr><td valign="middle" align="left">[<a href="#Labels" title="Previous section in reading order"> < </a>]</td>
|
947
|
+
<td valign="middle" align="left">[<a href="#X86-Assembler" title="Next section in reading order"> > </a>]</td>
|
948
|
+
<td valign="middle" align="left"> </td>
|
949
|
+
<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
950
|
+
<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
|
951
|
+
<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> >> </a>]</td>
|
952
|
+
<td valign="middle" align="left"> </td>
|
953
|
+
<td valign="middle" align="left"> </td>
|
954
|
+
<td valign="middle" align="left"> </td>
|
955
|
+
<td valign="middle" align="left"> </td>
|
956
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
957
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
958
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
959
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
960
|
+
</tr></table>
|
961
|
+
<h2 class="section">4.4 Directives</h2>
|
962
|
+
<a name="index-assembler-directives"></a>
|
963
|
+
<a name="index-directives_002c-assembler"></a>
|
964
|
+
<a name="index-align-directive"></a>
|
965
|
+
<a name="index-skip-directive"></a>
|
966
|
+
<a name="index-space-directive"></a>
|
967
|
+
<a name="index-byte-directive"></a>
|
968
|
+
<a name="index-word-directive"></a>
|
969
|
+
<a name="index-short-directive"></a>
|
970
|
+
<a name="index-int-directive"></a>
|
971
|
+
<a name="index-long-directive"></a>
|
972
|
+
<a name="index-quad-directive"></a>
|
973
|
+
<a name="index-globl-directive"></a>
|
974
|
+
<a name="index-global-directive"></a>
|
975
|
+
<a name="index-section-directive"></a>
|
976
|
+
<a name="index-text-directive"></a>
|
977
|
+
<a name="index-data-directive"></a>
|
978
|
+
<a name="index-bss-directive"></a>
|
979
|
+
<a name="index-fill-directive"></a>
|
980
|
+
<a name="index-org-directive"></a>
|
981
|
+
<a name="index-previous-directive"></a>
|
982
|
+
<a name="index-string-directive"></a>
|
983
|
+
<a name="index-asciz-directive"></a>
|
984
|
+
<a name="index-ascii-directive"></a>
|
985
|
+
|
986
|
+
<p>All directives are preceeded by a ’.’. The following directives are
|
987
|
+
supported:
|
988
|
+
</p>
|
989
|
+
<ul>
|
990
|
+
<li> .align n[,value]
|
991
|
+
</li><li> .skip n[,value]
|
992
|
+
</li><li> .space n[,value]
|
993
|
+
</li><li> .byte value1[,...]
|
994
|
+
</li><li> .word value1[,...]
|
995
|
+
</li><li> .short value1[,...]
|
996
|
+
</li><li> .int value1[,...]
|
997
|
+
</li><li> .long value1[,...]
|
998
|
+
</li><li> .quad immediate_value1[,...]
|
999
|
+
</li><li> .globl symbol
|
1000
|
+
</li><li> .global symbol
|
1001
|
+
</li><li> .section section
|
1002
|
+
</li><li> .text
|
1003
|
+
</li><li> .data
|
1004
|
+
</li><li> .bss
|
1005
|
+
</li><li> .fill repeat[,size[,value]]
|
1006
|
+
</li><li> .org n
|
1007
|
+
</li><li> .previous
|
1008
|
+
</li><li> .string string[,...]
|
1009
|
+
</li><li> .asciz string[,...]
|
1010
|
+
</li><li> .ascii string[,...]
|
1011
|
+
</li></ul>
|
1012
|
+
|
1013
|
+
<hr size="6">
|
1014
|
+
<a name="X86-Assembler"></a>
|
1015
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1016
|
+
<tr><td valign="middle" align="left">[<a href="#Directives" title="Previous section in reading order"> < </a>]</td>
|
1017
|
+
<td valign="middle" align="left">[<a href="#linker" title="Next section in reading order"> > </a>]</td>
|
1018
|
+
<td valign="middle" align="left"> </td>
|
1019
|
+
<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1020
|
+
<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
|
1021
|
+
<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> >> </a>]</td>
|
1022
|
+
<td valign="middle" align="left"> </td>
|
1023
|
+
<td valign="middle" align="left"> </td>
|
1024
|
+
<td valign="middle" align="left"> </td>
|
1025
|
+
<td valign="middle" align="left"> </td>
|
1026
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1027
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1028
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1029
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1030
|
+
</tr></table>
|
1031
|
+
<h2 class="section">4.5 X86 Assembler</h2>
|
1032
|
+
<a name="index-assembler"></a>
|
1033
|
+
|
1034
|
+
<p>All X86 opcodes are supported. Only ATT syntax is supported (source
|
1035
|
+
then destination operand order). If no size suffix is given, TinyCC
|
1036
|
+
tries to guess it from the operand sizes.
|
1037
|
+
</p>
|
1038
|
+
<p>Currently, MMX opcodes are supported but not SSE ones.
|
1039
|
+
</p>
|
1040
|
+
<hr size="6">
|
1041
|
+
<a name="linker"></a>
|
1042
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1043
|
+
<tr><td valign="middle" align="left">[<a href="#X86-Assembler" title="Previous section in reading order"> < </a>]</td>
|
1044
|
+
<td valign="middle" align="left">[<a href="#ELF-file-generation" title="Next section in reading order"> > </a>]</td>
|
1045
|
+
<td valign="middle" align="left"> </td>
|
1046
|
+
<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1047
|
+
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
|
1048
|
+
<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> >> </a>]</td>
|
1049
|
+
<td valign="middle" align="left"> </td>
|
1050
|
+
<td valign="middle" align="left"> </td>
|
1051
|
+
<td valign="middle" align="left"> </td>
|
1052
|
+
<td valign="middle" align="left"> </td>
|
1053
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1054
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1055
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1056
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1057
|
+
</tr></table>
|
1058
|
+
<a name="TinyCC-Linker"></a>
|
1059
|
+
<h1 class="chapter">5. TinyCC Linker</h1>
|
1060
|
+
<a name="index-linker"></a>
|
1061
|
+
|
1062
|
+
<hr size="6">
|
1063
|
+
<a name="ELF-file-generation"></a>
|
1064
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1065
|
+
<tr><td valign="middle" align="left">[<a href="#linker" title="Previous section in reading order"> < </a>]</td>
|
1066
|
+
<td valign="middle" align="left">[<a href="#ELF-file-loader" title="Next section in reading order"> > </a>]</td>
|
1067
|
+
<td valign="middle" align="left"> </td>
|
1068
|
+
<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1069
|
+
<td valign="middle" align="left">[<a href="#linker" title="Up section"> Up </a>]</td>
|
1070
|
+
<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> >> </a>]</td>
|
1071
|
+
<td valign="middle" align="left"> </td>
|
1072
|
+
<td valign="middle" align="left"> </td>
|
1073
|
+
<td valign="middle" align="left"> </td>
|
1074
|
+
<td valign="middle" align="left"> </td>
|
1075
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1076
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1077
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1078
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1079
|
+
</tr></table>
|
1080
|
+
<h2 class="section">5.1 ELF file generation</h2>
|
1081
|
+
<a name="index-ELF"></a>
|
1082
|
+
|
1083
|
+
<p>TCC can directly output relocatable ELF files (object files),
|
1084
|
+
executable ELF files and dynamic ELF libraries without relying on an
|
1085
|
+
external linker.
|
1086
|
+
</p>
|
1087
|
+
<p>Dynamic ELF libraries can be output but the C compiler does not generate
|
1088
|
+
position independent code (PIC). It means that the dynamic library
|
1089
|
+
code generated by TCC cannot be factorized among processes yet.
|
1090
|
+
</p>
|
1091
|
+
<p>TCC linker eliminates unreferenced object code in libraries. A single pass is
|
1092
|
+
done on the object and library list, so the order in which object files and
|
1093
|
+
libraries are specified is important (same constraint as GNU ld). No grouping
|
1094
|
+
options (‘<samp>--start-group</samp>’ and ‘<samp>--end-group</samp>’) are supported.
|
1095
|
+
</p>
|
1096
|
+
<hr size="6">
|
1097
|
+
<a name="ELF-file-loader"></a>
|
1098
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1099
|
+
<tr><td valign="middle" align="left">[<a href="#ELF-file-generation" title="Previous section in reading order"> < </a>]</td>
|
1100
|
+
<td valign="middle" align="left">[<a href="#PE_002di386-file-generation" title="Next section in reading order"> > </a>]</td>
|
1101
|
+
<td valign="middle" align="left"> </td>
|
1102
|
+
<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1103
|
+
<td valign="middle" align="left">[<a href="#linker" title="Up section"> Up </a>]</td>
|
1104
|
+
<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> >> </a>]</td>
|
1105
|
+
<td valign="middle" align="left"> </td>
|
1106
|
+
<td valign="middle" align="left"> </td>
|
1107
|
+
<td valign="middle" align="left"> </td>
|
1108
|
+
<td valign="middle" align="left"> </td>
|
1109
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1110
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1111
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1112
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1113
|
+
</tr></table>
|
1114
|
+
<h2 class="section">5.2 ELF file loader</h2>
|
1115
|
+
|
1116
|
+
<p>TCC can load ELF object files, archives (.a files) and dynamic
|
1117
|
+
libraries (.so).
|
1118
|
+
</p>
|
1119
|
+
<hr size="6">
|
1120
|
+
<a name="PE_002di386-file-generation"></a>
|
1121
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1122
|
+
<tr><td valign="middle" align="left">[<a href="#ELF-file-loader" title="Previous section in reading order"> < </a>]</td>
|
1123
|
+
<td valign="middle" align="left">[<a href="#GNU-Linker-Scripts" title="Next section in reading order"> > </a>]</td>
|
1124
|
+
<td valign="middle" align="left"> </td>
|
1125
|
+
<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1126
|
+
<td valign="middle" align="left">[<a href="#linker" title="Up section"> Up </a>]</td>
|
1127
|
+
<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> >> </a>]</td>
|
1128
|
+
<td valign="middle" align="left"> </td>
|
1129
|
+
<td valign="middle" align="left"> </td>
|
1130
|
+
<td valign="middle" align="left"> </td>
|
1131
|
+
<td valign="middle" align="left"> </td>
|
1132
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1133
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1134
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1135
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1136
|
+
</tr></table>
|
1137
|
+
<h2 class="section">5.3 PE-i386 file generation</h2>
|
1138
|
+
<a name="index-PE_002di386"></a>
|
1139
|
+
|
1140
|
+
<p>TCC for Windows supports the native Win32 executable file format (PE-i386). It
|
1141
|
+
generates EXE files (console and gui) and DLL files.
|
1142
|
+
</p>
|
1143
|
+
<p>For usage on Windows, see also tcc-win32.txt.
|
1144
|
+
</p>
|
1145
|
+
<hr size="6">
|
1146
|
+
<a name="GNU-Linker-Scripts"></a>
|
1147
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1148
|
+
<tr><td valign="middle" align="left">[<a href="#PE_002di386-file-generation" title="Previous section in reading order"> < </a>]</td>
|
1149
|
+
<td valign="middle" align="left">[<a href="#Bounds" title="Next section in reading order"> > </a>]</td>
|
1150
|
+
<td valign="middle" align="left"> </td>
|
1151
|
+
<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1152
|
+
<td valign="middle" align="left">[<a href="#linker" title="Up section"> Up </a>]</td>
|
1153
|
+
<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> >> </a>]</td>
|
1154
|
+
<td valign="middle" align="left"> </td>
|
1155
|
+
<td valign="middle" align="left"> </td>
|
1156
|
+
<td valign="middle" align="left"> </td>
|
1157
|
+
<td valign="middle" align="left"> </td>
|
1158
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1159
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1160
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1161
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1162
|
+
</tr></table>
|
1163
|
+
<h2 class="section">5.4 GNU Linker Scripts</h2>
|
1164
|
+
<a name="index-scripts_002c-linker"></a>
|
1165
|
+
<a name="index-linker-scripts"></a>
|
1166
|
+
<a name="index-GROUP_002c-linker-command"></a>
|
1167
|
+
<a name="index-FILE_002c-linker-command"></a>
|
1168
|
+
<a name="index-OUTPUT_005fFORMAT_002c-linker-command"></a>
|
1169
|
+
<a name="index-TARGET_002c-linker-command"></a>
|
1170
|
+
|
1171
|
+
<p>Because on many Linux systems some dynamic libraries (such as
|
1172
|
+
‘<tt>/usr/lib/libc.so</tt>’) are in fact GNU ld link scripts (horrible!),
|
1173
|
+
the TCC linker also supports a subset of GNU ld scripts.
|
1174
|
+
</p>
|
1175
|
+
<p>The <code>GROUP</code> and <code>FILE</code> commands are supported. <code>OUTPUT_FORMAT</code>
|
1176
|
+
and <code>TARGET</code> are ignored.
|
1177
|
+
</p>
|
1178
|
+
<p>Example from ‘<tt>/usr/lib/libc.so</tt>’:
|
1179
|
+
</p><table><tr><td> </td><td><pre class="example">/* GNU ld script
|
1180
|
+
Use the shared library, but some functions are only in
|
1181
|
+
the static library, so try that secondarily. */
|
1182
|
+
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )
|
1183
|
+
</pre></td></tr></table>
|
1184
|
+
|
1185
|
+
<hr size="6">
|
1186
|
+
<a name="Bounds"></a>
|
1187
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1188
|
+
<tr><td valign="middle" align="left">[<a href="#GNU-Linker-Scripts" title="Previous section in reading order"> < </a>]</td>
|
1189
|
+
<td valign="middle" align="left">[<a href="#Libtcc" title="Next section in reading order"> > </a>]</td>
|
1190
|
+
<td valign="middle" align="left"> </td>
|
1191
|
+
<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1192
|
+
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
|
1193
|
+
<td valign="middle" align="left">[<a href="#Libtcc" title="Next chapter"> >> </a>]</td>
|
1194
|
+
<td valign="middle" align="left"> </td>
|
1195
|
+
<td valign="middle" align="left"> </td>
|
1196
|
+
<td valign="middle" align="left"> </td>
|
1197
|
+
<td valign="middle" align="left"> </td>
|
1198
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1199
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1200
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1201
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1202
|
+
</tr></table>
|
1203
|
+
<a name="TinyCC-Memory-and-Bound-checks"></a>
|
1204
|
+
<h1 class="chapter">6. TinyCC Memory and Bound checks</h1>
|
1205
|
+
<a name="index-bound-checks"></a>
|
1206
|
+
<a name="index-memory-checks"></a>
|
1207
|
+
|
1208
|
+
<p>This feature is activated with the ‘<samp>-b</samp>’ (see section <a href="#Invoke">Command line invocation</a>).
|
1209
|
+
</p>
|
1210
|
+
<p>Note that pointer size is <em>unchanged</em> and that code generated
|
1211
|
+
with bound checks is <em>fully compatible</em> with unchecked
|
1212
|
+
code. When a pointer comes from unchecked code, it is assumed to be
|
1213
|
+
valid. Even very obscure C code with casts should work correctly.
|
1214
|
+
</p>
|
1215
|
+
<p>For more information about the ideas behind this method, see
|
1216
|
+
<a href="http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html">http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html</a>.
|
1217
|
+
</p>
|
1218
|
+
<p>Here are some examples of caught errors:
|
1219
|
+
</p>
|
1220
|
+
<dl compact="compact">
|
1221
|
+
<dt> Invalid range with standard string function:</dt>
|
1222
|
+
<dd><table><tr><td> </td><td><pre class="example">{
|
1223
|
+
char tab[10];
|
1224
|
+
memset(tab, 0, 11);
|
1225
|
+
}
|
1226
|
+
</pre></td></tr></table>
|
1227
|
+
|
1228
|
+
</dd>
|
1229
|
+
<dt> Out of bounds-error in global or local arrays:</dt>
|
1230
|
+
<dd><table><tr><td> </td><td><pre class="example">{
|
1231
|
+
int tab[10];
|
1232
|
+
for(i=0;i<11;i++) {
|
1233
|
+
sum += tab[i];
|
1234
|
+
}
|
1235
|
+
}
|
1236
|
+
</pre></td></tr></table>
|
1237
|
+
|
1238
|
+
</dd>
|
1239
|
+
<dt> Out of bounds-error in malloc’ed data:</dt>
|
1240
|
+
<dd><table><tr><td> </td><td><pre class="example">{
|
1241
|
+
int *tab;
|
1242
|
+
tab = malloc(20 * sizeof(int));
|
1243
|
+
for(i=0;i<21;i++) {
|
1244
|
+
sum += tab4[i];
|
1245
|
+
}
|
1246
|
+
free(tab);
|
1247
|
+
}
|
1248
|
+
</pre></td></tr></table>
|
1249
|
+
|
1250
|
+
</dd>
|
1251
|
+
<dt> Access of freed memory:</dt>
|
1252
|
+
<dd><table><tr><td> </td><td><pre class="example">{
|
1253
|
+
int *tab;
|
1254
|
+
tab = malloc(20 * sizeof(int));
|
1255
|
+
free(tab);
|
1256
|
+
for(i=0;i<20;i++) {
|
1257
|
+
sum += tab4[i];
|
1258
|
+
}
|
1259
|
+
}
|
1260
|
+
</pre></td></tr></table>
|
1261
|
+
|
1262
|
+
</dd>
|
1263
|
+
<dt> Double free:</dt>
|
1264
|
+
<dd><table><tr><td> </td><td><pre class="example">{
|
1265
|
+
int *tab;
|
1266
|
+
tab = malloc(20 * sizeof(int));
|
1267
|
+
free(tab);
|
1268
|
+
free(tab);
|
1269
|
+
}
|
1270
|
+
</pre></td></tr></table>
|
1271
|
+
|
1272
|
+
</dd>
|
1273
|
+
</dl>
|
1274
|
+
|
1275
|
+
<hr size="6">
|
1276
|
+
<a name="Libtcc"></a>
|
1277
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1278
|
+
<tr><td valign="middle" align="left">[<a href="#Bounds" title="Previous section in reading order"> < </a>]</td>
|
1279
|
+
<td valign="middle" align="left">[<a href="#devel" title="Next section in reading order"> > </a>]</td>
|
1280
|
+
<td valign="middle" align="left"> </td>
|
1281
|
+
<td valign="middle" align="left">[<a href="#Bounds" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1282
|
+
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
|
1283
|
+
<td valign="middle" align="left">[<a href="#devel" title="Next chapter"> >> </a>]</td>
|
1284
|
+
<td valign="middle" align="left"> </td>
|
1285
|
+
<td valign="middle" align="left"> </td>
|
1286
|
+
<td valign="middle" align="left"> </td>
|
1287
|
+
<td valign="middle" align="left"> </td>
|
1288
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1289
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1290
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1291
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1292
|
+
</tr></table>
|
1293
|
+
<a name="The-libtcc-library"></a>
|
1294
|
+
<h1 class="chapter">7. The <code>libtcc</code> library</h1>
|
1295
|
+
|
1296
|
+
<p>The <code>libtcc</code> library enables you to use TCC as a backend for
|
1297
|
+
dynamic code generation.
|
1298
|
+
</p>
|
1299
|
+
<p>Read the ‘<tt>libtcc.h</tt>’ to have an overview of the API. Read
|
1300
|
+
‘<tt>libtcc_test.c</tt>’ to have a very simple example.
|
1301
|
+
</p>
|
1302
|
+
<p>The idea consists in giving a C string containing the program you want
|
1303
|
+
to compile directly to <code>libtcc</code>. Then you can access to any global
|
1304
|
+
symbol (function or variable) defined.
|
1305
|
+
</p>
|
1306
|
+
<hr size="6">
|
1307
|
+
<a name="devel"></a>
|
1308
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1309
|
+
<tr><td valign="middle" align="left">[<a href="#Libtcc" title="Previous section in reading order"> < </a>]</td>
|
1310
|
+
<td valign="middle" align="left">[<a href="#File-reading" title="Next section in reading order"> > </a>]</td>
|
1311
|
+
<td valign="middle" align="left"> </td>
|
1312
|
+
<td valign="middle" align="left">[<a href="#Libtcc" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1313
|
+
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
|
1314
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1315
|
+
<td valign="middle" align="left"> </td>
|
1316
|
+
<td valign="middle" align="left"> </td>
|
1317
|
+
<td valign="middle" align="left"> </td>
|
1318
|
+
<td valign="middle" align="left"> </td>
|
1319
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1320
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1321
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1322
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1323
|
+
</tr></table>
|
1324
|
+
<a name="Developer_0027s-guide"></a>
|
1325
|
+
<h1 class="chapter">8. Developer’s guide</h1>
|
1326
|
+
|
1327
|
+
<p>This chapter gives some hints to understand how TCC works. You can skip
|
1328
|
+
it if you do not intend to modify the TCC code.
|
1329
|
+
</p>
|
1330
|
+
<hr size="6">
|
1331
|
+
<a name="File-reading"></a>
|
1332
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1333
|
+
<tr><td valign="middle" align="left">[<a href="#devel" title="Previous section in reading order"> < </a>]</td>
|
1334
|
+
<td valign="middle" align="left">[<a href="#Lexer" title="Next section in reading order"> > </a>]</td>
|
1335
|
+
<td valign="middle" align="left"> </td>
|
1336
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1337
|
+
<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
|
1338
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1339
|
+
<td valign="middle" align="left"> </td>
|
1340
|
+
<td valign="middle" align="left"> </td>
|
1341
|
+
<td valign="middle" align="left"> </td>
|
1342
|
+
<td valign="middle" align="left"> </td>
|
1343
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1344
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1345
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1346
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1347
|
+
</tr></table>
|
1348
|
+
<h2 class="section">8.1 File reading</h2>
|
1349
|
+
|
1350
|
+
<p>The <code>BufferedFile</code> structure contains the context needed to read a
|
1351
|
+
file, including the current line number. <code>tcc_open()</code> opens a new
|
1352
|
+
file and <code>tcc_close()</code> closes it. <code>inp()</code> returns the next
|
1353
|
+
character.
|
1354
|
+
</p>
|
1355
|
+
<hr size="6">
|
1356
|
+
<a name="Lexer"></a>
|
1357
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1358
|
+
<tr><td valign="middle" align="left">[<a href="#File-reading" title="Previous section in reading order"> < </a>]</td>
|
1359
|
+
<td valign="middle" align="left">[<a href="#Parser" title="Next section in reading order"> > </a>]</td>
|
1360
|
+
<td valign="middle" align="left"> </td>
|
1361
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1362
|
+
<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
|
1363
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1364
|
+
<td valign="middle" align="left"> </td>
|
1365
|
+
<td valign="middle" align="left"> </td>
|
1366
|
+
<td valign="middle" align="left"> </td>
|
1367
|
+
<td valign="middle" align="left"> </td>
|
1368
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1369
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1370
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1371
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1372
|
+
</tr></table>
|
1373
|
+
<h2 class="section">8.2 Lexer</h2>
|
1374
|
+
|
1375
|
+
<p><code>next()</code> reads the next token in the current
|
1376
|
+
file. <code>next_nomacro()</code> reads the next token without macro
|
1377
|
+
expansion.
|
1378
|
+
</p>
|
1379
|
+
<p><code>tok</code> contains the current token (see <code>TOK_xxx</code>)
|
1380
|
+
constants. Identifiers and keywords are also keywords. <code>tokc</code>
|
1381
|
+
contains additional infos about the token (for example a constant value
|
1382
|
+
if number or string token).
|
1383
|
+
</p>
|
1384
|
+
<hr size="6">
|
1385
|
+
<a name="Parser"></a>
|
1386
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1387
|
+
<tr><td valign="middle" align="left">[<a href="#Lexer" title="Previous section in reading order"> < </a>]</td>
|
1388
|
+
<td valign="middle" align="left">[<a href="#Types" title="Next section in reading order"> > </a>]</td>
|
1389
|
+
<td valign="middle" align="left"> </td>
|
1390
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1391
|
+
<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
|
1392
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1393
|
+
<td valign="middle" align="left"> </td>
|
1394
|
+
<td valign="middle" align="left"> </td>
|
1395
|
+
<td valign="middle" align="left"> </td>
|
1396
|
+
<td valign="middle" align="left"> </td>
|
1397
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1398
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1399
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1400
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1401
|
+
</tr></table>
|
1402
|
+
<h2 class="section">8.3 Parser</h2>
|
1403
|
+
|
1404
|
+
<p>The parser is hardcoded (yacc is not necessary). It does only one pass,
|
1405
|
+
except:
|
1406
|
+
</p>
|
1407
|
+
<ul>
|
1408
|
+
<li> For initialized arrays with unknown size, a first pass
|
1409
|
+
is done to count the number of elements.
|
1410
|
+
|
1411
|
+
</li><li> For architectures where arguments are evaluated in
|
1412
|
+
reverse order, a first pass is done to reverse the argument order.
|
1413
|
+
|
1414
|
+
</li></ul>
|
1415
|
+
|
1416
|
+
<hr size="6">
|
1417
|
+
<a name="Types"></a>
|
1418
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1419
|
+
<tr><td valign="middle" align="left">[<a href="#Parser" title="Previous section in reading order"> < </a>]</td>
|
1420
|
+
<td valign="middle" align="left">[<a href="#Symbols" title="Next section in reading order"> > </a>]</td>
|
1421
|
+
<td valign="middle" align="left"> </td>
|
1422
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1423
|
+
<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
|
1424
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1425
|
+
<td valign="middle" align="left"> </td>
|
1426
|
+
<td valign="middle" align="left"> </td>
|
1427
|
+
<td valign="middle" align="left"> </td>
|
1428
|
+
<td valign="middle" align="left"> </td>
|
1429
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1430
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1431
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1432
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1433
|
+
</tr></table>
|
1434
|
+
<h2 class="section">8.4 Types</h2>
|
1435
|
+
|
1436
|
+
<p>The types are stored in a single ’int’ variable. It was choosen in the
|
1437
|
+
first stages of development when tcc was much simpler. Now, it may not
|
1438
|
+
be the best solution.
|
1439
|
+
</p>
|
1440
|
+
<table><tr><td> </td><td><pre class="example">#define VT_INT 0 /* integer type */
|
1441
|
+
#define VT_BYTE 1 /* signed byte type */
|
1442
|
+
#define VT_SHORT 2 /* short type */
|
1443
|
+
#define VT_VOID 3 /* void type */
|
1444
|
+
#define VT_PTR 4 /* pointer */
|
1445
|
+
#define VT_ENUM 5 /* enum definition */
|
1446
|
+
#define VT_FUNC 6 /* function type */
|
1447
|
+
#define VT_STRUCT 7 /* struct/union definition */
|
1448
|
+
#define VT_FLOAT 8 /* IEEE float */
|
1449
|
+
#define VT_DOUBLE 9 /* IEEE double */
|
1450
|
+
#define VT_LDOUBLE 10 /* IEEE long double */
|
1451
|
+
#define VT_BOOL 11 /* ISOC99 boolean type */
|
1452
|
+
#define VT_LLONG 12 /* 64 bit integer */
|
1453
|
+
#define VT_LONG 13 /* long integer (NEVER USED as type, only
|
1454
|
+
during parsing) */
|
1455
|
+
#define VT_BTYPE 0x000f /* mask for basic type */
|
1456
|
+
#define VT_UNSIGNED 0x0010 /* unsigned type */
|
1457
|
+
#define VT_ARRAY 0x0020 /* array type (also has VT_PTR) */
|
1458
|
+
#define VT_VLA 0x20000 /* VLA type (also has VT_PTR and VT_ARRAY) */
|
1459
|
+
#define VT_BITFIELD 0x0040 /* bitfield modifier */
|
1460
|
+
#define VT_CONSTANT 0x0800 /* const modifier */
|
1461
|
+
#define VT_VOLATILE 0x1000 /* volatile modifier */
|
1462
|
+
#define VT_SIGNED 0x2000 /* signed type */
|
1463
|
+
|
1464
|
+
#define VT_STRUCT_SHIFT 18 /* structure/enum name shift (14 bits left) */
|
1465
|
+
</pre></td></tr></table>
|
1466
|
+
|
1467
|
+
<p>When a reference to another type is needed (for pointers, functions and
|
1468
|
+
structures), the <code>32 - VT_STRUCT_SHIFT</code> high order bits are used to
|
1469
|
+
store an identifier reference.
|
1470
|
+
</p>
|
1471
|
+
<p>The <code>VT_UNSIGNED</code> flag can be set for chars, shorts, ints and long
|
1472
|
+
longs.
|
1473
|
+
</p>
|
1474
|
+
<p>Arrays are considered as pointers <code>VT_PTR</code> with the flag
|
1475
|
+
<code>VT_ARRAY</code> set. Variable length arrays are considered as special
|
1476
|
+
arrays and have flag <code>VT_VLA</code> set instead of <code>VT_ARRAY</code>.
|
1477
|
+
</p>
|
1478
|
+
<p>The <code>VT_BITFIELD</code> flag can be set for chars, shorts, ints and long
|
1479
|
+
longs. If it is set, then the bitfield position is stored from bits
|
1480
|
+
VT_STRUCT_SHIFT to VT_STRUCT_SHIFT + 5 and the bit field size is stored
|
1481
|
+
from bits VT_STRUCT_SHIFT + 6 to VT_STRUCT_SHIFT + 11.
|
1482
|
+
</p>
|
1483
|
+
<p><code>VT_LONG</code> is never used except during parsing.
|
1484
|
+
</p>
|
1485
|
+
<p>During parsing, the storage of an object is also stored in the type
|
1486
|
+
integer:
|
1487
|
+
</p>
|
1488
|
+
<table><tr><td> </td><td><pre class="example">#define VT_EXTERN 0x00000080 /* extern definition */
|
1489
|
+
#define VT_STATIC 0x00000100 /* static variable */
|
1490
|
+
#define VT_TYPEDEF 0x00000200 /* typedef definition */
|
1491
|
+
#define VT_INLINE 0x00000400 /* inline definition */
|
1492
|
+
#define VT_IMPORT 0x00004000 /* win32: extern data imported from dll */
|
1493
|
+
#define VT_EXPORT 0x00008000 /* win32: data exported from dll */
|
1494
|
+
#define VT_WEAK 0x00010000 /* win32: data exported from dll */
|
1495
|
+
</pre></td></tr></table>
|
1496
|
+
|
1497
|
+
<hr size="6">
|
1498
|
+
<a name="Symbols"></a>
|
1499
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1500
|
+
<tr><td valign="middle" align="left">[<a href="#Types" title="Previous section in reading order"> < </a>]</td>
|
1501
|
+
<td valign="middle" align="left">[<a href="#Sections" title="Next section in reading order"> > </a>]</td>
|
1502
|
+
<td valign="middle" align="left"> </td>
|
1503
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1504
|
+
<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
|
1505
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1506
|
+
<td valign="middle" align="left"> </td>
|
1507
|
+
<td valign="middle" align="left"> </td>
|
1508
|
+
<td valign="middle" align="left"> </td>
|
1509
|
+
<td valign="middle" align="left"> </td>
|
1510
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1511
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1512
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1513
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1514
|
+
</tr></table>
|
1515
|
+
<h2 class="section">8.5 Symbols</h2>
|
1516
|
+
|
1517
|
+
<p>All symbols are stored in hashed symbol stacks. Each symbol stack
|
1518
|
+
contains <code>Sym</code> structures.
|
1519
|
+
</p>
|
1520
|
+
<p><code>Sym.v</code> contains the symbol name (remember
|
1521
|
+
an idenfier is also a token, so a string is never necessary to store
|
1522
|
+
it). <code>Sym.t</code> gives the type of the symbol. <code>Sym.r</code> is usually
|
1523
|
+
the register in which the corresponding variable is stored. <code>Sym.c</code> is
|
1524
|
+
usually a constant associated to the symbol like its address for normal
|
1525
|
+
symbols, and the number of entries for symbols representing arrays.
|
1526
|
+
Variable length array types use <code>Sym.c</code> as a location on the stack
|
1527
|
+
which holds the runtime sizeof for the type.
|
1528
|
+
</p>
|
1529
|
+
<p>Four main symbol stacks are defined:
|
1530
|
+
</p>
|
1531
|
+
<dl compact="compact">
|
1532
|
+
<dt> <code>define_stack</code></dt>
|
1533
|
+
<dd><p>for the macros (<code>#define</code>s).
|
1534
|
+
</p>
|
1535
|
+
</dd>
|
1536
|
+
<dt> <code>global_stack</code></dt>
|
1537
|
+
<dd><p>for the global variables, functions and types.
|
1538
|
+
</p>
|
1539
|
+
</dd>
|
1540
|
+
<dt> <code>local_stack</code></dt>
|
1541
|
+
<dd><p>for the local variables, functions and types.
|
1542
|
+
</p>
|
1543
|
+
</dd>
|
1544
|
+
<dt> <code>global_label_stack</code></dt>
|
1545
|
+
<dd><p>for the local labels (for <code>goto</code>).
|
1546
|
+
</p>
|
1547
|
+
</dd>
|
1548
|
+
<dt> <code>label_stack</code></dt>
|
1549
|
+
<dd><p>for GCC block local labels (see the <code>__label__</code> keyword).
|
1550
|
+
</p>
|
1551
|
+
</dd>
|
1552
|
+
</dl>
|
1553
|
+
|
1554
|
+
<p><code>sym_push()</code> is used to add a new symbol in the local symbol
|
1555
|
+
stack. If no local symbol stack is active, it is added in the global
|
1556
|
+
symbol stack.
|
1557
|
+
</p>
|
1558
|
+
<p><code>sym_pop(st,b)</code> pops symbols from the symbol stack <var>st</var> until
|
1559
|
+
the symbol <var>b</var> is on the top of stack. If <var>b</var> is NULL, the stack
|
1560
|
+
is emptied.
|
1561
|
+
</p>
|
1562
|
+
<p><code>sym_find(v)</code> return the symbol associated to the identifier
|
1563
|
+
<var>v</var>. The local stack is searched first from top to bottom, then the
|
1564
|
+
global stack.
|
1565
|
+
</p>
|
1566
|
+
<hr size="6">
|
1567
|
+
<a name="Sections"></a>
|
1568
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1569
|
+
<tr><td valign="middle" align="left">[<a href="#Symbols" title="Previous section in reading order"> < </a>]</td>
|
1570
|
+
<td valign="middle" align="left">[<a href="#Code-generation" title="Next section in reading order"> > </a>]</td>
|
1571
|
+
<td valign="middle" align="left"> </td>
|
1572
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1573
|
+
<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
|
1574
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1575
|
+
<td valign="middle" align="left"> </td>
|
1576
|
+
<td valign="middle" align="left"> </td>
|
1577
|
+
<td valign="middle" align="left"> </td>
|
1578
|
+
<td valign="middle" align="left"> </td>
|
1579
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1580
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1581
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1582
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1583
|
+
</tr></table>
|
1584
|
+
<h2 class="section">8.6 Sections</h2>
|
1585
|
+
|
1586
|
+
<p>The generated code and datas are written in sections. The structure
|
1587
|
+
<code>Section</code> contains all the necessary information for a given
|
1588
|
+
section. <code>new_section()</code> creates a new section. ELF file semantics
|
1589
|
+
is assumed for each section.
|
1590
|
+
</p>
|
1591
|
+
<p>The following sections are predefined:
|
1592
|
+
</p>
|
1593
|
+
<dl compact="compact">
|
1594
|
+
<dt> <code>text_section</code></dt>
|
1595
|
+
<dd><p>is the section containing the generated code. <var>ind</var> contains the
|
1596
|
+
current position in the code section.
|
1597
|
+
</p>
|
1598
|
+
</dd>
|
1599
|
+
<dt> <code>data_section</code></dt>
|
1600
|
+
<dd><p>contains initialized data
|
1601
|
+
</p>
|
1602
|
+
</dd>
|
1603
|
+
<dt> <code>bss_section</code></dt>
|
1604
|
+
<dd><p>contains uninitialized data
|
1605
|
+
</p>
|
1606
|
+
</dd>
|
1607
|
+
<dt> <code>bounds_section</code></dt>
|
1608
|
+
<dt> <code>lbounds_section</code></dt>
|
1609
|
+
<dd><p>are used when bound checking is activated
|
1610
|
+
</p>
|
1611
|
+
</dd>
|
1612
|
+
<dt> <code>stab_section</code></dt>
|
1613
|
+
<dt> <code>stabstr_section</code></dt>
|
1614
|
+
<dd><p>are used when debugging is actived to store debug information
|
1615
|
+
</p>
|
1616
|
+
</dd>
|
1617
|
+
<dt> <code>symtab_section</code></dt>
|
1618
|
+
<dt> <code>strtab_section</code></dt>
|
1619
|
+
<dd><p>contain the exported symbols (currently only used for debugging).
|
1620
|
+
</p>
|
1621
|
+
</dd>
|
1622
|
+
</dl>
|
1623
|
+
|
1624
|
+
<hr size="6">
|
1625
|
+
<a name="Code-generation"></a>
|
1626
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1627
|
+
<tr><td valign="middle" align="left">[<a href="#Sections" title="Previous section in reading order"> < </a>]</td>
|
1628
|
+
<td valign="middle" align="left">[<a href="#Introduction-2" title="Next section in reading order"> > </a>]</td>
|
1629
|
+
<td valign="middle" align="left"> </td>
|
1630
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1631
|
+
<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
|
1632
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1633
|
+
<td valign="middle" align="left"> </td>
|
1634
|
+
<td valign="middle" align="left"> </td>
|
1635
|
+
<td valign="middle" align="left"> </td>
|
1636
|
+
<td valign="middle" align="left"> </td>
|
1637
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1638
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1639
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1640
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1641
|
+
</tr></table>
|
1642
|
+
<h2 class="section">8.7 Code generation</h2>
|
1643
|
+
<a name="index-code-generation"></a>
|
1644
|
+
|
1645
|
+
<hr size="6">
|
1646
|
+
<a name="Introduction-2"></a>
|
1647
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1648
|
+
<tr><td valign="middle" align="left">[<a href="#Code-generation" title="Previous section in reading order"> < </a>]</td>
|
1649
|
+
<td valign="middle" align="left">[<a href="#The-value-stack" title="Next section in reading order"> > </a>]</td>
|
1650
|
+
<td valign="middle" align="left"> </td>
|
1651
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1652
|
+
<td valign="middle" align="left">[<a href="#Code-generation" title="Up section"> Up </a>]</td>
|
1653
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1654
|
+
<td valign="middle" align="left"> </td>
|
1655
|
+
<td valign="middle" align="left"> </td>
|
1656
|
+
<td valign="middle" align="left"> </td>
|
1657
|
+
<td valign="middle" align="left"> </td>
|
1658
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1659
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1660
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1661
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1662
|
+
</tr></table>
|
1663
|
+
<h3 class="subsection">8.7.1 Introduction</h3>
|
1664
|
+
|
1665
|
+
<p>The TCC code generator directly generates linked binary code in one
|
1666
|
+
pass. It is rather unusual these days (see gcc for example which
|
1667
|
+
generates text assembly), but it can be very fast and surprisingly
|
1668
|
+
little complicated.
|
1669
|
+
</p>
|
1670
|
+
<p>The TCC code generator is register based. Optimization is only done at
|
1671
|
+
the expression level. No intermediate representation of expression is
|
1672
|
+
kept except the current values stored in the <em>value stack</em>.
|
1673
|
+
</p>
|
1674
|
+
<p>On x86, three temporary registers are used. When more registers are
|
1675
|
+
needed, one register is spilled into a new temporary variable on the stack.
|
1676
|
+
</p>
|
1677
|
+
<hr size="6">
|
1678
|
+
<a name="The-value-stack"></a>
|
1679
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1680
|
+
<tr><td valign="middle" align="left">[<a href="#Introduction-2" title="Previous section in reading order"> < </a>]</td>
|
1681
|
+
<td valign="middle" align="left">[<a href="#Manipulating-the-value-stack" title="Next section in reading order"> > </a>]</td>
|
1682
|
+
<td valign="middle" align="left"> </td>
|
1683
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1684
|
+
<td valign="middle" align="left">[<a href="#Code-generation" title="Up section"> Up </a>]</td>
|
1685
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1686
|
+
<td valign="middle" align="left"> </td>
|
1687
|
+
<td valign="middle" align="left"> </td>
|
1688
|
+
<td valign="middle" align="left"> </td>
|
1689
|
+
<td valign="middle" align="left"> </td>
|
1690
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1691
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1692
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1693
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1694
|
+
</tr></table>
|
1695
|
+
<h3 class="subsection">8.7.2 The value stack</h3>
|
1696
|
+
<a name="index-value-stack_002c-introduction"></a>
|
1697
|
+
|
1698
|
+
<p>When an expression is parsed, its value is pushed on the value stack
|
1699
|
+
(<var>vstack</var>). The top of the value stack is <var>vtop</var>. Each value
|
1700
|
+
stack entry is the structure <code>SValue</code>.
|
1701
|
+
</p>
|
1702
|
+
<p><code>SValue.t</code> is the type. <code>SValue.r</code> indicates how the value is
|
1703
|
+
currently stored in the generated code. It is usually a CPU register
|
1704
|
+
index (<code>REG_xxx</code> constants), but additional values and flags are
|
1705
|
+
defined:
|
1706
|
+
</p>
|
1707
|
+
<table><tr><td> </td><td><pre class="example">#define VT_CONST 0x00f0
|
1708
|
+
#define VT_LLOCAL 0x00f1
|
1709
|
+
#define VT_LOCAL 0x00f2
|
1710
|
+
#define VT_CMP 0x00f3
|
1711
|
+
#define VT_JMP 0x00f4
|
1712
|
+
#define VT_JMPI 0x00f5
|
1713
|
+
#define VT_LVAL 0x0100
|
1714
|
+
#define VT_SYM 0x0200
|
1715
|
+
#define VT_MUSTCAST 0x0400
|
1716
|
+
#define VT_MUSTBOUND 0x0800
|
1717
|
+
#define VT_BOUNDED 0x8000
|
1718
|
+
#define VT_LVAL_BYTE 0x1000
|
1719
|
+
#define VT_LVAL_SHORT 0x2000
|
1720
|
+
#define VT_LVAL_UNSIGNED 0x4000
|
1721
|
+
#define VT_LVAL_TYPE (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)
|
1722
|
+
</pre></td></tr></table>
|
1723
|
+
|
1724
|
+
<dl compact="compact">
|
1725
|
+
<dt> <code>VT_CONST</code></dt>
|
1726
|
+
<dd><p>indicates that the value is a constant. It is stored in the union
|
1727
|
+
<code>SValue.c</code>, depending on its type.
|
1728
|
+
</p>
|
1729
|
+
</dd>
|
1730
|
+
<dt> <code>VT_LOCAL</code></dt>
|
1731
|
+
<dd><p>indicates a local variable pointer at offset <code>SValue.c.i</code> in the
|
1732
|
+
stack.
|
1733
|
+
</p>
|
1734
|
+
</dd>
|
1735
|
+
<dt> <code>VT_CMP</code></dt>
|
1736
|
+
<dd><p>indicates that the value is actually stored in the CPU flags (i.e. the
|
1737
|
+
value is the consequence of a test). The value is either 0 or 1. The
|
1738
|
+
actual CPU flags used is indicated in <code>SValue.c.i</code>.
|
1739
|
+
</p>
|
1740
|
+
<p>If any code is generated which destroys the CPU flags, this value MUST be
|
1741
|
+
put in a normal register.
|
1742
|
+
</p>
|
1743
|
+
</dd>
|
1744
|
+
<dt> <code>VT_JMP</code></dt>
|
1745
|
+
<dt> <code>VT_JMPI</code></dt>
|
1746
|
+
<dd><p>indicates that the value is the consequence of a conditional jump. For VT_JMP,
|
1747
|
+
it is 1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.
|
1748
|
+
</p>
|
1749
|
+
<p>These values are used to compile the <code>||</code> and <code>&&</code> logical
|
1750
|
+
operators.
|
1751
|
+
</p>
|
1752
|
+
<p>If any code is generated, this value MUST be put in a normal
|
1753
|
+
register. Otherwise, the generated code won’t be executed if the jump is
|
1754
|
+
taken.
|
1755
|
+
</p>
|
1756
|
+
</dd>
|
1757
|
+
<dt> <code>VT_LVAL</code></dt>
|
1758
|
+
<dd><p>is a flag indicating that the value is actually an lvalue (left value of
|
1759
|
+
an assignment). It means that the value stored is actually a pointer to
|
1760
|
+
the wanted value.
|
1761
|
+
</p>
|
1762
|
+
<p>Understanding the use <code>VT_LVAL</code> is very important if you want to
|
1763
|
+
understand how TCC works.
|
1764
|
+
</p>
|
1765
|
+
</dd>
|
1766
|
+
<dt> <code>VT_LVAL_BYTE</code></dt>
|
1767
|
+
<dt> <code>VT_LVAL_SHORT</code></dt>
|
1768
|
+
<dt> <code>VT_LVAL_UNSIGNED</code></dt>
|
1769
|
+
<dd><p>if the lvalue has an integer type, then these flags give its real
|
1770
|
+
type. The type alone is not enough in case of cast optimisations.
|
1771
|
+
</p>
|
1772
|
+
</dd>
|
1773
|
+
<dt> <code>VT_LLOCAL</code></dt>
|
1774
|
+
<dd><p>is a saved lvalue on the stack. <code>VT_LLOCAL</code> should be eliminated
|
1775
|
+
ASAP because its semantics are rather complicated.
|
1776
|
+
</p>
|
1777
|
+
</dd>
|
1778
|
+
<dt> <code>VT_MUSTCAST</code></dt>
|
1779
|
+
<dd><p>indicates that a cast to the value type must be performed if the value
|
1780
|
+
is used (lazy casting).
|
1781
|
+
</p>
|
1782
|
+
</dd>
|
1783
|
+
<dt> <code>VT_SYM</code></dt>
|
1784
|
+
<dd><p>indicates that the symbol <code>SValue.sym</code> must be added to the constant.
|
1785
|
+
</p>
|
1786
|
+
</dd>
|
1787
|
+
<dt> <code>VT_MUSTBOUND</code></dt>
|
1788
|
+
<dt> <code>VT_BOUNDED</code></dt>
|
1789
|
+
<dd><p>are only used for optional bound checking.
|
1790
|
+
</p>
|
1791
|
+
</dd>
|
1792
|
+
</dl>
|
1793
|
+
|
1794
|
+
<hr size="6">
|
1795
|
+
<a name="Manipulating-the-value-stack"></a>
|
1796
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1797
|
+
<tr><td valign="middle" align="left">[<a href="#The-value-stack" title="Previous section in reading order"> < </a>]</td>
|
1798
|
+
<td valign="middle" align="left">[<a href="#CPU-dependent-code-generation" title="Next section in reading order"> > </a>]</td>
|
1799
|
+
<td valign="middle" align="left"> </td>
|
1800
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1801
|
+
<td valign="middle" align="left">[<a href="#Code-generation" title="Up section"> Up </a>]</td>
|
1802
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1803
|
+
<td valign="middle" align="left"> </td>
|
1804
|
+
<td valign="middle" align="left"> </td>
|
1805
|
+
<td valign="middle" align="left"> </td>
|
1806
|
+
<td valign="middle" align="left"> </td>
|
1807
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1808
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1809
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1810
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1811
|
+
</tr></table>
|
1812
|
+
<h3 class="subsection">8.7.3 Manipulating the value stack</h3>
|
1813
|
+
<a name="index-value-stack"></a>
|
1814
|
+
|
1815
|
+
<p><code>vsetc()</code> and <code>vset()</code> pushes a new value on the value
|
1816
|
+
stack. If the previous <var>vtop</var> was stored in a very unsafe place(for
|
1817
|
+
example in the CPU flags), then some code is generated to put the
|
1818
|
+
previous <var>vtop</var> in a safe storage.
|
1819
|
+
</p>
|
1820
|
+
<p><code>vpop()</code> pops <var>vtop</var>. In some cases, it also generates cleanup
|
1821
|
+
code (for example if stacked floating point registers are used as on
|
1822
|
+
x86).
|
1823
|
+
</p>
|
1824
|
+
<p>The <code>gv(rc)</code> function generates code to evaluate <var>vtop</var> (the
|
1825
|
+
top value of the stack) into registers. <var>rc</var> selects in which
|
1826
|
+
register class the value should be put. <code>gv()</code> is the <em>most
|
1827
|
+
important function</em> of the code generator.
|
1828
|
+
</p>
|
1829
|
+
<p><code>gv2()</code> is the same as <code>gv()</code> but for the top two stack
|
1830
|
+
entries.
|
1831
|
+
</p>
|
1832
|
+
<hr size="6">
|
1833
|
+
<a name="CPU-dependent-code-generation"></a>
|
1834
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1835
|
+
<tr><td valign="middle" align="left">[<a href="#Manipulating-the-value-stack" title="Previous section in reading order"> < </a>]</td>
|
1836
|
+
<td valign="middle" align="left">[<a href="#Optimizations-done" title="Next section in reading order"> > </a>]</td>
|
1837
|
+
<td valign="middle" align="left"> </td>
|
1838
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1839
|
+
<td valign="middle" align="left">[<a href="#Code-generation" title="Up section"> Up </a>]</td>
|
1840
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1841
|
+
<td valign="middle" align="left"> </td>
|
1842
|
+
<td valign="middle" align="left"> </td>
|
1843
|
+
<td valign="middle" align="left"> </td>
|
1844
|
+
<td valign="middle" align="left"> </td>
|
1845
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1846
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1847
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1848
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1849
|
+
</tr></table>
|
1850
|
+
<h3 class="subsection">8.7.4 CPU dependent code generation</h3>
|
1851
|
+
<a name="index-CPU-dependent"></a>
|
1852
|
+
<p>See the ‘<tt>i386-gen.c</tt>’ file to have an example.
|
1853
|
+
</p>
|
1854
|
+
<dl compact="compact">
|
1855
|
+
<dt> <code>load()</code></dt>
|
1856
|
+
<dd><p>must generate the code needed to load a stack value into a register.
|
1857
|
+
</p>
|
1858
|
+
</dd>
|
1859
|
+
<dt> <code>store()</code></dt>
|
1860
|
+
<dd><p>must generate the code needed to store a register into a stack value
|
1861
|
+
lvalue.
|
1862
|
+
</p>
|
1863
|
+
</dd>
|
1864
|
+
<dt> <code>gfunc_start()</code></dt>
|
1865
|
+
<dt> <code>gfunc_param()</code></dt>
|
1866
|
+
<dt> <code>gfunc_call()</code></dt>
|
1867
|
+
<dd><p>should generate a function call
|
1868
|
+
</p>
|
1869
|
+
</dd>
|
1870
|
+
<dt> <code>gfunc_prolog()</code></dt>
|
1871
|
+
<dt> <code>gfunc_epilog()</code></dt>
|
1872
|
+
<dd><p>should generate a function prolog/epilog.
|
1873
|
+
</p>
|
1874
|
+
</dd>
|
1875
|
+
<dt> <code>gen_opi(op)</code></dt>
|
1876
|
+
<dd><p>must generate the binary integer operation <var>op</var> on the two top
|
1877
|
+
entries of the stack which are guaranted to contain integer types.
|
1878
|
+
</p>
|
1879
|
+
<p>The result value should be put on the stack.
|
1880
|
+
</p>
|
1881
|
+
</dd>
|
1882
|
+
<dt> <code>gen_opf(op)</code></dt>
|
1883
|
+
<dd><p>same as <code>gen_opi()</code> for floating point operations. The two top
|
1884
|
+
entries of the stack are guaranted to contain floating point values of
|
1885
|
+
same types.
|
1886
|
+
</p>
|
1887
|
+
</dd>
|
1888
|
+
<dt> <code>gen_cvt_itof()</code></dt>
|
1889
|
+
<dd><p>integer to floating point conversion.
|
1890
|
+
</p>
|
1891
|
+
</dd>
|
1892
|
+
<dt> <code>gen_cvt_ftoi()</code></dt>
|
1893
|
+
<dd><p>floating point to integer conversion.
|
1894
|
+
</p>
|
1895
|
+
</dd>
|
1896
|
+
<dt> <code>gen_cvt_ftof()</code></dt>
|
1897
|
+
<dd><p>floating point to floating point of different size conversion.
|
1898
|
+
</p>
|
1899
|
+
</dd>
|
1900
|
+
<dt> <code>gen_bounded_ptr_add()</code></dt>
|
1901
|
+
<dt> <code>gen_bounded_ptr_deref()</code></dt>
|
1902
|
+
<dd><p>are only used for bounds checking.
|
1903
|
+
</p>
|
1904
|
+
</dd>
|
1905
|
+
</dl>
|
1906
|
+
|
1907
|
+
<hr size="6">
|
1908
|
+
<a name="Optimizations-done"></a>
|
1909
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1910
|
+
<tr><td valign="middle" align="left">[<a href="#CPU-dependent-code-generation" title="Previous section in reading order"> < </a>]</td>
|
1911
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next section in reading order"> > </a>]</td>
|
1912
|
+
<td valign="middle" align="left"> </td>
|
1913
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1914
|
+
<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
|
1915
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> >> </a>]</td>
|
1916
|
+
<td valign="middle" align="left"> </td>
|
1917
|
+
<td valign="middle" align="left"> </td>
|
1918
|
+
<td valign="middle" align="left"> </td>
|
1919
|
+
<td valign="middle" align="left"> </td>
|
1920
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1921
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1922
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1923
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1924
|
+
</tr></table>
|
1925
|
+
<h2 class="section">8.8 Optimizations done</h2>
|
1926
|
+
<a name="index-optimizations"></a>
|
1927
|
+
<a name="index-constant-propagation"></a>
|
1928
|
+
<a name="index-strength-reduction"></a>
|
1929
|
+
<a name="index-comparison-operators"></a>
|
1930
|
+
<a name="index-caching-processor-flags"></a>
|
1931
|
+
<a name="index-flags_002c-caching"></a>
|
1932
|
+
<a name="index-jump-optimization"></a>
|
1933
|
+
<p>Constant propagation is done for all operations. Multiplications and
|
1934
|
+
divisions are optimized to shifts when appropriate. Comparison
|
1935
|
+
operators are optimized by maintaining a special cache for the
|
1936
|
+
processor flags. &&, || and ! are optimized by maintaining a special
|
1937
|
+
’jump target’ value. No other jump optimization is currently performed
|
1938
|
+
because it would require to store the code in a more abstract fashion.
|
1939
|
+
</p>
|
1940
|
+
<hr size="6">
|
1941
|
+
<a name="Concept-Index"></a>
|
1942
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
1943
|
+
<tr><td valign="middle" align="left">[<a href="#Optimizations-done" title="Previous section in reading order"> < </a>]</td>
|
1944
|
+
<td valign="middle" align="left">[ > ]</td>
|
1945
|
+
<td valign="middle" align="left"> </td>
|
1946
|
+
<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> << </a>]</td>
|
1947
|
+
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
|
1948
|
+
<td valign="middle" align="left">[ >> ]</td>
|
1949
|
+
<td valign="middle" align="left"> </td>
|
1950
|
+
<td valign="middle" align="left"> </td>
|
1951
|
+
<td valign="middle" align="left"> </td>
|
1952
|
+
<td valign="middle" align="left"> </td>
|
1953
|
+
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
1954
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
1955
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
1956
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
1957
|
+
</tr></table>
|
1958
|
+
<h1 class="unnumbered">Concept Index</h1>
|
1959
|
+
<table><tr><th valign="top">Jump to: </th><td><a href="#Concept-Index_cp_symbol-1" class="summary-letter"><b>_</b></a>
|
1960
|
+
|
1961
|
+
<br>
|
1962
|
+
<a href="#Concept-Index_cp_letter-A" class="summary-letter"><b>A</b></a>
|
1963
|
+
|
1964
|
+
<a href="#Concept-Index_cp_letter-B" class="summary-letter"><b>B</b></a>
|
1965
|
+
|
1966
|
+
<a href="#Concept-Index_cp_letter-C" class="summary-letter"><b>C</b></a>
|
1967
|
+
|
1968
|
+
<a href="#Concept-Index_cp_letter-D" class="summary-letter"><b>D</b></a>
|
1969
|
+
|
1970
|
+
<a href="#Concept-Index_cp_letter-E" class="summary-letter"><b>E</b></a>
|
1971
|
+
|
1972
|
+
<a href="#Concept-Index_cp_letter-F" class="summary-letter"><b>F</b></a>
|
1973
|
+
|
1974
|
+
<a href="#Concept-Index_cp_letter-G" class="summary-letter"><b>G</b></a>
|
1975
|
+
|
1976
|
+
<a href="#Concept-Index_cp_letter-I" class="summary-letter"><b>I</b></a>
|
1977
|
+
|
1978
|
+
<a href="#Concept-Index_cp_letter-J" class="summary-letter"><b>J</b></a>
|
1979
|
+
|
1980
|
+
<a href="#Concept-Index_cp_letter-L" class="summary-letter"><b>L</b></a>
|
1981
|
+
|
1982
|
+
<a href="#Concept-Index_cp_letter-M" class="summary-letter"><b>M</b></a>
|
1983
|
+
|
1984
|
+
<a href="#Concept-Index_cp_letter-O" class="summary-letter"><b>O</b></a>
|
1985
|
+
|
1986
|
+
<a href="#Concept-Index_cp_letter-P" class="summary-letter"><b>P</b></a>
|
1987
|
+
|
1988
|
+
<a href="#Concept-Index_cp_letter-Q" class="summary-letter"><b>Q</b></a>
|
1989
|
+
|
1990
|
+
<a href="#Concept-Index_cp_letter-R" class="summary-letter"><b>R</b></a>
|
1991
|
+
|
1992
|
+
<a href="#Concept-Index_cp_letter-S" class="summary-letter"><b>S</b></a>
|
1993
|
+
|
1994
|
+
<a href="#Concept-Index_cp_letter-T" class="summary-letter"><b>T</b></a>
|
1995
|
+
|
1996
|
+
<a href="#Concept-Index_cp_letter-U" class="summary-letter"><b>U</b></a>
|
1997
|
+
|
1998
|
+
<a href="#Concept-Index_cp_letter-V" class="summary-letter"><b>V</b></a>
|
1999
|
+
|
2000
|
+
<a href="#Concept-Index_cp_letter-W" class="summary-letter"><b>W</b></a>
|
2001
|
+
|
2002
|
+
</td></tr></table>
|
2003
|
+
<table border="0" class="index-cp">
|
2004
|
+
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
|
2005
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2006
|
+
<tr><th><a name="Concept-Index_cp_symbol-1">_</a></th><td></td><td></td></tr>
|
2007
|
+
<tr><td></td><td valign="top"><a href="#index-_005f_005fasm_005f_005f">__asm__</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2008
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2009
|
+
<tr><th><a name="Concept-Index_cp_letter-A">A</a></th><td></td><td></td></tr>
|
2010
|
+
<tr><td></td><td valign="top"><a href="#index-align-directive">align directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2011
|
+
<tr><td></td><td valign="top"><a href="#index-aligned-attribute">aligned attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2012
|
+
<tr><td></td><td valign="top"><a href="#index-ascii-directive">ascii directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2013
|
+
<tr><td></td><td valign="top"><a href="#index-asciz-directive">asciz directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2014
|
+
<tr><td></td><td valign="top"><a href="#index-assembler">assembler</a></td><td valign="top"><a href="#X86-Assembler">4.5 X86 Assembler</a></td></tr>
|
2015
|
+
<tr><td></td><td valign="top"><a href="#index-assembler-directives">assembler directives</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2016
|
+
<tr><td></td><td valign="top"><a href="#index-assembly_002c-inline">assembly, inline</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2017
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2018
|
+
<tr><th><a name="Concept-Index_cp_letter-B">B</a></th><td></td><td></td></tr>
|
2019
|
+
<tr><td></td><td valign="top"><a href="#index-bound-checks">bound checks</a></td><td valign="top"><a href="#Bounds">6. TinyCC Memory and Bound checks</a></td></tr>
|
2020
|
+
<tr><td></td><td valign="top"><a href="#index-bss-directive">bss directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2021
|
+
<tr><td></td><td valign="top"><a href="#index-byte-directive">byte directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2022
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2023
|
+
<tr><th><a name="Concept-Index_cp_letter-C">C</a></th><td></td><td></td></tr>
|
2024
|
+
<tr><td></td><td valign="top"><a href="#index-caching-processor-flags">caching processor flags</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
|
2025
|
+
<tr><td></td><td valign="top"><a href="#index-cdecl-attribute">cdecl attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2026
|
+
<tr><td></td><td valign="top"><a href="#index-code-generation">code generation</a></td><td valign="top"><a href="#Code-generation">8.7 Code generation</a></td></tr>
|
2027
|
+
<tr><td></td><td valign="top"><a href="#index-comparison-operators">comparison operators</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
|
2028
|
+
<tr><td></td><td valign="top"><a href="#index-constant-propagation">constant propagation</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
|
2029
|
+
<tr><td></td><td valign="top"><a href="#index-CPU-dependent">CPU dependent</a></td><td valign="top"><a href="#CPU-dependent-code-generation">8.7.4 CPU dependent code generation</a></td></tr>
|
2030
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2031
|
+
<tr><th><a name="Concept-Index_cp_letter-D">D</a></th><td></td><td></td></tr>
|
2032
|
+
<tr><td></td><td valign="top"><a href="#index-data-directive">data directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2033
|
+
<tr><td></td><td valign="top"><a href="#index-directives_002c-assembler">directives, assembler</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2034
|
+
<tr><td></td><td valign="top"><a href="#index-dllexport-attribute">dllexport attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2035
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2036
|
+
<tr><th><a name="Concept-Index_cp_letter-E">E</a></th><td></td><td></td></tr>
|
2037
|
+
<tr><td></td><td valign="top"><a href="#index-ELF">ELF</a></td><td valign="top"><a href="#ELF-file-generation">5.1 ELF file generation</a></td></tr>
|
2038
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2039
|
+
<tr><th><a name="Concept-Index_cp_letter-F">F</a></th><td></td><td></td></tr>
|
2040
|
+
<tr><td></td><td valign="top"><a href="#index-FILE_002c-linker-command">FILE, linker command</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
|
2041
|
+
<tr><td></td><td valign="top"><a href="#index-fill-directive">fill directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2042
|
+
<tr><td></td><td valign="top"><a href="#index-flags_002c-caching">flags, caching</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
|
2043
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2044
|
+
<tr><th><a name="Concept-Index_cp_letter-G">G</a></th><td></td><td></td></tr>
|
2045
|
+
<tr><td></td><td valign="top"><a href="#index-gas">gas</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2046
|
+
<tr><td></td><td valign="top"><a href="#index-global-directive">global directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2047
|
+
<tr><td></td><td valign="top"><a href="#index-globl-directive">globl directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2048
|
+
<tr><td></td><td valign="top"><a href="#index-GROUP_002c-linker-command">GROUP, linker command</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
|
2049
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2050
|
+
<tr><th><a name="Concept-Index_cp_letter-I">I</a></th><td></td><td></td></tr>
|
2051
|
+
<tr><td></td><td valign="top"><a href="#index-inline-assembly">inline assembly</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2052
|
+
<tr><td></td><td valign="top"><a href="#index-int-directive">int directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2053
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2054
|
+
<tr><th><a name="Concept-Index_cp_letter-J">J</a></th><td></td><td></td></tr>
|
2055
|
+
<tr><td></td><td valign="top"><a href="#index-jump-optimization">jump optimization</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
|
2056
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2057
|
+
<tr><th><a name="Concept-Index_cp_letter-L">L</a></th><td></td><td></td></tr>
|
2058
|
+
<tr><td></td><td valign="top"><a href="#index-linker">linker</a></td><td valign="top"><a href="#linker">5. TinyCC Linker</a></td></tr>
|
2059
|
+
<tr><td></td><td valign="top"><a href="#index-linker-scripts">linker scripts</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
|
2060
|
+
<tr><td></td><td valign="top"><a href="#index-long-directive">long directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2061
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2062
|
+
<tr><th><a name="Concept-Index_cp_letter-M">M</a></th><td></td><td></td></tr>
|
2063
|
+
<tr><td></td><td valign="top"><a href="#index-memory-checks">memory checks</a></td><td valign="top"><a href="#Bounds">6. TinyCC Memory and Bound checks</a></td></tr>
|
2064
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2065
|
+
<tr><th><a name="Concept-Index_cp_letter-O">O</a></th><td></td><td></td></tr>
|
2066
|
+
<tr><td></td><td valign="top"><a href="#index-optimizations">optimizations</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
|
2067
|
+
<tr><td></td><td valign="top"><a href="#index-org-directive">org directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2068
|
+
<tr><td></td><td valign="top"><a href="#index-OUTPUT_005fFORMAT_002c-linker-command">OUTPUT_FORMAT, linker command</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
|
2069
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2070
|
+
<tr><th><a name="Concept-Index_cp_letter-P">P</a></th><td></td><td></td></tr>
|
2071
|
+
<tr><td></td><td valign="top"><a href="#index-packed-attribute">packed attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2072
|
+
<tr><td></td><td valign="top"><a href="#index-PE_002di386">PE-i386</a></td><td valign="top"><a href="#PE_002di386-file-generation">5.3 PE-i386 file generation</a></td></tr>
|
2073
|
+
<tr><td></td><td valign="top"><a href="#index-previous-directive">previous directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2074
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2075
|
+
<tr><th><a name="Concept-Index_cp_letter-Q">Q</a></th><td></td><td></td></tr>
|
2076
|
+
<tr><td></td><td valign="top"><a href="#index-quad-directive">quad directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2077
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2078
|
+
<tr><th><a name="Concept-Index_cp_letter-R">R</a></th><td></td><td></td></tr>
|
2079
|
+
<tr><td></td><td valign="top"><a href="#index-regparm-attribute">regparm attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2080
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2081
|
+
<tr><th><a name="Concept-Index_cp_letter-S">S</a></th><td></td><td></td></tr>
|
2082
|
+
<tr><td></td><td valign="top"><a href="#index-scripts_002c-linker">scripts, linker</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
|
2083
|
+
<tr><td></td><td valign="top"><a href="#index-section-attribute">section attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2084
|
+
<tr><td></td><td valign="top"><a href="#index-section-directive">section directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2085
|
+
<tr><td></td><td valign="top"><a href="#index-short-directive">short directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2086
|
+
<tr><td></td><td valign="top"><a href="#index-skip-directive">skip directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2087
|
+
<tr><td></td><td valign="top"><a href="#index-space-directive">space directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2088
|
+
<tr><td></td><td valign="top"><a href="#index-stdcall-attribute">stdcall attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2089
|
+
<tr><td></td><td valign="top"><a href="#index-strength-reduction">strength reduction</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
|
2090
|
+
<tr><td></td><td valign="top"><a href="#index-string-directive">string directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2091
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2092
|
+
<tr><th><a name="Concept-Index_cp_letter-T">T</a></th><td></td><td></td></tr>
|
2093
|
+
<tr><td></td><td valign="top"><a href="#index-TARGET_002c-linker-command">TARGET, linker command</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
|
2094
|
+
<tr><td></td><td valign="top"><a href="#index-text-directive">text directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2095
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2096
|
+
<tr><th><a name="Concept-Index_cp_letter-U">U</a></th><td></td><td></td></tr>
|
2097
|
+
<tr><td></td><td valign="top"><a href="#index-unused-attribute">unused attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
|
2098
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2099
|
+
<tr><th><a name="Concept-Index_cp_letter-V">V</a></th><td></td><td></td></tr>
|
2100
|
+
<tr><td></td><td valign="top"><a href="#index-value-stack">value stack</a></td><td valign="top"><a href="#Manipulating-the-value-stack">8.7.3 Manipulating the value stack</a></td></tr>
|
2101
|
+
<tr><td></td><td valign="top"><a href="#index-value-stack_002c-introduction">value stack, introduction</a></td><td valign="top"><a href="#The-value-stack">8.7.2 The value stack</a></td></tr>
|
2102
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2103
|
+
<tr><th><a name="Concept-Index_cp_letter-W">W</a></th><td></td><td></td></tr>
|
2104
|
+
<tr><td></td><td valign="top"><a href="#index-word-directive">word directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
|
2105
|
+
<tr><td colspan="3"> <hr></td></tr>
|
2106
|
+
</table>
|
2107
|
+
<table><tr><th valign="top">Jump to: </th><td><a href="#Concept-Index_cp_symbol-1" class="summary-letter"><b>_</b></a>
|
2108
|
+
|
2109
|
+
<br>
|
2110
|
+
<a href="#Concept-Index_cp_letter-A" class="summary-letter"><b>A</b></a>
|
2111
|
+
|
2112
|
+
<a href="#Concept-Index_cp_letter-B" class="summary-letter"><b>B</b></a>
|
2113
|
+
|
2114
|
+
<a href="#Concept-Index_cp_letter-C" class="summary-letter"><b>C</b></a>
|
2115
|
+
|
2116
|
+
<a href="#Concept-Index_cp_letter-D" class="summary-letter"><b>D</b></a>
|
2117
|
+
|
2118
|
+
<a href="#Concept-Index_cp_letter-E" class="summary-letter"><b>E</b></a>
|
2119
|
+
|
2120
|
+
<a href="#Concept-Index_cp_letter-F" class="summary-letter"><b>F</b></a>
|
2121
|
+
|
2122
|
+
<a href="#Concept-Index_cp_letter-G" class="summary-letter"><b>G</b></a>
|
2123
|
+
|
2124
|
+
<a href="#Concept-Index_cp_letter-I" class="summary-letter"><b>I</b></a>
|
2125
|
+
|
2126
|
+
<a href="#Concept-Index_cp_letter-J" class="summary-letter"><b>J</b></a>
|
2127
|
+
|
2128
|
+
<a href="#Concept-Index_cp_letter-L" class="summary-letter"><b>L</b></a>
|
2129
|
+
|
2130
|
+
<a href="#Concept-Index_cp_letter-M" class="summary-letter"><b>M</b></a>
|
2131
|
+
|
2132
|
+
<a href="#Concept-Index_cp_letter-O" class="summary-letter"><b>O</b></a>
|
2133
|
+
|
2134
|
+
<a href="#Concept-Index_cp_letter-P" class="summary-letter"><b>P</b></a>
|
2135
|
+
|
2136
|
+
<a href="#Concept-Index_cp_letter-Q" class="summary-letter"><b>Q</b></a>
|
2137
|
+
|
2138
|
+
<a href="#Concept-Index_cp_letter-R" class="summary-letter"><b>R</b></a>
|
2139
|
+
|
2140
|
+
<a href="#Concept-Index_cp_letter-S" class="summary-letter"><b>S</b></a>
|
2141
|
+
|
2142
|
+
<a href="#Concept-Index_cp_letter-T" class="summary-letter"><b>T</b></a>
|
2143
|
+
|
2144
|
+
<a href="#Concept-Index_cp_letter-U" class="summary-letter"><b>U</b></a>
|
2145
|
+
|
2146
|
+
<a href="#Concept-Index_cp_letter-V" class="summary-letter"><b>V</b></a>
|
2147
|
+
|
2148
|
+
<a href="#Concept-Index_cp_letter-W" class="summary-letter"><b>W</b></a>
|
2149
|
+
|
2150
|
+
</td></tr></table>
|
2151
|
+
|
2152
|
+
<hr size="6">
|
2153
|
+
<a name="SEC_Contents"></a>
|
2154
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
2155
|
+
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
2156
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
2157
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
2158
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
2159
|
+
</tr></table>
|
2160
|
+
<h1>Table of Contents</h1>
|
2161
|
+
<div class="contents">
|
2162
|
+
|
2163
|
+
<ul class="toc">
|
2164
|
+
<li><a name="toc-Introduction-1" href="#Introduction">1. Introduction</a></li>
|
2165
|
+
<li><a name="toc-Command-line-invocation" href="#Invoke">2. Command line invocation</a>
|
2166
|
+
<ul class="toc">
|
2167
|
+
<li><a name="toc-Quick-start" href="#Quick-start">2.1 Quick start</a></li>
|
2168
|
+
<li><a name="toc-Option-summary" href="#Option-summary">2.2 Option summary</a></li>
|
2169
|
+
</ul></li>
|
2170
|
+
<li><a name="toc-C-language-support" href="#Clang">3. C language support</a>
|
2171
|
+
<ul class="toc">
|
2172
|
+
<li><a name="toc-ANSI-C" href="#ANSI-C">3.1 ANSI C</a></li>
|
2173
|
+
<li><a name="toc-ISOC99-extensions" href="#ISOC99-extensions">3.2 ISOC99 extensions</a></li>
|
2174
|
+
<li><a name="toc-GNU-C-extensions" href="#GNU-C-extensions">3.3 GNU C extensions</a></li>
|
2175
|
+
<li><a name="toc-TinyCC-extensions" href="#TinyCC-extensions">3.4 TinyCC extensions</a></li>
|
2176
|
+
</ul></li>
|
2177
|
+
<li><a name="toc-TinyCC-Assembler" href="#asm">4. TinyCC Assembler</a>
|
2178
|
+
<ul class="toc">
|
2179
|
+
<li><a name="toc-Syntax" href="#Syntax">4.1 Syntax</a></li>
|
2180
|
+
<li><a name="toc-Expressions" href="#Expressions">4.2 Expressions</a></li>
|
2181
|
+
<li><a name="toc-Labels" href="#Labels">4.3 Labels</a></li>
|
2182
|
+
<li><a name="toc-Directives" href="#Directives">4.4 Directives</a></li>
|
2183
|
+
<li><a name="toc-X86-Assembler" href="#X86-Assembler">4.5 X86 Assembler</a></li>
|
2184
|
+
</ul></li>
|
2185
|
+
<li><a name="toc-TinyCC-Linker" href="#linker">5. TinyCC Linker</a>
|
2186
|
+
<ul class="toc">
|
2187
|
+
<li><a name="toc-ELF-file-generation" href="#ELF-file-generation">5.1 ELF file generation</a></li>
|
2188
|
+
<li><a name="toc-ELF-file-loader" href="#ELF-file-loader">5.2 ELF file loader</a></li>
|
2189
|
+
<li><a name="toc-PE_002di386-file-generation" href="#PE_002di386-file-generation">5.3 PE-i386 file generation</a></li>
|
2190
|
+
<li><a name="toc-GNU-Linker-Scripts" href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></li>
|
2191
|
+
</ul></li>
|
2192
|
+
<li><a name="toc-TinyCC-Memory-and-Bound-checks" href="#Bounds">6. TinyCC Memory and Bound checks</a></li>
|
2193
|
+
<li><a name="toc-The-libtcc-library" href="#Libtcc">7. The <code>libtcc</code> library</a></li>
|
2194
|
+
<li><a name="toc-Developer_0027s-guide" href="#devel">8. Developer’s guide</a>
|
2195
|
+
<ul class="toc">
|
2196
|
+
<li><a name="toc-File-reading" href="#File-reading">8.1 File reading</a></li>
|
2197
|
+
<li><a name="toc-Lexer" href="#Lexer">8.2 Lexer</a></li>
|
2198
|
+
<li><a name="toc-Parser" href="#Parser">8.3 Parser</a></li>
|
2199
|
+
<li><a name="toc-Types" href="#Types">8.4 Types</a></li>
|
2200
|
+
<li><a name="toc-Symbols" href="#Symbols">8.5 Symbols</a></li>
|
2201
|
+
<li><a name="toc-Sections" href="#Sections">8.6 Sections</a></li>
|
2202
|
+
<li><a name="toc-Code-generation" href="#Code-generation">8.7 Code generation</a>
|
2203
|
+
<ul class="toc">
|
2204
|
+
<li><a name="toc-Introduction-2" href="#Introduction-2">8.7.1 Introduction</a></li>
|
2205
|
+
<li><a name="toc-The-value-stack" href="#The-value-stack">8.7.2 The value stack</a></li>
|
2206
|
+
<li><a name="toc-Manipulating-the-value-stack" href="#Manipulating-the-value-stack">8.7.3 Manipulating the value stack</a></li>
|
2207
|
+
<li><a name="toc-CPU-dependent-code-generation" href="#CPU-dependent-code-generation">8.7.4 CPU dependent code generation</a></li>
|
2208
|
+
</ul></li>
|
2209
|
+
<li><a name="toc-Optimizations-done" href="#Optimizations-done">8.8 Optimizations done</a></li>
|
2210
|
+
</ul></li>
|
2211
|
+
<li><a name="toc-Concept-Index" href="#Concept-Index">Concept Index</a></li>
|
2212
|
+
</ul>
|
2213
|
+
</div>
|
2214
|
+
<hr size="1">
|
2215
|
+
<a name="SEC_About"></a>
|
2216
|
+
<table cellpadding="1" cellspacing="1" border="0">
|
2217
|
+
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
|
2218
|
+
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
|
2219
|
+
<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
|
2220
|
+
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
|
2221
|
+
</tr></table>
|
2222
|
+
<h1>About This Document</h1>
|
2223
|
+
<p>
|
2224
|
+
This document was generated by <em>Thomas Preud'homme</em> on <em>February 15, 2013</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
|
2225
|
+
</p>
|
2226
|
+
<p>
|
2227
|
+
The buttons in the navigation panels have the following meaning:
|
2228
|
+
</p>
|
2229
|
+
<table border="1">
|
2230
|
+
<tr>
|
2231
|
+
<th> Button </th>
|
2232
|
+
<th> Name </th>
|
2233
|
+
<th> Go to </th>
|
2234
|
+
<th> From 1.2.3 go to</th>
|
2235
|
+
</tr>
|
2236
|
+
<tr>
|
2237
|
+
<td align="center"> [ < ] </td>
|
2238
|
+
<td align="center">Back</td>
|
2239
|
+
<td>Previous section in reading order</td>
|
2240
|
+
<td>1.2.2</td>
|
2241
|
+
</tr>
|
2242
|
+
<tr>
|
2243
|
+
<td align="center"> [ > ] </td>
|
2244
|
+
<td align="center">Forward</td>
|
2245
|
+
<td>Next section in reading order</td>
|
2246
|
+
<td>1.2.4</td>
|
2247
|
+
</tr>
|
2248
|
+
<tr>
|
2249
|
+
<td align="center"> [ << ] </td>
|
2250
|
+
<td align="center">FastBack</td>
|
2251
|
+
<td>Beginning of this chapter or previous chapter</td>
|
2252
|
+
<td>1</td>
|
2253
|
+
</tr>
|
2254
|
+
<tr>
|
2255
|
+
<td align="center"> [ Up ] </td>
|
2256
|
+
<td align="center">Up</td>
|
2257
|
+
<td>Up section</td>
|
2258
|
+
<td>1.2</td>
|
2259
|
+
</tr>
|
2260
|
+
<tr>
|
2261
|
+
<td align="center"> [ >> ] </td>
|
2262
|
+
<td align="center">FastForward</td>
|
2263
|
+
<td>Next chapter</td>
|
2264
|
+
<td>2</td>
|
2265
|
+
</tr>
|
2266
|
+
<tr>
|
2267
|
+
<td align="center"> [Top] </td>
|
2268
|
+
<td align="center">Top</td>
|
2269
|
+
<td>Cover (top) of document</td>
|
2270
|
+
<td> </td>
|
2271
|
+
</tr>
|
2272
|
+
<tr>
|
2273
|
+
<td align="center"> [Contents] </td>
|
2274
|
+
<td align="center">Contents</td>
|
2275
|
+
<td>Table of contents</td>
|
2276
|
+
<td> </td>
|
2277
|
+
</tr>
|
2278
|
+
<tr>
|
2279
|
+
<td align="center"> [Index] </td>
|
2280
|
+
<td align="center">Index</td>
|
2281
|
+
<td>Index</td>
|
2282
|
+
<td> </td>
|
2283
|
+
</tr>
|
2284
|
+
<tr>
|
2285
|
+
<td align="center"> [ ? ] </td>
|
2286
|
+
<td align="center">About</td>
|
2287
|
+
<td>About (help)</td>
|
2288
|
+
<td> </td>
|
2289
|
+
</tr>
|
2290
|
+
</table>
|
2291
|
+
|
2292
|
+
<p>
|
2293
|
+
where the <strong> Example </strong> assumes that the current position is at <strong> Subsubsection One-Two-Three </strong> of a document of the following structure:
|
2294
|
+
</p>
|
2295
|
+
|
2296
|
+
<ul>
|
2297
|
+
<li> 1. Section One
|
2298
|
+
<ul>
|
2299
|
+
<li>1.1 Subsection One-One
|
2300
|
+
<ul>
|
2301
|
+
<li>...</li>
|
2302
|
+
</ul>
|
2303
|
+
</li>
|
2304
|
+
<li>1.2 Subsection One-Two
|
2305
|
+
<ul>
|
2306
|
+
<li>1.2.1 Subsubsection One-Two-One</li>
|
2307
|
+
<li>1.2.2 Subsubsection One-Two-Two</li>
|
2308
|
+
<li>1.2.3 Subsubsection One-Two-Three
|
2309
|
+
<strong><== Current Position </strong></li>
|
2310
|
+
<li>1.2.4 Subsubsection One-Two-Four</li>
|
2311
|
+
</ul>
|
2312
|
+
</li>
|
2313
|
+
<li>1.3 Subsection One-Three
|
2314
|
+
<ul>
|
2315
|
+
<li>...</li>
|
2316
|
+
</ul>
|
2317
|
+
</li>
|
2318
|
+
<li>1.4 Subsection One-Four</li>
|
2319
|
+
</ul>
|
2320
|
+
</li>
|
2321
|
+
</ul>
|
2322
|
+
|
2323
|
+
<hr size="1">
|
2324
|
+
<p>
|
2325
|
+
<font size="-1">
|
2326
|
+
This document was generated by <em>Thomas Preud'homme</em> on <em>February 15, 2013</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
|
2327
|
+
</font>
|
2328
|
+
<br>
|
2329
|
+
|
2330
|
+
</p>
|
2331
|
+
</body>
|
2332
|
+
</html>
|