Browse Source

Revert all of my changes to directories & codingstyle.

gus knight 4 years ago
parent
commit
89ad24e7d6
52 changed files with 4439 additions and 4462 deletions
  1. 2 2
      .gitignore
  2. 29 28
      CMakeLists.txt
  3. 0 0
      Changelog
  4. 1 5
      docs/CodingStyle.md
  5. 418 5
      Makefile
  6. 0 0
      TODO
  7. 2123 0
      arm-gen.c
  8. 1 1
      src/arm/arm64-gen.c
  9. 58 58
      src/tms320c67/c67-gen.c
  10. 7 7
      src/coff.h
  11. 0 0
      config.h.in
  12. 0 0
      config.texi.in
  13. 5 5
      configure
  14. 0 0
      conftest.c
  15. 0 0
      elf.h
  16. 2 2
      src/x86/i386-asm.c
  17. 5 5
      src/x86/i386-asm.h
  18. 13 13
      src/x86/i386-gen.c
  19. 0 0
      i386-tok.h
  20. 7 7
      src/cil/il-gen.c
  21. 1 1
      src/cil/il-opcodes.h
  22. 8 8
      lib/Makefile
  23. 28 28
      lib/bcheck.c
  24. 13 13
      lib/libtcc1.c
  25. 16 16
      src/libtcc.c
  26. 0 0
      libtcc.h
  27. 0 421
      src/Makefile
  28. 0 2162
      src/arm/arm-gen.c
  29. 0 924
      src/tcccoff.c
  30. 0 0
      stab.def
  31. 0 0
      stab.h
  32. 23 23
      docs/tcc-doc.texi
  33. 1 1
      src/tcc.c
  34. 9 9
      src/tcc.h
  35. 52 52
      src/tccasm.c
  36. 948 0
      tcccoff.c
  37. 156 156
      src/tccelf.c
  38. 283 282
      src/tccgen.c
  39. 3 3
      src/tcclib.h
  40. 25 25
      src/tccpe.c
  41. 40 40
      src/tccpp.c
  42. 9 9
      src/tccrun.c
  43. 2 2
      src/tcctok.h
  44. 5 5
      tests/Makefile
  45. 15 15
      tests/abitest.c
  46. 1 1
      tests/pp/Makefile
  47. 58 58
      tests/tcctest.c
  48. 3 3
      tests/tests2/Makefile
  49. 1 1
      docs/texi2pod.pl
  50. 1 1
      win32/tools/tiny_libmaker.c
  51. 0 0
      x86_64-asm.h
  52. 67 65
      src/x86/x86_64-gen.c

+ 2 - 2
.gitignore

@@ -5,7 +5,7 @@ a.out
 *.log
 tcc_g
 tcc
-/src/*-tcc
+/*-tcc
 tc2.c
 doc
 tc3s.c
@@ -63,7 +63,7 @@ lib/i386-win32
 lib/arm
 lib/arm64
 tcc-doc.info
-conftest*!conftest.c
+conftest*
 tiny_libmaker
 *.dSYM
 *~

+ 29 - 28
CMakeLists.txt

@@ -85,14 +85,14 @@ endif()
 
 file(STRINGS "VERSION" TCC_VERSION)
 list(GET TCC_VERSION 0 TCC_VERSION)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/)
-configure_file(src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h)
-configure_file(docs/config.texi.in ${CMAKE_CURRENT_SOURCE_DIR}/docs/config.texi)
+include_directories(${CMAKE_BINARY_DIR})
+configure_file(config.h.in config.h)
+configure_file(config.texi.in config.texi)
 
 # Utility variables
-set(I386_SOURCES src/x86/i386-gen.c src/x86/i386-asm.c src/x86/i386-asm.h src/x86/i386-tok.h)
-set(X86_64_SOURCES src/x86/x86_64-gen.c src/x86/i386-asm.c src/x86/x86_64-asm.h)
-set(ARM_SOURCES src/arm/arm_gen.c)
+set(I386_SOURCES i386-gen.c i386-asm.c i386-asm.h i386-tok.h)
+set(X86_64_SOURCES x86_64-gen.c i386-asm.c x86_64-asm.h)
+set(ARM_SOURCES arm_gen.c)
 
 set(LIBTCC1_I386_SOURCES lib/alloca86.S lib/alloca86-bt.S)
 set(LIBTCC1_WIN_SOURCES win32/lib/crt1.c win32/lib/wincrt1.c win32/lib/dllcrt1.c win32/lib/dllmain.c win32/lib/chkstk.S)
@@ -154,41 +154,41 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt
     foreach(make_tcc_def ${TCC_NATIVE_DEFINITIONS})
       set(TCC_NATIVE_FLAGS ${TCC_NATIVE_FLAGS} -D${make_tcc_def})
     endforeach()
-
+    
     if (TCC_BUILD_NATIVE)
       add_library(libtcc
-        src/libtcc.c
-        src/tccpp.c
-        src/tccgen.c
-        src/tccelf.c
-        src/tccasm.c
-        src/tccrun.c
-        src/tcc.h
-        src/libtcc.h
-        src/tcctok.h
+        libtcc.c
+        tccpp.c
+        tccgen.c
+        tccelf.c
+        tccasm.c
+        tccrun.c
+        tcc.h
+        libtcc.h
+        tcctok.h
         ${tcc_sources}
       )
       set_target_properties(libtcc PROPERTIES OUTPUT_NAME tcc PREFIX lib)
       if(WIN32)
         set_target_properties(libtcc PROPERTIES LINK_FLAGS "-Wl,--output-def,libtcc.def")
       endif()
-      add_executable(tcc src/tcc.c)
+      add_executable(tcc tcc.c)
       target_link_libraries(tcc libtcc)
       if(NOT WIN32)
         target_link_libraries(tcc dl)
       endif()
       install(TARGETS tcc libtcc RUNTIME DESTINATION ${EXE_PATH} LIBRARY DESTINATION ${NATIVE_LIB_PATH} ARCHIVE DESTINATION ${NATIVE_LIB_PATH})
       set_target_properties(tcc libtcc PROPERTIES COMPILE_DEFINITIONS "${TCC_NATIVE_DEFINITIONS}")
-
+      
       if("${libtcc_sources}" STRGREATER "")
         make_libtcc1("" tcc "${libtcc_ar}" "${TCC_NATIVE_DEFINITIONS}" "${libtcc_includes}" "${libtcc_sources}")
       endif()
     endif()
   elseif(${cross_enabled})
-    add_executable(${cross_name}-tcc src/tcc.c)
+    add_executable(${cross_name}-tcc tcc.c)
     set_target_properties(${cross_name}-tcc PROPERTIES COMPILE_DEFINITIONS "ONE_SOURCE;${definitions}")
     install(TARGETS ${cross_name}-tcc RUNTIME DESTINATION ${EXE_PATH})
-
+    
     if("${libtcc_sources}" STRGREATER "")
       make_libtcc1(${cross_name} "${cross_name}-tcc" "${libtcc_ar}" "${definitions}" "${libtcc_includes}" "${libtcc_sources}")
     endif()
@@ -197,17 +197,17 @@ endmacro()
 
 make_tcc("Win32" i386-w64-mingw32 TCC_BUILD_WIN32
   "TCC_TARGET_I386;TCC_TARGET_PE"
-  "${I386_SOURCES};src/tccpe.c"
+  "${I386_SOURCES};tccpe.c"
   tiny_libmaker_32 "${LIBTCC1_I386_SOURCES};${LIBTCC1_WIN_SOURCES}" "win32/include;win32/include/winapi"
 )
 make_tcc("Win64" x86_64-w64-mingw32 TCC_BUILD_WIN64
   "TCC_TARGET_X86_64;TCC_TARGET_PE"
-  "${X86_64_SOURCES};src/tccpe.c"
+  "${X86_64_SOURCES};tccpe.c"
   tiny_libmaker_64 "lib/alloca86_64.S;${LIBTCC1_WIN_SOURCES}" "win32/include;win32/include/winapi"
 )
 make_tcc("WinCE" arm-wince-mingw32ce TCC_BUILD_WINCE
   "TCC_TARGET_ARM;TCC_ARM_VERSION=${TCC_ARM_VERSION};TCC_TARGET_PE"
-  "${ARM_SOURCES};src/tccpe.c"
+  "${ARM_SOURCES};tccpe.c"
   "" "" ""
 )
 make_tcc("i386" i386-linux-gnu TCC_BUILD_I386
@@ -248,7 +248,7 @@ make_tcc("" arm-linux-gnu TCC_BUILD_ARM_VFP
 )
 make_tcc("" c67 TCC_BUILD_C67
   TCC_TARGET_C67
-  "c67-gen.c;src/tcccoff.c"
+  "c67-gen.c;tcccoff.c"
   "" "" ""
 )
 
@@ -257,14 +257,14 @@ add_subdirectory(tests)
 find_program(MAKEINFO NAMES makeinfo PATHS C:/MinGW/MSYS/1.0/bin)
 if(MAKEINFO)
   add_custom_command(OUTPUT tcc-doc.html
-    COMMAND ${MAKEINFO} --no-split --html -o tcc-doc.html ${CMAKE_CURRENT_SOURCE_DIR}/docs/tcc-doc.texi
-    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/docs/tcc-doc.texi
+    COMMAND ${MAKEINFO} --no-split --html -o tcc-doc.html ${CMAKE_CURRENT_SOURCE_DIR}/tcc-doc.texi
+    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tcc-doc.texi
   )
   set(TCC_DOC_FILES tcc-doc.html)
   if(NOT WIN32)
     add_custom_command(OUTPUT tcc-doc.info
-      COMMAND ${MAKEINFO} -o tcc-doc.info ${CMAKE_CURRENT_SOURCE_DIR}/docs/tcc-doc.texi
-      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/docs/tcc-doc.texi
+      COMMAND ${MAKEINFO} -o tcc-doc.info ${CMAKE_CURRENT_SOURCE_DIR}/tcc-doc.texi
+      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tcc-doc.texi
     )
     set(TCC_DOC_FILES ${TCC_DOC_FILES} tcc-doc.info)
     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tcc-doc.info DESTINATION share/info)
@@ -290,3 +290,4 @@ else()
   install(DIRECTORY win32/include/ DESTINATION lib/tcc/win32/include)
   install(DIRECTORY include/ DESTINATION lib/tcc/win32/include)
 endif()
+

docs/Changelog → Changelog


+ 1 - 5
docs/CodingStyle.md

@@ -1,9 +1,5 @@
-TinyCC Coding Style
-==========================
-Lines should be no more than 80 columns long.
+    Indentation
 
-Indentation
---------------------------------------
 Turn on a "fill tabs with spaces" option in your editor.
 
 Be also careful that some files are indented with 2 spaces (when they

+ 418 - 5
Makefile

@@ -1,8 +1,421 @@
-SRC_DIR = src
+#
+# Tiny C Compiler Makefile
+#
 
-.PHONY: default
-default:
-	$(MAKE) -C $(SRC_DIR)
+TOP ?= .
+include $(TOP)/config.mak
+VPATH = $(top_srcdir)
+
+CPPFLAGS += -I$(TOP) # for config.h
+
+ifneq (-$(findstring gcc,$(CC))-,-gcc-)
+ifeq (-$(findstring clang,$(CC))-,-clang-)
+# make clang accept gnuisms in libtcc1.c
+CFLAGS+=-fheinous-gnu-extensions
+endif
+endif
+
+CPPFLAGS_P=$(CPPFLAGS) -DCONFIG_TCC_STATIC
+CFLAGS_P=$(CFLAGS) -pg -static
+LIBS_P=
+LDFLAGS_P=$(LDFLAGS)
+
+ifdef CONFIG_WIN64
+CONFIG_WIN32=yes
+endif
+
+ifndef CONFIG_WIN32
+LIBS=-lm
+ifndef CONFIG_NOLDL
+LIBS+=-ldl
+endif
+endif
+
+# make libtcc as static or dynamic library?
+ifdef DISABLE_STATIC
+ifndef CONFIG_WIN32
+LIBTCC=libtcc.so.1.0
+else
+LIBTCC=libtcc.dll
+LIBTCC_DLL=yes
+LIBTCC_EXTRA=libtcc.def libtcc.a
+endif
+LINK_LIBTCC=-Wl,-rpath,"$(libdir)"
+ifdef DISABLE_RPATH
+LINK_LIBTCC=
+endif
+else
+LIBTCC=libtcc.a
+LINK_LIBTCC=
+endif
+
+CONFIG_$(ARCH) = yes
+NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
+NATIVE_DEFINES_$(CONFIG_x86-64) += -DTCC_TARGET_X86_64
+NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
+NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
+NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
+NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
+NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
+NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP
+NATIVE_DEFINES_$(CONFIG_arm64) += -DTCC_TARGET_ARM64
+NATIVE_DEFINES += $(NATIVE_DEFINES_yes)
+
+ifeq ($(TOP),.)
+
+PROGS=tcc$(EXESUF)
+I386_CROSS = i386-linux-gnu-tcc$(EXESUF)
+WIN32_CROSS = i386-win-mingw32-tcc$(EXESUF)
+WIN64_CROSS = x86_64-win-mingw32-tcc$(EXESUF)
+WINCE_CROSS = arm-win-mingw32ce-tcc$(EXESUF)
+X64_CROSS = x86_64-linux-gnu-tcc$(EXESUF)
+ARM_FPA_CROSS = arm-linux-fpa-tcc$(EXESUF)
+ARM_FPA_LD_CROSS = arm-linux-fpa-ld-tcc$(EXESUF)
+ARM_VFP_CROSS = arm-linux-gnu-tcc$(EXESUF)
+ARM_EABI_CROSS = arm-linux-gnueabi-tcc$(EXESUF)
+ARM_EABIHF_CROSS = arm-linux-gnueabihf-tcc$(EXESUF)
+ARM_CROSS = $(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS)
+ARM64_CROSS = arm64-tcc$(EXESUF)
+C67_CROSS = c67-tcc$(EXESUF)
+
+# Legacy symlinks for cross compilers
+$(I386_CROSS)_LINK = i386-tcc$(EXESUF)
+$(WIN32_CROSS)_LINK = i386-win-tcc$(EXESUF)
+$(WIN64_CROSS)_LINK = x86_64-win-tcc$(EXESUF)
+$(WINCE_CROSS)_LINK = arm-win-tcc$(EXESUF)
+$(X64_CROSS)_LINK = x86_64-tcc$(EXESUF)
+$(ARM_FPA_CROSS)_LINK = arm-fpa-tcc$(EXESUF)
+$(ARM_FPA_LD_CROSS)_LINK = arm-fpa-ld-tcc$(EXESUF)
+$(ARM_VFP_CROSS)_LINK = arm-vfp-tcc$(EXESUF)
+$(ARM_EABI_CROSS)_LINK = arm-eabi-tcc$(EXESUF)
+
+ifeq ($(TARGETOS),Windows)
+ifeq ($(ARCH),i386)
+PROGS:=$($(WIN32_CROSS)_LINK)
+$($(WIN32_CROSS)_LINK)_TCC = yes
+endif
+ifeq ($(ARCH),x86-64)
+PROGS:=$($(WIN64_CROSS)_LINK)
+$($(WIN64_CROSS)_LINK)_TCC = yes
+endif
+endif
+
+ifeq ($(TARGETOS),Linux)
+ifeq ($(ARCH),i386)
+PROGS:=$($(I386_CROSS)_LINK)
+$($(I386_CROSS)_LINK)_TCC = yes
+endif
+ifeq ($(ARCH),x86-64)
+PROGS:=$($(X64_CROSS)_LINK)
+$($(X64_CROSS)_LINK)_TCC = yes
+endif
+endif
+
+CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c
+CORE_FILES += tcc.h config.h libtcc.h tcctok.h
+I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
+WIN32_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
+WIN64_FILES = $(CORE_FILES) x86_64-gen.c i386-asm.c x86_64-asm.h tccpe.c
+WINCE_FILES = $(CORE_FILES) arm-gen.c tccpe.c
+X86_64_FILES = $(CORE_FILES) x86_64-gen.c i386-asm.c x86_64-asm.h
+ARM_FILES = $(CORE_FILES) arm-gen.c
+ARM64_FILES = $(CORE_FILES) arm64-gen.c
+C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c
+
+ifdef CONFIG_WIN64
+PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
+NATIVE_FILES=$(WIN64_FILES)
+PROGS_CROSS=$(WIN32_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
+LIBTCC1_CROSS=lib/i386-win/libtcc1.a
+LIBTCC1=libtcc1.a
+else ifdef CONFIG_WIN32
+PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
+NATIVE_FILES=$(WIN32_FILES)
+PROGS_CROSS=$(WIN64_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
+LIBTCC1_CROSS=lib/x86_64-win/libtcc1.a
+LIBTCC1=libtcc1.a
+else ifeq ($(ARCH),i386)
+NATIVE_FILES=$(I386_FILES)
+PROGS_CROSS=$($(X64_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
+LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a \
+    lib/arm64/libtcc1.a
+LIBTCC1=libtcc1.a
+else ifeq ($(ARCH),x86-64)
+ifeq ($(TARGETOS),Darwin)
+NATIVE_FILES=$(X86_64_FILES)
+PROGS_CROSS=$($(I386_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(C67_CROSS) $(WINCE_CROSS)
+LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a
+LIBTCC1=libtcc1.a
+else
+NATIVE_FILES=$(X86_64_FILES)
+PROGS_CROSS=$($(I386_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
+LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a \
+    lib/arm64/libtcc1.a
+LIBTCC1=libtcc1.a
+endif
+else ifeq ($(ARCH),arm)
+NATIVE_FILES=$(ARM_FILES)
+PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
+LIBTCC1=libtcc1.a
+LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a
+else ifeq ($(ARCH),arm64)
+NATIVE_FILES=$(ARM64_FILES)
+PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(C67_CROSS) $(WINCE_CROSS)
+LIBTCC1=libtcc1.a
+LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a
+endif
+PROGS_CROSS_LINK=$(foreach PROG_CROSS,$(PROGS_CROSS),$($(PROG_CROSS)_LINK))
+
+ifeq ($(TARGETOS),Darwin)
+PROGS+=tiny_libmaker$(EXESUF)
+endif
+
+TCCLIBS = $(LIBTCC1) $(LIBTCC) $(LIBTCC_EXTRA)
+TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info
+
+ifdef CONFIG_CROSS
+PROGS+=$(PROGS_CROSS)
+TCCLIBS+=$(LIBTCC1_CROSS)
+endif
+
+all: $(PROGS) $(TCCLIBS) $(TCCDOCS)
+
+# Host Tiny C Compiler
+tcc$(EXESUF): tcc.o $(LIBTCC)
+	$(CC) -o $@ $^ $(LIBS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LINK_LIBTCC)
+
+# Cross Tiny C Compilers
+%-tcc$(EXESUF): tcc.c
+	$(CC) -o $@ $< -DONE_SOURCE $(if $($@_TCC),$(NATIVE_DEFINES),$(DEFINES)) $(CPPFLAGS) $(CFLAGS) $(LIBS) $(LDFLAGS)
+	$(if $($@_LINK),ln -sf $@ $($@_LINK))
+	$(if $($@_TCC),ln -sf $@ tcc$(EXESUF))
+
+# profiling version
+tcc_p$(EXESUF): $(NATIVE_FILES)
+	$(CC) -o $@ $< -DONE_SOURCE $(NATIVE_DEFINES) $(CPPFLAGS_P) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
+
+$(I386_CROSS) $($(I386_CROSS)_LINK): DEFINES = -DTCC_TARGET_I386
+$(X64_CROSS) $($(X64_CROSS)_LINK): DEFINES = -DTCC_TARGET_X86_64
+$(WIN32_CROSS) $($(WIN32_CROSS)_LINK): DEFINES = -DTCC_TARGET_I386 -DTCC_TARGET_PE \
+    -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \
+    -DCONFIG_TCC_LIBPATHS="\"{B}/lib/32;{B}/lib\""
+$(WIN64_CROSS) $($(WIN64_CROSS)_LINK): DEFINES = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE \
+    -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \
+    -DCONFIG_TCC_LIBPATHS="\"{B}/lib/64;{B}/lib\""
+$(WINCE_CROSS): DEFINES = -DTCC_TARGET_PE
+$(C67_CROSS): DEFINES = -DTCC_TARGET_C67
+$(ARM_FPA_CROSS): DEFINES = -DTCC_TARGET_ARM
+$(ARM_FPA_LD_CROSS)$(EXESUF): DEFINES = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12
+$(ARM_VFP_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_VFP
+$(ARM_EABI_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_VFP
+$(ARM64_CROSS): DEFINES = -DTCC_TARGET_ARM64
+
+$(I386_CROSS) $($(I386_CROSS)_LINK): $(I386_FILES)
+$(X64_CROSS)  $($(X64_CROSS)_LINK): $(X86_64_FILES)
+$(WIN32_CROSS) $($(WIN32_CROSS)_LINK): $(WIN32_FILES)
+$(WIN64_CROSS) $($(WIN64_CROSS)_LINK): $(WIN64_FILES)
+$(WINCE_CROSS) $($(WINCE_CROSS)_LINK): $(WINCE_FILES)
+$(C67_CROSS)  $($(C67_CROSS)_LINK): $(C67_FILES)
+$(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS): $(ARM_FILES)
+$($(ARM_FPA_CROSS)_LINK) $($(ARM_FPA_LD_CROSS)_LINK) $($(ARM_VFP_CROSS)_LINK) $($(ARM_EABI_CROSS)_LINK): $(ARM_FILES)
+$(ARM64_CROSS): $(ARM64_FILES)
+
+# libtcc generation and test
+ifndef ONE_SOURCE
+LIBTCC_OBJ = $(filter-out tcc.o,$(patsubst %.c,%.o,$(filter %.c,$(NATIVE_FILES))))
+LIBTCC_INC = $(filter %.h,$(CORE_FILES)) $(filter-out $(CORE_FILES),$(NATIVE_FILES))
+else
+LIBTCC_OBJ = libtcc.o
+LIBTCC_INC = $(NATIVE_FILES)
+libtcc.o : NATIVE_DEFINES += -DONE_SOURCE
+endif
+
+$(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC)
+	$(CC) -o $@ -c $< $(NATIVE_DEFINES) $(CPPFLAGS) $(CFLAGS)
+
+ifndef LIBTCC_DLL
+libtcc.a: $(LIBTCC_OBJ)
+	$(AR) rcs $@ $^
+endif
+
+libtcc.so.1.0: $(LIBTCC_OBJ)
+	$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
+
+libtcc.so.1.0: CFLAGS+=-fPIC
+
+ifdef LIBTCC_DLL
+libtcc.dll libtcc.def libtcc.a: $(LIBTCC_OBJ)
+	$(CC) -shared $^ -o $@ $(LDFLAGS) -Wl,--output-def,libtcc.def,--out-implib,libtcc.a
+endif
+
+# windows utilities
+tiny_impdef$(EXESUF): win32/tools/tiny_impdef.c
+	$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
+tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c
+	$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
+
+# TinyCC runtime libraries
+libtcc1.a : FORCE
+	$(MAKE) -C lib native
+	if test ! -d $(ARCH); then mkdir $(ARCH); fi
+	if test ! -L $(ARCH)/$@; then ln -sf ../$@ $(ARCH)/$@; fi
+lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
+	$(MAKE) -C lib cross TARGET=$*
+
+FORCE:
+
+# install
+TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h
+INSTALL=install
+ifdef STRIP_BINARIES
+INSTALLBIN=$(INSTALL) -s
+else
+INSTALLBIN=$(INSTALL)
+endif
+
+install-strip: install
+	strip $(foreach PROG,$(PROGS),"$(bindir)"/$(PROG))
+
+ifndef CONFIG_WIN32
+install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
+	mkdir -p "$(bindir)"
+	$(INSTALLBIN) -m755 $(PROGS) "$(bindir)"
+	cp -P tcc$(EXESUF) "$(bindir)"
+	mkdir -p "$(mandir)/man1"
+	-$(INSTALL) -m644 tcc.1 "$(mandir)/man1"
+	mkdir -p "$(infodir)"
+	-$(INSTALL) -m644 tcc-doc.info "$(infodir)"
+	mkdir -p "$(tccdir)"
+	mkdir -p "$(tccdir)/include"
+ifneq ($(LIBTCC1),)
+	mkdir -p "$(tccdir)/$(ARCH)"
+	$(INSTALL) -m644 $(LIBTCC1) "$(tccdir)/$(ARCH)"
+endif
+	$(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include"
+	mkdir -p "$(libdir)"
+	$(INSTALL) -m644 $(LIBTCC) "$(libdir)"
+ifdef DISABLE_STATIC
+	ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so.1"
+	ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so"
+endif
+	mkdir -p "$(includedir)"
+	$(INSTALL) -m644 $(top_srcdir)/libtcc.h "$(includedir)"
+	mkdir -p "$(docdir)"
+	-$(INSTALL) -m644 tcc-doc.html "$(docdir)"
+ifdef CONFIG_CROSS
+	mkdir -p "$(tccdir)/win32/lib/32"
+	mkdir -p "$(tccdir)/win32/lib/64"
+	mkdir -p "$(tccdir)/i386"
+	mkdir -p "$(tccdir)/x86-64"
+ifneq ($(HOST_OS),Darwin)
+	mkdir -p "$(tccdir)/arm64"
+	$(INSTALL) -m644 lib/arm64/libtcc1.a "$(tccdir)/arm64"
+endif
+	$(INSTALL) -m644 lib/i386/libtcc1.a "$(tccdir)/i386"
+	$(INSTALL) -m644 lib/x86_64/libtcc1.a "$(tccdir)/x86-64"
+	$(INSTALL) -m644 $(top_srcdir)/win32/lib/*.def "$(tccdir)/win32/lib"
+	$(INSTALL) -m644 lib/i386-win/libtcc1.a "$(tccdir)/win32/lib/32"
+	$(INSTALL) -m644 lib/x86_64-win/libtcc1.a "$(tccdir)/win32/lib/64"
+	cp -r $(top_srcdir)/win32/include/. "$(tccdir)/win32/include"
+	cp -r "$(tccdir)/include" "$(tccdir)/win32"
+endif
+
+uninstall:
+	rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
+	rm -fv "$(bindir)/tcc$(EXESUF)"
+	rm -fv $(foreach P,$(LIBTCC1),"$(tccdir)/$P")
+	rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P")
+	rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
+	rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
+	rm -fv "$(libdir)/libtcc.so*"
+	rm -rv "$(tccdir)"
+	rm -rv "$(docdir)"
+else
+# on windows
+install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
+	mkdir -p "$(tccdir)"
+	mkdir -p "$(tccdir)/lib"
+	mkdir -p "$(tccdir)/include"
+	mkdir -p "$(tccdir)/examples"
+	mkdir -p "$(tccdir)/doc"
+	mkdir -p "$(tccdir)/libtcc"
+	$(INSTALLBIN) -m755 $(PROGS) "$(tccdir)"
+	$(INSTALLBIN) -m755 tcc.exe "$(tccdir)"
+	$(INSTALL) -m644 $(LIBTCC1) $(top_srcdir)/win32/lib/*.def "$(tccdir)/lib"
+	cp -r $(top_srcdir)/win32/include/. "$(tccdir)/include"
+	cp -r $(top_srcdir)/win32/examples/. "$(tccdir)/examples"
+	$(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include"
+	$(INSTALL) -m644 tcc-doc.html $(top_srcdir)/win32/tcc-win32.txt "$(tccdir)/doc"
+	$(INSTALL) -m644 $(top_srcdir)/libtcc.h $(LIBTCC_EXTRA) "$(tccdir)/libtcc"
+	$(INSTALL) -m644 $(LIBTCC) "$(tccdir)"
+ifdef CONFIG_CROSS
+	mkdir -p "$(tccdir)/lib/32"
+	mkdir -p "$(tccdir)/lib/64"
+	-$(INSTALL) -m644 lib/i386-win/libtcc1.a "$(tccdir)/lib/32"
+	-$(INSTALL) -m644 lib/x86_64-win/libtcc1.a "$(tccdir)/lib/64"
+endif
+
+uninstall:
+	rm -rfv "$(tccdir)/*"
+endif
+
+# documentation and man page
+tcc-doc.html: tcc-doc.texi
+	-makeinfo --no-split --html --number-sections -o $@ $<
+
+tcc.1: tcc-doc.texi
+	-$(top_srcdir)/texi2pod.pl $< tcc.pod
+	-pod2man --section=1 --center="Tiny C Compiler" --release=`cat $(top_srcdir)/VERSION` tcc.pod > $@
+
+tcc-doc.info: tcc-doc.texi
+	-makeinfo $<
+
+# in tests subdir
+export LIBTCC1
+
+%est:
+	$(MAKE) -C tests $@ 'PROGS_CROSS=$(PROGS_CROSS)'
 
 clean:
-	$(MAKE) -C $(SRC_DIR) clean
+	rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.log \
+		*.exe a.out tags TAGS libtcc_test$(EXESUF) tcc$(EXESUF)
+	-rm -r $(ARCH) arm64
+ifeq ($(HOST_OS),Linux)
+	-rm -r ./C:
+endif
+	-rm *-tcc$(EXESUF)
+	$(MAKE) -C tests $@
+ifneq ($(LIBTCC1),)
+	$(MAKE) -C lib $@
+endif
+
+distclean: clean
+	rm -vf config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
+
+config.mak:
+	@echo "Please run ./configure."
+	@exit 1
+
+tags:
+	ctags $(top_srcdir)/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[chS]
+
+TAGS:
+	ctags -e $(top_srcdir)/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[chS]
+
+# create release tarball from *current* git branch (including tcc-doc.html
+# and converting two files to CRLF)
+TCC-VERSION := tcc-$(shell cat $(top_srcdir)/VERSION)
+tar:    tcc-doc.html
+	mkdir $(TCC-VERSION)
+	( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )
+	cp tcc-doc.html $(TCC-VERSION)
+	for f in tcc-win32.txt build-tcc.bat ; do \
+	    cat win32/$$f | sed 's,\(.*\),\1\r,g' > $(TCC-VERSION)/win32/$$f ; \
+	done
+	tar cjf $(TCC-VERSION).tar.bz2 $(TCC-VERSION)
+	rm -rf $(TCC-VERSION)
+	git reset
+
+.PHONY: all clean tar tags TAGS distclean install uninstall FORCE
+
+endif # ifeq ($(TOP),.)

docs/TODO → TODO


File diff suppressed because it is too large
+ 2123 - 0
arm-gen.c


+ 1 - 1
src/arm/arm64-gen.c

@@ -58,7 +58,7 @@ typedef int RegArgs;
 /******************************************************/
 #else /* ! TARGET_DEFS_ONLY */
 /******************************************************/
-#include "../tcc.h"
+#include "tcc.h"
 #include <assert.h>
 
 ST_DATA const int reg_classes[NB_REGS] = {

+ 58 - 58
src/tms320c67/c67-gen.c

@@ -1,6 +1,6 @@
 /*
  *  TMS320C67xx code generator for TCC
- *
+ * 
  *  Copyright (c) 2001, 2002 Fabrice Bellard
  *
  * This library is free software; you can redistribute it and/or
@@ -127,10 +127,10 @@ enum {
 /******************************************************/
 #else /* ! TARGET_DEFS_ONLY */
 /******************************************************/
-#include "../tcc.h"
+#include "tcc.h"
 
 ST_DATA const int reg_classes[NB_REGS] = {
-    /* eax */ RC_INT | RC_FLOAT | RC_EAX,
+    /* eax */ RC_INT | RC_FLOAT | RC_EAX, 
     // only allow even regs for floats (allow for doubles)
     /* ecx */ RC_INT | RC_ECX,
     /* edx */ RC_INT | RC_INT_BSIDE | RC_FLOAT | RC_EDX,
@@ -161,7 +161,7 @@ ST_DATA const int reg_classes[NB_REGS] = {
 // although tcc thinks it is passing parameters on the stack,
 // the C67 really passes up to the first 10 params in special
 // regs or regs pairs (for 64 bit params).  So keep track of
-// the stack offsets so we can translate to the appropriate
+// the stack offsets so we can translate to the appropriate 
 // reg (pair)
 
 #define NoCallArgsPassedOnStack 10
@@ -204,7 +204,7 @@ void C67_g(int c)
 #endif
     ind1 = ind + 4;
     if (ind1 > (int) cur_text_section->data_allocated)
-        section_realloc(cur_text_section, ind1);
+	section_realloc(cur_text_section, ind1);
     cur_text_section->data[ind] = c & 0xff;
     cur_text_section->data[ind + 1] = (c >> 8) & 0xff;
     cur_text_section->data[ind + 2] = (c >> 16) & 0xff;
@@ -218,26 +218,26 @@ void gsym_addr(int t, int a)
 {
     int n, *ptr;
     while (t) {
-        ptr = (int *) (cur_text_section->data + t);
-        {
-            Sym *sym;
+	ptr = (int *) (cur_text_section->data + t);
+	{
+	    Sym *sym;
 
-            // extract 32 bit address from MVKH/MVKL
-            n = ((*ptr >> 7) & 0xffff);
-            n |= ((*(ptr + 1) >> 7) & 0xffff) << 16;
+	    // extract 32 bit address from MVKH/MVKL
+	    n = ((*ptr >> 7) & 0xffff);
+	    n |= ((*(ptr + 1) >> 7) & 0xffff) << 16;
 
-            // define a label that will be relocated
+	    // define a label that will be relocated
 
-            sym = get_sym_ref(&char_pointer_type, cur_text_section, a, 0);
-            greloc(cur_text_section, sym, t, R_C60LO16);
-            greloc(cur_text_section, sym, t + 4, R_C60HI16);
+	    sym = get_sym_ref(&char_pointer_type, cur_text_section, a, 0);
+	    greloc(cur_text_section, sym, t, R_C60LO16);
+	    greloc(cur_text_section, sym, t + 4, R_C60HI16);
 
-            // clear out where the pointer was
+	    // clear out where the pointer was
 
-            *ptr &= ~(0xffff << 7);
-            *(ptr + 1) &= ~(0xffff << 7);
-        }
-        t = n;
+	    *ptr &= ~(0xffff << 7);
+	    *(ptr + 1) &= ~(0xffff << 7);
+	}
+	t = n;
     }
 }
 
@@ -246,7 +246,7 @@ void gsym(int t)
     gsym_addr(t, ind);
 }
 
-// these are regs that tcc doesn't really know about,
+// these are regs that tcc doesn't really know about, 
 // but assign them unique values so the mapping routines
 // can distinguish them
 
@@ -298,7 +298,7 @@ int C67_map_regn(int r)
     return 0;
 }
 
-// mapping from tcc reg number to
+// mapping from tcc reg number to 
 // C67 register to condition code field
 //
 // valid condition code regs are:
@@ -343,15 +343,15 @@ int C67_map_regs(int r)
     else if (r >= TREG_C67_A4 && r <= TREG_C67_B13)	// these form a pattern of alt pairs
 	return (r & 2) >> 1;
     else if (r == C67_A0)
-	return 0;		// set to A side
+	return 0;		// set to A side 
     else if (r == C67_B2)
-	return 1;		// set to B side
+	return 1;		// set to B side 
     else if (r == C67_B3)
 	return 1;		// set to B side
     else if (r == C67_SP)
-	return 0x1;		// set to SP (B15) B side
+	return 0x1;		// set to SP (B15) B side 
     else if (r == C67_FP)
-	return 0x0;		// set to FP (A15) A side
+	return 0x0;		// set to FP (A15) A side 
     else
 	ALWAYS_ASSERT(FALSE);
 
@@ -420,7 +420,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (0 << 7) |	//y D1/D2 A side
-	      (3 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (3 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(a) << 1) |	//side of src
 	      (0 << 0));	//parallel
@@ -442,7 +442,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (0 << 7) |	//y D1/D2 A side
-	      (3 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (3 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(a) << 1) |	//side of src
 	      (0 << 0));	//parallel
@@ -464,7 +464,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (0 << 7) |	//y D1/D2 A side
-	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(a) << 1) |	//side of src
 	      (0 << 0));	//parallel
@@ -475,7 +475,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (1 << 9) |	//mode 1 = pos cst offset
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (C67_map_regs(b) << 7) |	//y D1/D2 base reg side
-	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(a) << 1) |	//side of src
 	      (0 << 0));	//parallel
@@ -486,7 +486,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (1 << 9) |	//mode 1 = pos cst offset
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (C67_map_regs(b) << 7) |	//y D1/D2 base reg side
-	      (5 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (5 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(a) << 1) |	//side of src
 	      (0 << 0));	//parallel
@@ -497,7 +497,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (1 << 9) |	//mode 1 = pos cst offset
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (C67_map_regs(b) << 7) |	//y D1/D2 base reg side
-	      (3 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (3 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(a) << 1) |	//side of src
 	      (0 << 0));	//parallel
@@ -509,7 +509,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (1 << 9) |	//mode 1 = pos cst offset
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (C67_map_regs(b) << 7) |	//y D1/D2 base reg side
-	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(a) << 1) |	//side of src
 	      (0 << 0));	//parallel
@@ -641,7 +641,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (1 << 9) |	//mode 1 = pos cst offset
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
-	      (2 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (2 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(b) << 1) |	//side of dst
 	      (0 << 0));	//parallel
@@ -652,7 +652,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (1 << 9) |	//mode 1 = pos cst offset
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
-	      (0 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (0 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(b) << 1) |	//side of dst
 	      (0 << 0));	//parallel
@@ -674,7 +674,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (1 << 9) |	//mode 1 = pos cst offset
 	      (0 << 8) |	//r (LDDW bit 0)
 	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
-	      (6 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (6 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
 	      (1 << 2) |	//opcode
 	      (C67_map_regs(b) << 1) |	//side of dst
 	      (0 << 0));	//parallel
@@ -877,7 +877,7 @@ void C67_asm(char *s, int a, int b, int c)
 	C67_g((0 << 29) |	//creg
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
-	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(b) << 18) |	//src2   
 	      (0 << 13) |	//src1 NA
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x4a << 5) |	//opcode
@@ -890,7 +890,7 @@ void C67_asm(char *s, int a, int b, int c)
 	C67_g((0 << 29) |	//creg
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
-	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(b) << 18) |	//src2  
 	      (0 << 13) |	//src1 NA
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x49 << 5) |	//opcode
@@ -903,7 +903,7 @@ void C67_asm(char *s, int a, int b, int c)
 	C67_g((0 << 29) |	//creg
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
-	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(b) << 18) |	//src2  
 	      (0 << 13) |	//src1 NA
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x39 << 5) |	//opcode
@@ -958,7 +958,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x3 << 5) |	//opcode
 	      (0x6 << 2) |	//opcode fixed
@@ -973,7 +973,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x7 << 5) |	//opcode
 	      (0x6 << 2) |	//opcode fixed
@@ -988,7 +988,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x7f << 5) |	//opcode
 	      (0x6 << 2) |	//opcode fixed
@@ -1003,7 +1003,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x7b << 5) |	//opcode
 	      (0x6 << 2) |	//opcode fixed
@@ -1018,7 +1018,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x6f << 5) |	//opcode
 	      (0x6 << 2) |	//opcode fixed
@@ -1033,7 +1033,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x10 << 5) |	//opcode
 	      (0x6 << 2) |	//opcode fixed
@@ -1048,7 +1048,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x18 << 5) |	//opcode
 	      (0x6 << 2) |	//opcode fixed
@@ -1063,7 +1063,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x11 << 5) |	//opcode
 	      (0x6 << 2) |	//opcode fixed
@@ -1078,7 +1078,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x19 << 5) |	//opcode
 	      (0x6 << 2) |	//opcode fixed
@@ -1093,7 +1093,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x1c << 7) |	//opcode
 	      (0x0 << 2) |	//opcode fixed
@@ -1108,7 +1108,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x0e << 7) |	//opcode
 	      (0x0 << 2) |	//opcode fixed
@@ -1138,7 +1138,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x37 << 6) |	//opcode
 	      (0x8 << 2) |	//opcode fixed
@@ -1153,7 +1153,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x27 << 6) |	//opcode
 	      (0x8 << 2) |	//opcode fixed
@@ -1168,7 +1168,7 @@ void C67_asm(char *s, int a, int b, int c)
 	      (0 << 28) |	//inv
 	      (C67_map_regn(c) << 23) |	//dst
 	      (C67_map_regn(b) << 18) |	//src2
-	      (C67_map_regn(a) << 13) |	//src1
+	      (C67_map_regn(a) << 13) |	//src1 
 	      (xpath << 12) |	//x cross path if opposite sides
 	      (0x33 << 6) |	//opcode
 	      (0x8 << 2) |	//opcode fixed
@@ -1597,7 +1597,7 @@ void load(int r, SValue * sv)
 	    size = 4;
 	}
 
-	// check if fc is a positive reference on the stack,
+	// check if fc is a positive reference on the stack, 
 	// if it is tcc is referencing what it thinks is a parameter
 	// on the stack, so check if it is really in a register.
 
@@ -1962,7 +1962,7 @@ void gfunc_call(int nb_args)
 // ending with B12:B13.
 //
 // When a call is made, if the caller has its parameters
-// in regs A4-B13 these must be saved before/as the call
+// in regs A4-B13 these must be saved before/as the call 
 // parameters are loaded and restored upon return (or if/when needed).
 
 /* generate function prolog of type 't' */
@@ -2033,7 +2033,7 @@ void gfunc_prolog(CType * func_type)
 
     TotalBytesPushedOnStack = -loc;
 
-    func_sub_sp_offset = ind;	// remember where we put the stack instruction
+    func_sub_sp_offset = ind;	// remember where we put the stack instruction 
     C67_ADDK(0, C67_SP);	//  ADDK.L2 loc,SP  (just put zero temporarily)
 
     C67_PUSH(C67_A0);
@@ -2049,11 +2049,11 @@ void gfunc_epilog(void)
 	C67_NOP(4);		// NOP wait for load
 	C67_IREG_B_REG(0, C67_CREG_ZERO, C67_B3);	//  B.S2  B3
 	C67_POP(C67_FP);
-	C67_ADDK(local, C67_SP);	//  ADDK.L2 loc,SP
+	C67_ADDK(local, C67_SP);	//  ADDK.L2 loc,SP  
 	C67_Adjust_ADDK((int *) (cur_text_section->data +
 				 func_sub_sp_offset),
 			-local + TotalBytesPushedOnStack);
-	C67_NOP(3);		// NOP
+	C67_NOP(3);		// NOP 
     }
 }
 

+ 7 - 7
src/coff.h

@@ -31,9 +31,9 @@ struct filehdr {
 #define  F_LITTLE   0x100      /* byte ordering of an AR32WR (vax)         */
 #define  F_BIG      0x200      /* byte ordering of an AR32W (3B, maxi)     */
 #define  F_PATCH    0x400      /* contains "patch" list in optional header */
-#define  F_NODF     0x400
+#define  F_NODF     0x400   
 
-#define F_VERSION    (F_GSP10  | F_GSP20)
+#define F_VERSION    (F_GSP10  | F_GSP20)   
 #define F_BYTE_ORDER (F_LITTLE | F_BIG)
 #define FILHDR  struct filehdr
 
@@ -68,7 +68,7 @@ typedef struct aouthdr {
 
 /*----------------------------------------------------------------------*/
 /*      When a UNIX aout header is to be built in the optional header,  */
-/*      the following magic numbers can appear in that header:          */
+/*      the following magic numbers can appear in that header:          */ 
 /*                                                                      */
 /*              AOUT1MAGIC : default : readonly sharable text segment   */
 /*              AOUT2MAGIC:          : writable text segment            */
@@ -164,7 +164,7 @@ struct scnhdr {
 #define STYP_NOLOAD 0x02  /* "noload"  : allocated, relocated, not loaded */
 #define STYP_GROUP  0x04  /* "grouped" : formed of input sections */
 #define STYP_PAD    0x08  /* "padding" : not allocated, not relocated, loaded */
-#define STYP_COPY   0x10  /* "copy"    : used for C init tables -
+#define STYP_COPY   0x10  /* "copy"    : used for C init tables - 
                                                 not allocated, relocated,
                                                 loaded;  reloc & lineno
                                                 entries processed normally */
@@ -358,11 +358,11 @@ struct syment
 #define  N_BTSHFT_COFF     4
 #define  N_TSHIFT_COFF     2
 
-#define  BTYPE_COFF(x)  ((x) & N_BTMASK_COFF)
+#define  BTYPE_COFF(x)  ((x) & N_BTMASK_COFF)  
 #define  ISINT(x)  (((x) >= T_CHAR && (x) <= T_LONG) ||   \
 		    ((x) >= T_UCHAR && (x) <= T_ULONG) || (x) == T_ENUM)
 #define  ISFLT_COFF(x)  ((x) == T_DOUBLE || (x) == T_FLOAT)
-#define  ISPTR_COFF(x)  (((x) & N_TMASK_COFF) == (DT_PTR << N_BTSHFT_COFF))
+#define  ISPTR_COFF(x)  (((x) & N_TMASK_COFF) == (DT_PTR << N_BTSHFT_COFF)) 
 #define  ISFCN_COFF(x)  (((x) & N_TMASK_COFF) == (DT_FCN << N_BTSHFT_COFF))
 #define  ISARY_COFF(x)  (((x) & N_TMASK_COFF) == (DT_ARY << N_BTSHFT_COFF))
 #define  ISTAG_COFF(x)  ((x)==C_STRTAG || (x)==C_UNTAG || (x)==C_ENTAG)
@@ -370,7 +370,7 @@ struct syment
 #define  INCREF_COFF(x) ((((x)&~N_BTMASK_COFF)<<N_TSHIFT_COFF)|(DT_PTR<<N_BTSHFT_COFF)|(x&N_BTMASK_COFF))
 #define  DECREF_COFF(x) ((((x)>>N_TSHIFT_COFF)&~N_BTMASK_COFF)|((x)&N_BTMASK_COFF))
 
-
+
 /*------------------------------------------------------------------------*/
 /*  AUXILIARY SYMBOL ENTRY                                                */
 /*------------------------------------------------------------------------*/

src/config.h.in → config.h.in


docs/config.texi.in → config.texi.in


+ 5 - 5
configure

@@ -66,7 +66,7 @@ case $targetos in
 esac
 
 # find source path
-# XXX: we assume an absolute path is given when launching configure,
+# XXX: we assume an absolute path is given when launching configure, 
 # except in './configure' case.
 source_path=${0%configure}
 source_path=${source_path%/}
@@ -337,7 +337,7 @@ strip="${cross_prefix}${strip}"
 CONFTEST=./conftest$EXESUF
 
 if test -z "$cross_prefix" ; then
-  if ! $cc -o $CONFTEST $source_path/src/conftest.c 2>/dev/null ; then
+  if ! $cc -o $CONFTEST $source_path/conftest.c 2>/dev/null ; then
     echo "configure: error: '$cc' failed to compile conftest.c."
   else
     bigendian="$($CONFTEST bigendian)"
@@ -560,7 +560,7 @@ fi
 version=`head $source_path/VERSION`
 echo "VERSION=$version" >>config.mak
 echo "#define TCC_VERSION \"$version\"" >> $TMPH
-echo "@set VERSION $version" >docs/config.texi
+echo "@set VERSION $version" > config.texi
 echo "SRC_PATH=$source_path" >>config.mak
 
 if test "$source_path_used" = "yes" ; then
@@ -573,9 +573,9 @@ else
 fi
 echo 'top_builddir=$(TOP)' >>config.mak
 
-diff $TMPH src/config.h >/dev/null 2>&1
+diff $TMPH config.h >/dev/null 2>&1
 if test $? -ne 0 ; then
-    mv -f $TMPH src/config.h
+    mv -f $TMPH config.h
 else
     echo "config.h is unchanged"
 fi

src/conftest.c → conftest.c


src/elf.h → elf.h


+ 2 - 2
src/x86/i386-asm.c

@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "../tcc.h"
+#include "tcc.h"
 
 /* #define NB_ASM_REGS 8 */
 #define MAX_OPERANDS 3
@@ -712,7 +712,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
                     a32 = addr32 = 1;
             }
 #endif
-            if (b & 0xff00)
+            if (b & 0xff00) 
                 g(b >> 8);
             g(b);
             return;

+ 5 - 5
src/x86/i386-asm.h

@@ -57,7 +57,7 @@ ALT(DEF_ASM_OP0L(stosb, 0xaa, 0, OPC_BWL))
 ALT(DEF_ASM_OP0L(sstob, 0xaa, 0, OPC_BWL))
 
      /* bits */
-
+     
 ALT(DEF_ASM_OP2(bsfw, 0x0fbc, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA, OPT_REGW))
 ALT(DEF_ASM_OP2(bsrw, 0x0fbd, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA, OPT_REGW))
 
@@ -91,7 +91,7 @@ ALT(DEF_ASM_OP2(btcw, 0x0fba, 7, OPC_MODRM | OPC_WL, OPT_IM8, OPT_REGW | OPT_EA)
      DEF_ASM_OP0(repz, 0xf3)
      DEF_ASM_OP0(repne, 0xf2)
      DEF_ASM_OP0(repnz, 0xf2)
-
+             
      DEF_ASM_OP0(invd, 0x0f08)
      DEF_ASM_OP0(wbinvd, 0x0f09)
      DEF_ASM_OP0(cpuid, 0x0fa2)
@@ -236,7 +236,7 @@ ALT(DEF_ASM_OP1(jo, 0x70, 0, OPC_SHORTJMP | OPC_JMP | OPC_TEST, OPT_ADDR))
     DEF_ASM_OP1(loopz, 0xe1, 0, OPC_SHORTJMP, OPT_ADDR)
     DEF_ASM_OP1(loop, 0xe2, 0, OPC_SHORTJMP, OPT_ADDR)
     DEF_ASM_OP1(jecxz, 0xe3, 0, OPC_SHORTJMP, OPT_ADDR)
-
+     
      /* float */
      /* specific fcomp handling */
 ALT(DEF_ASM_OP0L(fcomp, 0xd8d9, 0, 0))
@@ -298,7 +298,7 @@ ALT(DEF_ASM_OP1(fldl, 0xdd, 0, OPC_MODRM, OPT_EA))
     DEF_ASM_OP1(fildll, 0xdf, 5, OPC_MODRM,OPT_EA)
     DEF_ASM_OP1(fldt, 0xdb, 5, OPC_MODRM, OPT_EA)
     DEF_ASM_OP1(fbld, 0xdf, 4, OPC_MODRM, OPT_EA)
-
+    
     /* fp store */
     DEF_ASM_OP1(fst, 0xddd0, 0, OPC_REG, OPT_ST)
     DEF_ASM_OP1(fstl, 0xddd0, 0, OPC_REG, OPT_ST)
@@ -380,7 +380,7 @@ ALT(DEF_ASM_OP2(cmpxchgb, 0x0fb0, 0, OPC_MODRM | OPC_BWL, OPT_REG, OPT_REG | OPT
 
     /* pentium */
     DEF_ASM_OP1(cmpxchg8b, 0x0fc7, 1, OPC_MODRM, OPT_EA )
-
+    
     /* pentium pro */
     ALT(DEF_ASM_OP2(cmovo, 0x0f40, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
 #ifdef I386_ASM_16

+ 13 - 13
src/x86/i386-gen.c

@@ -1,6 +1,6 @@
 /*
  *  X86 code generator for TCC
- *
+ * 
  *  Copyright (c) 2001-2004 Fabrice Bellard
  *
  * This library is free software; you can redistribute it and/or
@@ -32,7 +32,7 @@ typedef int RegArgs;
 #define RC_INT     0x0001 /* generic integer register */
 #define RC_FLOAT   0x0002 /* generic float register */
 #define RC_EAX     0x0004
-#define RC_ST0     0x0008
+#define RC_ST0     0x0008 
 #define RC_ECX     0x0010
 #define RC_EDX     0x0020
 #define RC_IRET    RC_EAX /* function return: integer register */
@@ -89,7 +89,7 @@ enum {
 /******************************************************/
 #else /* ! TARGET_DEFS_ONLY */
 /******************************************************/
-#include "../tcc.h"
+#include "tcc.h"
 
 ST_DATA const int reg_classes[NB_REGS] = {
     /* eax */ RC_INT | RC_EAX,
@@ -357,11 +357,11 @@ static void gcall_or_jmp(int is_jmp)
         /* constant case */
         if (vtop->r & VT_SYM) {
             /* relocation case */
-            greloc(cur_text_section, vtop->sym,
+            greloc(cur_text_section, vtop->sym, 
                    ind + 1, R_386_PC32);
         } else {
             /* put an empty PC32 relocation */
-            put_elf_reloc(symtab_section, cur_text_section,
+            put_elf_reloc(symtab_section, cur_text_section, 
                           ind + 1, R_386_PC32, 0);
         }
         oad(0xe8 + is_jmp, vtop->c.ul - 4); /* call/jmp im */
@@ -417,7 +417,7 @@ ST_FUNC void gfunc_call(int nb_args)
 {
     int size, align, r, args_size, i, func_call;
     Sym *func_sym;
-
+    
     args_size = 0;
     for(i = 0;i < nb_args; i++) {
         if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
@@ -610,7 +610,7 @@ ST_FUNC void gfunc_epilog(void)
         /* generate bound local allocation */
         saved_ind = ind;
         ind = func_sub_sp_offset;
-        sym_data = get_sym_ref(&char_pointer_type, lbounds_section,
+        sym_data = get_sym_ref(&char_pointer_type, lbounds_section, 
                                func_bound_offset, lbounds_section->data_offset);
         greloc(cur_text_section, sym_data,
                ind + 1, R_386_32);
@@ -637,8 +637,8 @@ ST_FUNC void gfunc_epilog(void)
         g(func_ret_sub >> 8);
     }
     /* align local size to word & save local variables */
-
-    v = (-loc + 3) & -4;
+    
+    v = (-loc + 3) & -4; 
     saved_ind = ind;
     ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
 #ifdef TCC_TARGET_PE
@@ -741,7 +741,7 @@ ST_FUNC void gen_opi(int op)
             r = vtop[-1].r;
             fr = vtop[0].r;
             o((opc << 3) | 0x01);
-            o(0xc0 + r + fr * 8);
+            o(0xc0 + r + fr * 8); 
         }
         vtop--;
         if (op >= TOK_ULT && op <= TOK_GT) {
@@ -911,7 +911,7 @@ ST_FUNC void gen_opf(int op)
             load(TREG_ST0, vtop);
             swapped = !swapped;
         }
-
+        
         switch(op) {
         default:
         case '+':
@@ -972,7 +972,7 @@ ST_FUNC void gen_cvt_itof(int t)
         o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
         o(0x242cdf); /* fildll (%esp) */
         o(0x08c483); /* add $8, %esp */
-    } else if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
+    } else if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == 
                (VT_INT | VT_UNSIGNED)) {
         /* unsigned int to float/double/long double */
         o(0x6a); /* push $0 */
@@ -1060,7 +1060,7 @@ ST_FUNC void gen_bounded_ptr_add(void)
     vtop++;
     vtop->r = TREG_EAX | VT_BOUNDED;
     /* address of bounding function call point */
-    vtop->c.ul = (cur_text_section->reloc->data_offset - sizeof(Elf32_Rel));
+    vtop->c.ul = (cur_text_section->reloc->data_offset - sizeof(Elf32_Rel)); 
 }
 
 /* patch pointer addition in vtop so that pointer dereferencing is

src/x86/i386-tok.h → i386-tok.h


+ 7 - 7
src/cil/il-gen.c

@@ -1,6 +1,6 @@
 /*
  *  CIL code generator for TCC
- *
+ * 
  *  Copyright (c) 2002 Fabrice Bellard
  *
  * This library is free software; you can redistribute it and/or
@@ -112,7 +112,7 @@ static void init_outfile(void)
 {
     if (!il_outfile) {
         il_outfile = stdout;
-        fprintf(il_outfile,
+        fprintf(il_outfile, 
                 ".assembly extern mscorlib\n"
                 "{\n"
                 ".ver 1:0:2411:0\n"
@@ -149,7 +149,7 @@ static void out_opi(int op, int c)
 }
 
 /* XXX: not complete */
-static void il_type_to_str(char *buf, int buf_size,
+static void il_type_to_str(char *buf, int buf_size, 
                            int t, const char *varstr)
 {
     int bt;
@@ -301,12 +301,12 @@ void load(int r, SValue *sv)
                 out_op(IL_OP_LDIND_U2);
             else
                 out_op(IL_OP_LDIND_I4);
-        }
+        } 
     } else {
         if (v == VT_CONST) {
             /* XXX: handle globals */
             if (fc >= -1 && fc <= 8) {
-                out_op(IL_OP_LDC_I4_M1 + fc + 1);
+                out_op(IL_OP_LDC_I4_M1 + fc + 1); 
             } else {
                 out_opi(IL_OP_LDC_I4, fc);
             }
@@ -430,10 +430,10 @@ void gfunc_prolog(int t)
     /* XXX: cannot do better now */
     fprintf(il_outfile, " .maxstack %d\n", NB_REGS);
     fprintf(il_outfile, " .locals (int32, int32, int32, int32, int32, int32, int32, int32)\n");
-
+    
     if (!strcmp(funcname, "main"))
         fprintf(il_outfile, " .entrypoint\n");
-
+        
     sym = sym_find((unsigned)t >> VT_STRUCT_SHIFT);
     func_call = sym->r;
 

+ 1 - 1
src/cil/il-opcodes.h

@@ -1,6 +1,6 @@
 /*
  *  CIL opcode definition
- *
+ * 
  *  Copyright (c) 2002 Fabrice Bellard
  *
  *  This program is free software; you can redistribute it and/or modify

+ 8 - 8
lib/Makefile

@@ -2,9 +2,9 @@
 # Tiny C Compiler Makefile for libtcc1.a
 #
 
-TOP = ../src
+TOP = ..
 include $(TOP)/Makefile
-VPATH = $(top_srcdir)/../lib $(top_srcdir)/../win32/lib
+VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib
 
 ifndef TARGET # native library
  ifdef CONFIG_WIN64
@@ -37,7 +37,7 @@ endif
 BCHECK_O = bcheck.o
 DIR = $(TARGET)
 
-native : $(DIR)/libtcc1.a
+native : ../libtcc1.a
 cross : $(DIR)/libtcc1.a
 
 native : TCC = $(TOP)/tcc$(EXESUF)
@@ -61,26 +61,26 @@ CFLAGS := $(filter-out -fstack-protector-strong,$(CFLAGS))
 ifeq "$(TARGET)" "i386-win"
  OBJ = $(addprefix $(DIR)/,$(WIN32_O))
  TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
- XCC ?= $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/../include
+ XCC ?= $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
  XAR ?= $(DIR)/tiny_libmaker$(EXESUF)
  PICFLAGS =
 else
 ifeq "$(TARGET)" "x86_64-win"
  OBJ = $(addprefix $(DIR)/,$(WIN64_O))
  TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
- XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/../include
+ XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
  XAR ?= $(DIR)/tiny_libmaker$(EXESUF)
  PICFLAGS =
 else
 ifeq "$(TARGET)" "i386"
  OBJ = $(addprefix $(DIR)/,$(I386_O))
  TGT = -DTCC_TARGET_I386
- XCC ?= $(TCC) -B$(TOP) -I$(top_srcdir)/../include
+ XCC ?= $(TCC) -B$(TOP)
 else
 ifeq "$(TARGET)" "x86_64"
  OBJ = $(addprefix $(DIR)/,$(X86_64_O))
  TGT = -DTCC_TARGET_X86_64
- XCC ?= $(TCC) -B$(TOP) -I$(top_srcdir)/../include
+ XCC ?= $(TCC) -B$(TOP)
 else
 ifeq "$(TARGET)" "arm"
  OBJ = $(addprefix $(DIR)/,$(ARM_O))
@@ -110,7 +110,7 @@ endif
 
 XAR ?= $(AR)
 
-$(DIR)/libtcc1.a : $(OBJ) $(XAR)
+$(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
 	$(XAR) rcs $@ $(OBJ)
 $(DIR)/%.o : %.c
 	$(XCC) -c $< -o $@ $(XFLAGS)

+ 28 - 28
lib/bcheck.c

@@ -1,6 +1,6 @@
 /*
  *  Tiny C Memory and bounds checker
- *
+ * 
  *  Copyright (c) 2002 Fabrice Bellard
  *
  * This library is free software; you can redistribute it and/or
@@ -88,7 +88,7 @@ int __bound_delete_region(void *p);
 
 #ifdef __attribute__
   /* an __attribute__ macro is defined in the system headers */
-  #undef __attribute__
+  #undef __attribute__ 
 #endif
 #define FASTCALL __attribute__((regparm(3)))
 
@@ -177,8 +177,8 @@ void * FASTCALL __bound_ptr_add(void *p, size_t offset)
     dprintf(stderr, "%s %s: %p %p\n", __FILE__, __FUNCTION__, p, offset);
 
     e = __bound_t1[addr >> (BOUND_T2_BITS + BOUND_T3_BITS)];
-    e = (BoundEntry *)((char *)e +
-                       ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) &
+    e = (BoundEntry *)((char *)e + 
+                       ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
                         ((BOUND_T2_SIZE - 1) << BOUND_E_BITS)));
     addr -= e->start;
     if (addr > e->size) {
@@ -236,7 +236,7 @@ BOUND_PTR_INDIR(16)
 }
 
 /* called when entering a function to add all the local regions */
-void FASTCALL __bound_local_new(void *p1)
+void FASTCALL __bound_local_new(void *p1) 
 {
     size_t addr, size, fp, *p = p1;
 
@@ -255,7 +255,7 @@ void FASTCALL __bound_local_new(void *p1)
 }
 
 /* called when leaving a function to delete all the local regions */
-void FASTCALL __bound_local_delete(void *p1)
+void FASTCALL __bound_local_delete(void *p1) 
 {
     size_t addr, fp, *p = p1;
     GET_CALLER_FP(fp);
@@ -331,14 +331,14 @@ static void mark_invalid(size_t addr, size_t size)
 #if 0
     dprintf(stderr, "mark_invalid: start = %x %x\n", t2_start, t2_end);
 #endif
-
+    
     /* first we handle full pages */
     t1_start = (t2_start + BOUND_T2_SIZE - 1) >> BOUND_T2_BITS;
     t1_end = t2_end >> BOUND_T2_BITS;
 
     i = t2_start & (BOUND_T2_SIZE - 1);
     j = t2_end & (BOUND_T2_SIZE - 1);
-
+    
     if (t1_start == t1_end) {
         page = get_page(t2_start >> BOUND_T2_BITS);
         for(; i < j; i++) {
@@ -456,7 +456,7 @@ void __bound_main_arg(void **p)
     void *start = p;
     while (*p++);
 
-    dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n",
+    dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n", 
            __FILE__, __FUNCTION__, (void *) p - start);
 
     __bound_new_region(start, (void *) p - start);
@@ -467,7 +467,7 @@ void __bound_exit(void)
     restore_malloc_hooks();
 }
 
-static inline void add_region(BoundEntry *e,
+static inline void add_region(BoundEntry *e, 
                               size_t start, size_t size)
 {
     BoundEntry *e1;
@@ -496,7 +496,7 @@ void __bound_new_region(void *p, size_t size)
 
     __bound_init();
 
-    dprintf(stderr, "%s, %s(%p, %p) start\n",
+    dprintf(stderr, "%s, %s(%p, %p) start\n", 
            __FILE__, __FUNCTION__, p, size);
 
     start = (size_t)p;
@@ -506,9 +506,9 @@ void __bound_new_region(void *p, size_t size)
 
     /* start */
     page = get_page(t1_start);
-    t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) &
+    t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
         ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
-    t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) &
+    t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
         ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
 
 
@@ -557,7 +557,7 @@ void __bound_new_region(void *p, size_t size)
 }
 
 /* delete a region */
-static inline void delete_region(BoundEntry *e,
+static inline void delete_region(BoundEntry *e, 
                                  void *p, size_t empty_size)
 {
     size_t addr;
@@ -612,9 +612,9 @@ int __bound_delete_region(void *p)
 
     start = (size_t)p;
     t1_start = start >> (BOUND_T2_BITS + BOUND_T3_BITS);
-    t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) &
+    t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
         ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
-
+    
     /* find region size */
     page = __bound_t1[t1_start];
     e = (BoundEntry *)((char *)page + t2_start);
@@ -622,7 +622,7 @@ int __bound_delete_region(void *p)
     if (addr > e->size)
         e = __bound_find_region(e, p);
     /* test if invalid region */
-    if (e->size == EMPTY_SIZE || (size_t)p != e->start)
+    if (e->size == EMPTY_SIZE || (size_t)p != e->start) 
         return -1;
     /* compute the size we put in invalid regions */
     if (e->is_invalid)
@@ -634,7 +634,7 @@ int __bound_delete_region(void *p)
 
     /* now we can free each entry */
     t1_end = end >> (BOUND_T2_BITS + BOUND_T3_BITS);
-    t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) &
+    t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
         ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
 
     delete_region(e, p, empty_size);
@@ -690,8 +690,8 @@ static size_t get_region_size(void *p)
     BoundEntry *e;
 
     e = __bound_t1[addr >> (BOUND_T2_BITS + BOUND_T3_BITS)];
-    e = (BoundEntry *)((char *)e +
-                       ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) &
+    e = (BoundEntry *)((char *)e + 
+                       ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
                         ((BOUND_T2_SIZE - 1) << BOUND_E_BITS)));
     addr -= e->start;
     if (addr > e->size)
@@ -756,16 +756,16 @@ static void libc_free(void *ptr)
 void *__bound_malloc(size_t size, const void *caller)
 {
     void *ptr;
-
+    
     /* we allocate one more byte to ensure the regions will be
        separated by at least one byte. With the glibc malloc, it may
        be in fact not necessary */
     ptr = libc_malloc(size + 1);
-
+    
     if (!ptr)
         return NULL;
 
-    dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n",
+    dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n", 
            __FILE__, __FUNCTION__, ptr, size);
 
     __bound_new_region(ptr, size);
@@ -792,13 +792,13 @@ void *__bound_memalign(size_t size, size_t align, const void *caller)
        be in fact not necessary */
     ptr = memalign(size + 1, align);
 #endif
-
+    
     install_malloc_hooks();
-
+    
     if (!ptr)
         return NULL;
 
-    dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n",
+    dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n", 
            __FILE__, __FUNCTION__, ptr, size);
 
     __bound_new_region(ptr, size);
@@ -862,8 +862,8 @@ static void bound_dump(void)
             e = page + j;
             /* do not print invalid or empty entries */
             if (e->size != EMPTY_SIZE && e->start != 0) {
-                fprintf(stderr, "%08x:",
-                       (i << (BOUND_T2_BITS + BOUND_T3_BITS)) +
+                fprintf(stderr, "%08x:", 
+                       (i << (BOUND_T2_BITS + BOUND_T3_BITS)) + 
                        (j << BOUND_T3_BITS));
                 do {
                     fprintf(stderr, " %08lx:%08lx", e->start, e->start + e->size);

+ 13 - 13
lib/libtcc1.c

@@ -1,5 +1,5 @@
-/* TCC runtime library.
-   Parts of this code are (c) 2002 Fabrice Bellard
+/* TCC runtime library. 
+   Parts of this code are (c) 2002 Fabrice Bellard 
 
    Copyright (C) 1987, 1988, 1992, 1994, 1995 Free Software Foundation, Inc.
 
@@ -25,7 +25,7 @@ General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+Boston, MA 02111-1307, USA.  
 */
 
 #include <stdint.h>
@@ -370,10 +370,10 @@ long long __divdi3(long long u, long long v)
     int c = 0;
     DWunion uu, vv;
     DWtype w;
-
+    
     uu.ll = u;
     vv.ll = v;
-
+    
     if (uu.s.high < 0) {
         c = ~c;
         uu.ll = __negdi2 (uu.ll);
@@ -393,17 +393,17 @@ long long __moddi3(long long u, long long v)
     int c = 0;
     DWunion uu, vv;
     DWtype w;
-
+    
     uu.ll = u;
     vv.ll = v;
-
+    
     if (uu.s.high < 0) {
         c = ~c;
         uu.ll = __negdi2 (uu.ll);
     }
     if (vv.s.high < 0)
         vv.ll = __negdi2 (vv.ll);
-
+    
     __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) &w);
     if (c)
         w = __negdi2 (w);
@@ -418,7 +418,7 @@ unsigned long long __udivdi3(unsigned long long u, unsigned long long v)
 unsigned long long __umoddi3(unsigned long long u, unsigned long long v)
 {
     UDWtype w;
-
+    
     __udivmoddi4 (u, v, &w);
     return w;
 }
@@ -499,7 +499,7 @@ long long __tcc_cvt_ftol(long double x)
 /* XXX: fix tcc's code generator to do this instead */
 float __floatundisf(unsigned long long a)
 {
-    DWunion uu;
+    DWunion uu; 
     XFtype r;
 
     uu.ll = a;
@@ -514,7 +514,7 @@ float __floatundisf(unsigned long long a)
 
 double __floatundidf(unsigned long long a)
 {
-    DWunion uu;
+    DWunion uu; 
     XFtype r;
 
     uu.ll = a;
@@ -529,7 +529,7 @@ double __floatundidf(unsigned long long a)
 
 long double __floatundixf(unsigned long long a)
 {
-    DWunion uu;
+    DWunion uu; 
     XFtype r;
 
     uu.ll = a;
@@ -608,7 +608,7 @@ unsigned long long __fixunsxfdi (long double a1)
 
     if (exp > 0)
 	return (unsigned long long)-1;
-    else if (exp >= -63)
+    else if (exp >= -63) 
         return l >> -exp;
     else
         return 0;

+ 16 - 16
src/libtcc.c

@@ -40,24 +40,24 @@ ST_DATA struct TCCState *tcc_state;
 #include "tccelf.c"
 #include "tccrun.c"
 #ifdef TCC_TARGET_I386
-#include "x86/i386-gen.c"
+#include "i386-gen.c"
 #endif
 #ifdef TCC_TARGET_ARM
-#include "arm/arm-gen.c"
+#include "arm-gen.c"
 #endif
 #ifdef TCC_TARGET_ARM64
-#include "arm/arm64-gen.c"
+#include "arm64-gen.c"
 #endif
 #ifdef TCC_TARGET_C67
-#include "tms320c67/c67-gen.c"
+#include "c67-gen.c"
 #endif
 #ifdef TCC_TARGET_X86_64
-#include "x86/x86_64-gen.c"
+#include "x86_64-gen.c"
 #endif
 #ifdef CONFIG_TCC_ASM
 #include "tccasm.c"
 #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
-#include "x86/i386-asm.c"
+#include "i386-asm.c"
 #endif
 #endif
 #ifdef TCC_TARGET_COFF
@@ -318,7 +318,7 @@ PUB_FUNC void tcc_free_debug(void *ptr)
 
     mem_cur_size -= header->size;
     header->size = (size_t)-1;
-
+    
     if (header->next)
         header->next->prev = header->prev;
 
@@ -672,7 +672,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section,
         }
 #else
         if (! (sym->type.t & VT_STATIC))
-            other = (sym->type.t & VT_VIS_MASK) >> VT_VIS_SHIFT;
+	    other = (sym->type.t & VT_VIS_MASK) >> VT_VIS_SHIFT;
 #endif
         if (tcc_state->leading_underscore && can_add_underscore) {
             buf1[0] = '_';
@@ -2101,11 +2101,11 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv)
             s->static_link = 1;
             break;
         case TCC_OPTION_std:
-            /* silently ignore, a current purpose:
-               allow to use a tcc as a reference compiler for "make test" */
+    	    /* silently ignore, a current purpose:
+    	       allow to use a tcc as a reference compiler for "make test" */
             break;
         case TCC_OPTION_shared:
-            if (s->output_type)
+    	    if (s->output_type)
                 tcc_warning("-shared: some compiler action already specified (%d)", s->output_type);
             s->output_type = TCC_OUTPUT_DLL;
             break;
@@ -2124,7 +2124,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv)
             break;
         case TCC_OPTION_r:
             /* generate a .o merging several output files */
-            if (s->output_type)
+    	    if (s->output_type)
                 tcc_warning("-r: some compiler action already specified (%d)", s->output_type);
             s->option_r = 1;
             s->output_type = TCC_OUTPUT_OBJ;
@@ -2163,7 +2163,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv)
             s->print_search_dirs = 1;
             break;
         case TCC_OPTION_run:
-            if (s->output_type)
+    	    if (s->output_type)
                 tcc_warning("-run: some compiler action already specified (%d)", s->output_type);
             s->output_type = TCC_OUTPUT_MEMORY;
             tcc_set_options(s, optarg);
@@ -2194,7 +2194,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv)
             cstr_ccat(&linker_arg, '\0');
             break;
         case TCC_OPTION_E:
-            if (s->output_type)
+    	    if (s->output_type)
                 tcc_warning("-E: some compiler action already specified (%d)", s->output_type);
             s->output_type = TCC_OUTPUT_PREPROCESS;
             break;
@@ -2251,13 +2251,13 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv)
     }
 
     if (s->output_type == 0)
-        s->output_type = TCC_OUTPUT_EXE;
+	s->output_type = TCC_OUTPUT_EXE;
 
     if (pthread && s->output_type != TCC_OUTPUT_OBJ)
         tcc_set_options(s, "-lpthread");
 
     if (s->output_type == TCC_OUTPUT_EXE)
-        tcc_set_linker(s, (const char *)linker_arg.data);
+	tcc_set_linker(s, (const char *)linker_arg.data);
     cstr_free(&linker_arg);
 
     return optind;

src/libtcc.h → libtcc.h


+ 0 - 421
src/Makefile

@@ -1,421 +0,0 @@
-#
-# Tiny C Compiler Makefile
-#
-
-TOP ?= .
-include $(TOP)/../config.mak
-VPATH = $(top_srcdir)
-
-CPPFLAGS += -I$(TOP) # for config.h
-
-ifneq (-$(findstring gcc,$(CC))-,-gcc-)
-ifeq (-$(findstring clang,$(CC))-,-clang-)
-# make clang accept gnuisms in libtcc1.c
-CFLAGS+=-fheinous-gnu-extensions
-endif
-endif
-
-CPPFLAGS_P=$(CPPFLAGS) -DCONFIG_TCC_STATIC
-CFLAGS_P=$(CFLAGS) -pg -static
-LIBS_P=
-LDFLAGS_P=$(LDFLAGS)
-
-ifdef CONFIG_WIN64
-CONFIG_WIN32=yes
-endif
-
-ifndef CONFIG_WIN32
-LIBS=-lm
-ifndef CONFIG_NOLDL
-LIBS+=-ldl
-endif
-endif
-
-# make libtcc as static or dynamic library?
-ifdef DISABLE_STATIC
-ifndef CONFIG_WIN32
-LIBTCC=libtcc.so.1.0
-else
-LIBTCC=libtcc.dll
-LIBTCC_DLL=yes
-LIBTCC_EXTRA=libtcc.def libtcc.a
-endif
-LINK_LIBTCC=-Wl,-rpath,"$(libdir)"
-ifdef DISABLE_RPATH
-LINK_LIBTCC=
-endif
-else
-LIBTCC=libtcc.a
-LINK_LIBTCC=
-endif
-
-CONFIG_$(ARCH) = yes
-NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
-NATIVE_DEFINES_$(CONFIG_x86-64) += -DTCC_TARGET_X86_64
-NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
-NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
-NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
-NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
-NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
-NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP
-NATIVE_DEFINES_$(CONFIG_arm64) += -DTCC_TARGET_ARM64
-NATIVE_DEFINES += $(NATIVE_DEFINES_yes)
-
-ifeq ($(TOP),.)
-
-PROGS=tcc$(EXESUF)
-I386_CROSS = i386-linux-gnu-tcc$(EXESUF)
-WIN32_CROSS = i386-win-mingw32-tcc$(EXESUF)
-WIN64_CROSS = x86_64-win-mingw32-tcc$(EXESUF)
-WINCE_CROSS = arm-win-mingw32ce-tcc$(EXESUF)
-X64_CROSS = x86_64-linux-gnu-tcc$(EXESUF)
-ARM_FPA_CROSS = arm-linux-fpa-tcc$(EXESUF)
-ARM_FPA_LD_CROSS = arm-linux-fpa-ld-tcc$(EXESUF)
-ARM_VFP_CROSS = arm-linux-gnu-tcc$(EXESUF)
-ARM_EABI_CROSS = arm-linux-gnueabi-tcc$(EXESUF)
-ARM_EABIHF_CROSS = arm-linux-gnueabihf-tcc$(EXESUF)
-ARM_CROSS = $(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS)
-ARM64_CROSS = arm64-tcc$(EXESUF)
-C67_CROSS = c67-tcc$(EXESUF)
-
-# Legacy symlinks for cross compilers
-$(I386_CROSS)_LINK = i386-tcc$(EXESUF)
-$(WIN32_CROSS)_LINK = i386-win-tcc$(EXESUF)
-$(WIN64_CROSS)_LINK = x86_64-win-tcc$(EXESUF)
-$(WINCE_CROSS)_LINK = arm-win-tcc$(EXESUF)
-$(X64_CROSS)_LINK = x86_64-tcc$(EXESUF)
-$(ARM_FPA_CROSS)_LINK = arm-fpa-tcc$(EXESUF)
-$(ARM_FPA_LD_CROSS)_LINK = arm-fpa-ld-tcc$(EXESUF)
-$(ARM_VFP_CROSS)_LINK = arm-vfp-tcc$(EXESUF)
-$(ARM_EABI_CROSS)_LINK = arm-eabi-tcc$(EXESUF)
-
-ifeq ($(TARGETOS),Windows)
-ifeq ($(ARCH),i386)
-PROGS:=$($(WIN32_CROSS)_LINK)
-$($(WIN32_CROSS)_LINK)_TCC = yes
-endif
-ifeq ($(ARCH),x86-64)
-PROGS:=$($(WIN64_CROSS)_LINK)
-$($(WIN64_CROSS)_LINK)_TCC = yes
-endif
-endif
-
-ifeq ($(TARGETOS),Linux)
-ifeq ($(ARCH),i386)
-PROGS:=$($(I386_CROSS)_LINK)
-$($(I386_CROSS)_LINK)_TCC = yes
-endif
-ifeq ($(ARCH),x86-64)
-PROGS:=$($(X64_CROSS)_LINK)
-$($(X64_CROSS)_LINK)_TCC = yes
-endif
-endif
-
-CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c
-CORE_FILES += tcc.h config.h libtcc.h tcctok.h
-I386_FILES = $(CORE_FILES) x86/i386-gen.c x86/i386-asm.c x86/i386-asm.h x86/i386-tok.h
-WIN32_FILES = $(CORE_FILES) x86/i386-gen.c x86/i386-asm.c x86/i386-asm.h x86/i386-tok.h tccpe.c
-WIN64_FILES = $(CORE_FILES) x86/x86_64-gen.c x86/i386-asm.c x86/x86_64-asm.h tccpe.c
-WINCE_FILES = $(CORE_FILES) arm/arm-gen.c tccpe.c
-X86_64_FILES = $(CORE_FILES) x86/x86_64-gen.c x86/i386-asm.c x86/x86_64-asm.h
-ARM_FILES = $(CORE_FILES) arm/arm-gen.c
-ARM64_FILES = $(CORE_FILES) arm/arm64-gen.c
-C67_FILES = $(CORE_FILES) tms320c67/c67-gen.c tcccoff.c
-
-ifdef CONFIG_WIN64
-PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
-NATIVE_FILES=$(WIN64_FILES)
-PROGS_CROSS=$(WIN32_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
-LIBTCC1_CROSS=lib/i386-win/libtcc1.a
-LIBTCC1=libtcc1.a
-else ifdef CONFIG_WIN32
-PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
-NATIVE_FILES=$(WIN32_FILES)
-PROGS_CROSS=$(WIN64_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
-LIBTCC1_CROSS=lib/x86_64-win/libtcc1.a
-LIBTCC1=libtcc1.a
-else ifeq ($(ARCH),i386)
-NATIVE_FILES=$(I386_FILES)
-PROGS_CROSS=$($(X64_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
-LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a \
-    lib/arm64/libtcc1.a
-LIBTCC1=libtcc1.a
-else ifeq ($(ARCH),x86-64)
-ifeq ($(TARGETOS),Darwin)
-NATIVE_FILES=$(X86_64_FILES)
-PROGS_CROSS=$($(I386_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(C67_CROSS) $(WINCE_CROSS)
-LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a
-LIBTCC1=libtcc1.a
-else
-NATIVE_FILES=$(X86_64_FILES)
-PROGS_CROSS=$($(I386_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
-LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a \
-    lib/arm64/libtcc1.a
-LIBTCC1=libtcc1.a
-endif
-else ifeq ($(ARCH),arm)
-NATIVE_FILES=$(ARM_FILES)
-PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
-LIBTCC1=libtcc1.a
-LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a
-else ifeq ($(ARCH),arm64)
-NATIVE_FILES=$(ARM64_FILES)
-PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(C67_CROSS) $(WINCE_CROSS)
-LIBTCC1=libtcc1.a
-LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a
-endif
-PROGS_CROSS_LINK=$(foreach PROG_CROSS,$(PROGS_CROSS),$($(PROG_CROSS)_LINK))
-
-ifeq ($(TARGETOS),Darwin)
-PROGS+=tiny_libmaker$(EXESUF)
-endif
-
-TCCLIBS = $(LIBTCC1) $(LIBTCC) $(LIBTCC_EXTRA)
-TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info
-
-ifdef CONFIG_CROSS
-PROGS+=$(PROGS_CROSS)
-TCCLIBS+=$(LIBTCC1_CROSS)
-endif
-
-all: $(PROGS) $(TCCLIBS) $(TCCDOCS)
-
-# Host Tiny C Compiler
-tcc$(EXESUF): tcc.o $(LIBTCC)
-	$(CC) -o $@ $^ $(LIBS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LINK_LIBTCC)
-
-# Cross Tiny C Compilers
-%-tcc$(EXESUF): tcc.c
-	$(CC) -o $@ $< -DONE_SOURCE $(if $($@_TCC),$(NATIVE_DEFINES),$(DEFINES)) $(CPPFLAGS) $(CFLAGS) $(LIBS) $(LDFLAGS)
-	$(if $($@_LINK),ln -sf $@ $($@_LINK))
-	$(if $($@_TCC),ln -sf $@ tcc$(EXESUF))
-
-# profiling version
-tcc_p$(EXESUF): $(NATIVE_FILES)
-	$(CC) -o $@ $< -DONE_SOURCE $(NATIVE_DEFINES) $(CPPFLAGS_P) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
-
-$(I386_CROSS) $($(I386_CROSS)_LINK): DEFINES = -DTCC_TARGET_I386
-$(X64_CROSS) $($(X64_CROSS)_LINK): DEFINES = -DTCC_TARGET_X86_64
-$(WIN32_CROSS) $($(WIN32_CROSS)_LINK): DEFINES = -DTCC_TARGET_I386 -DTCC_TARGET_PE \
-    -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \
-    -DCONFIG_TCC_LIBPATHS="\"{B}/lib/32;{B}/lib\""
-$(WIN64_CROSS) $($(WIN64_CROSS)_LINK): DEFINES = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE \
-    -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \
-    -DCONFIG_TCC_LIBPATHS="\"{B}/lib/64;{B}/lib\""
-$(WINCE_CROSS): DEFINES = -DTCC_TARGET_PE
-$(C67_CROSS): DEFINES = -DTCC_TARGET_C67
-$(ARM_FPA_CROSS): DEFINES = -DTCC_TARGET_ARM
-$(ARM_FPA_LD_CROSS)$(EXESUF): DEFINES = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12
-$(ARM_VFP_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_VFP
-$(ARM_EABI_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_VFP
-$(ARM64_CROSS): DEFINES = -DTCC_TARGET_ARM64
-
-$(I386_CROSS) $($(I386_CROSS)_LINK): $(I386_FILES)
-$(X64_CROSS)  $($(X64_CROSS)_LINK): $(X86_64_FILES)
-$(WIN32_CROSS) $($(WIN32_CROSS)_LINK): $(WIN32_FILES)
-$(WIN64_CROSS) $($(WIN64_CROSS)_LINK): $(WIN64_FILES)
-$(WINCE_CROSS) $($(WINCE_CROSS)_LINK): $(WINCE_FILES)
-$(C67_CROSS)  $($(C67_CROSS)_LINK): $(C67_FILES)
-$(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS): $(ARM_FILES)
-$($(ARM_FPA_CROSS)_LINK) $($(ARM_FPA_LD_CROSS)_LINK) $($(ARM_VFP_CROSS)_LINK) $($(ARM_EABI_CROSS)_LINK): $(ARM_FILES)
-$(ARM64_CROSS): $(ARM64_FILES)
-
-# libtcc generation and test
-ifndef ONE_SOURCE
-LIBTCC_OBJ = $(filter-out tcc.o,$(patsubst %.c,%.o,$(filter %.c,$(NATIVE_FILES))))
-LIBTCC_INC = $(filter %.h,$(CORE_FILES)) $(filter-out $(CORE_FILES),$(NATIVE_FILES))
-else
-LIBTCC_OBJ = libtcc.o
-LIBTCC_INC = $(NATIVE_FILES)
-libtcc.o : NATIVE_DEFINES += -DONE_SOURCE
-endif
-
-$(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC)
-	$(CC) -o $@ -c $< $(NATIVE_DEFINES) $(CPPFLAGS) $(CFLAGS)
-
-ifndef LIBTCC_DLL
-libtcc.a: $(LIBTCC_OBJ)
-	$(AR) rcs $@ $^
-endif
-
-libtcc.so.1.0: $(LIBTCC_OBJ)
-	$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
-
-libtcc.so.1.0: CFLAGS+=-fPIC
-
-ifdef LIBTCC_DLL
-libtcc.dll libtcc.def libtcc.a: $(LIBTCC_OBJ)
-	$(CC) -shared $^ -o $@ $(LDFLAGS) -Wl,--output-def,libtcc.def,--out-implib,libtcc.a
-endif
-
-# windows utilities
-tiny_impdef$(EXESUF): ../win32/tools/tiny_impdef.c
-	$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
-tiny_libmaker$(EXESUF): ../win32/tools/tiny_libmaker.c
-	$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
-
-# TinyCC runtime libraries
-libtcc1.a : FORCE
-	$(MAKE) -C ../lib native
-	if test ! -d $(ARCH); then mkdir $(ARCH); fi
-	if test ! -L $(ARCH)/$@; then ln -sf ../$@ $(ARCH)/$@; fi
-lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
-	$(MAKE) -C ../lib cross TARGET=$*
-
-FORCE:
-
-# install
-TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h
-INSTALL=install
-ifdef STRIP_BINARIES
-INSTALLBIN=$(INSTALL) -s
-else
-INSTALLBIN=$(INSTALL)
-endif
-
-install-strip: install
-	strip $(foreach PROG,$(PROGS),"$(bindir)"/$(PROG))
-
-ifndef CONFIG_WIN32
-install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
-	mkdir -p "$(bindir)"
-	$(INSTALLBIN) -m755 $(PROGS) "$(bindir)"
-	cp -P tcc$(EXESUF) "$(bindir)"
-	mkdir -p "$(mandir)/man1"
-	-$(INSTALL) -m644 tcc.1 "$(mandir)/man1"
-	mkdir -p "$(infodir)"
-	-$(INSTALL) -m644 tcc-doc.info "$(infodir)"
-	mkdir -p "$(tccdir)"
-	mkdir -p "$(tccdir)/include"
-ifneq ($(LIBTCC1),)
-	mkdir -p "$(tccdir)/$(ARCH)"
-	$(INSTALL) -m644 $(LIBTCC1) "$(tccdir)/$(ARCH)"
-endif
-	$(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include"
-	mkdir -p "$(libdir)"
-	$(INSTALL) -m644 $(LIBTCC) "$(libdir)"
-ifdef DISABLE_STATIC
-	ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so.1"
-	ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so"
-endif
-	mkdir -p "$(includedir)"
-	$(INSTALL) -m644 $(top_srcdir)/libtcc.h "$(includedir)"
-	mkdir -p "$(docdir)"
-	-$(INSTALL) -m644 tcc-doc.html "$(docdir)"
-ifdef CONFIG_CROSS
-	mkdir -p "$(tccdir)/win32/lib/32"
-	mkdir -p "$(tccdir)/win32/lib/64"
-	mkdir -p "$(tccdir)/i386"
-	mkdir -p "$(tccdir)/x86-64"
-ifneq ($(HOST_OS),Darwin)
-	mkdir -p "$(tccdir)/arm64"
-	$(INSTALL) -m644 lib/arm64/libtcc1.a "$(tccdir)/arm64"
-endif
-	$(INSTALL) -m644 lib/i386/libtcc1.a "$(tccdir)/i386"
-	$(INSTALL) -m644 lib/x86_64/libtcc1.a "$(tccdir)/x86-64"
-	$(INSTALL) -m644 $(top_srcdir)/win32/lib/*.def "$(tccdir)/win32/lib"
-	$(INSTALL) -m644 lib/i386-win/libtcc1.a "$(tccdir)/win32/lib/32"
-	$(INSTALL) -m644 lib/x86_64-win/libtcc1.a "$(tccdir)/win32/lib/64"
-	cp -r $(top_srcdir)/win32/include/. "$(tccdir)/win32/include"
-	cp -r "$(tccdir)/include" "$(tccdir)/win32"
-endif
-
-uninstall:
-	rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
-	rm -fv "$(bindir)/tcc$(EXESUF)"
-	rm -fv $(foreach P,$(LIBTCC1),"$(tccdir)/$P")
-	rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P")
-	rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
-	rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
-	rm -fv "$(libdir)/libtcc.so*"
-	rm -rv "$(tccdir)"
-	rm -rv "$(docdir)"
-else
-# on windows
-install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
-	mkdir -p "$(tccdir)"
-	mkdir -p "$(tccdir)/lib"
-	mkdir -p "$(tccdir)/include"
-	mkdir -p "$(tccdir)/examples"
-	mkdir -p "$(tccdir)/doc"
-	mkdir -p "$(tccdir)/libtcc"
-	$(INSTALLBIN) -m755 $(PROGS) "$(tccdir)"
-	$(INSTALLBIN) -m755 tcc.exe "$(tccdir)"
-	$(INSTALL) -m644 $(LIBTCC1) $(top_srcdir)/win32/lib/*.def "$(tccdir)/lib"
-	cp -r $(top_srcdir)/win32/include/. "$(tccdir)/include"
-	cp -r $(top_srcdir)/win32/examples/. "$(tccdir)/examples"
-	$(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include"
-	$(INSTALL) -m644 tcc-doc.html $(top_srcdir)/win32/tcc-win32.txt "$(tccdir)/doc"
-	$(INSTALL) -m644 $(top_srcdir)/libtcc.h $(LIBTCC_EXTRA) "$(tccdir)/libtcc"
-	$(INSTALL) -m644 $(LIBTCC) "$(tccdir)"
-ifdef CONFIG_CROSS
-	mkdir -p "$(tccdir)/lib/32"
-	mkdir -p "$(tccdir)/lib/64"
-	-$(INSTALL) -m644 lib/i386-win/libtcc1.a "$(tccdir)/lib/32"
-	-$(INSTALL) -m644 lib/x86_64-win/libtcc1.a "$(tccdir)/lib/64"
-endif
-
-uninstall:
-	rm -rfv "$(tccdir)/*"
-endif
-
-# documentation and man page
-tcc-doc.html: ../docs/tcc-doc.texi
-	-makeinfo --no-split --html --number-sections -o $@ $<
-
-tcc.1: ../docs/tcc-doc.texi
-	-$(top_srcdir)/../docs/texi2pod.pl $< tcc.pod
-	-pod2man --section=1 --center="Tiny C Compiler" --release=`cat $(top_srcdir)/../VERSION` tcc.pod > $@
-
-tcc-doc.info: ../docs/tcc-doc.texi
-	-makeinfo $<
-
-# in tests subdir
-export LIBTCC1
-
-%est:
-	$(MAKE) -C ../tests $@ 'PROGS_CROSS=$(PROGS_CROSS)'
-
-clean:
-	rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.log \
-		*.exe a.out tags TAGS libtcc_test$(EXESUF) tcc$(EXESUF)
-	-rm -r $(ARCH) arm64
-ifeq ($(HOST_OS),Linux)
-	-rm -r ./C:
-endif
-	-rm *-tcc$(EXESUF)
-	$(MAKE) -C ../tests $@
-ifneq ($(LIBTCC1),)
-	$(MAKE) -C ../lib $@
-endif
-
-distclean: clean
-	rm -vf config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
-
-config.mak:
-	@echo "Please run ./configure."
-	@exit 1
-
-tags:
-	ctags $(top_srcdir)/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[chS]
-
-TAGS:
-	ctags -e $(top_srcdir)/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[chS]
-
-# create release tarball from *current* git branch (including tcc-doc.html
-# and converting two files to CRLF)
-TCC-VERSION := tcc-$(shell cat $(top_srcdir)/../VERSION)
-tar:    tcc-doc.html
-	mkdir $(TCC-VERSION)
-	( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )
-	cp tcc-doc.html $(TCC-VERSION)
-	for f in tcc-win32.txt build-tcc.bat ; do \
-	    cat win32/$$f | sed 's,\(.*\),\1\r,g' > $(TCC-VERSION)/win32/$$f ; \
-	done
-	tar cjf $(TCC-VERSION).tar.bz2 $(TCC-VERSION)
-	rm -rf $(TCC-VERSION)
-	git reset
-
-.PHONY: all clean tar tags TAGS distclean install uninstall FORCE
-
-endif # ifeq ($(TOP),.)

File diff suppressed because it is too large
+ 0 - 2162
src/arm/arm-gen.c


+ 0 - 924
src/tcccoff.c

@@ -1,924 +0,0 @@
-/*
- *  COFF file handling for TCC
- *
- *  Copyright (c) 2003, 2004 TK
- *  Copyright (c) 2004 Fabrice Bellard
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "tcc.h"
-
-#define MAXNSCNS 255        /* MAXIMUM NUMBER OF SECTIONS         */
-#define MAX_STR_TABLE 1000000
-AOUTHDR o_filehdr;          /* OPTIONAL (A.OUT) FILE HEADER       */
-
-SCNHDR section_header[MAXNSCNS];
-
-#define MAX_FUNCS 1000
-#define MAX_FUNC_NAME_LENGTH 128
-
-int nFuncs;
-char Func[MAX_FUNCS][MAX_FUNC_NAME_LENGTH];
-char AssociatedFile[MAX_FUNCS][MAX_FUNC_NAME_LENGTH];
-int LineNoFilePtr[MAX_FUNCS];
-int EndAddress[MAX_FUNCS];
-int LastLineNo[MAX_FUNCS];
-int FuncEntries[MAX_FUNCS];
-
-int OutputTheSection(Section* sect);
-short int GetCoffFlags(const char* s);
-void SortSymbolTable(void);
-Section* FindSection(TCCState* s1, const char* sname);
-
-int C67_main_entry_point;
-
-int FindCoffSymbolIndex(const char* func_name);
-int nb_syms;
-
-typedef struct {
-    long tag;
-    long size;
-    long fileptr;
-    long nextsym;
-    short int dummy;
-} AUXFUNC;
-
-typedef struct {
-    long regmask;
-    unsigned short lineno;
-    unsigned short nentries;
-    int localframe;
-    int nextentry;
-    short int dummy;
-} AUXBF;
-
-typedef struct {
-    long dummy;
-    unsigned short lineno;
-    unsigned short dummy1;
-    int dummy2;
-    int dummy3;
-    unsigned short dummy4;
-} AUXEF;
-
-ST_FUNC int tcc_output_coff(TCCState* s1, FILE* f)
-{
-    Section* tcc_sect;
-    SCNHDR* coff_sec;
-    int file_pointer;
-    char* Coff_str_table, *pCoff_str_table;
-    int CoffTextSectionNo, coff_nb_syms;
-    FILHDR file_hdr; /* FILE HEADER STRUCTURE              */
-    Section* stext, *sdata, *sbss;
-    int i, NSectionsToOutput = 0;
-
-    Coff_str_table = pCoff_str_table = NULL;
-
-    stext = FindSection(s1, ".text");
-    sdata = FindSection(s1, ".data");
-    sbss = FindSection(s1, ".bss");
-
-    nb_syms = symtab_section->data_offset / sizeof(Elf32_Sym);
-    coff_nb_syms = FindCoffSymbolIndex("XXXXXXXXXX1");
-
-    file_hdr.f_magic = COFF_C67_MAGIC;        /* magic number */
-    file_hdr.f_timdat = 0;                    /* time & date stamp */
-    file_hdr.f_opthdr = sizeof(AOUTHDR);      /* sizeof(optional hdr) */
-    file_hdr.f_flags = 0x1143;                /* flags (copied from what code composer does) */
-    file_hdr.f_TargetID = 0x99;               /* for C6x = 0x0099 */
-
-    o_filehdr.magic = 0x0108;                 /* see magic.h                          */
-    o_filehdr.vstamp = 0x0190;                /* version stamp                        */
-    o_filehdr.tsize =
-        stext->data_offset;                   /* text size in bytes, padded to FW bdry */
-    o_filehdr.dsize = sdata->data_offset;     /* initialized data "  " */
-    o_filehdr.bsize = sbss->data_offset;      /* uninitialized data "   " */
-    o_filehdr.entrypt = C67_main_entry_point; /* entry pt. */
-    o_filehdr.text_start = stext->sh_addr;    /* base of text used for this file */
-    o_filehdr.data_start = sdata->sh_addr;    /* base of data used for this file */
-
-    // create all the section headers
-
-    file_pointer = FILHSZ + sizeof(AOUTHDR);
-
-    CoffTextSectionNo = -1;
-
-    for (i = 1; i < s1->nb_sections; i++) {
-        coff_sec = &section_header[i];
-        tcc_sect = s1->sections[i];
-
-        if (OutputTheSection(tcc_sect)) {
-            NSectionsToOutput++;
-
-            if (CoffTextSectionNo == -1 && tcc_sect == stext)
-                CoffTextSectionNo = NSectionsToOutput; // rem which coff sect
-                                                       // number the .text sect
-                                                       // is
-
-            strcpy(coff_sec->s_name, tcc_sect->name); /* section name */
-
-            coff_sec->s_paddr = tcc_sect->sh_addr;    /* physical address */
-            coff_sec->s_vaddr = tcc_sect->sh_addr;    /* virtual address */
-            coff_sec->s_size = tcc_sect->data_offset; /* section size */
-            coff_sec->s_scnptr = 0;  /* file ptr to raw data for section */
-            coff_sec->s_relptr = 0;  /* file ptr to relocation */
-            coff_sec->s_lnnoptr = 0; /* file ptr to line numbers */
-            coff_sec->s_nreloc = 0;  /* number of relocation entries */
-            coff_sec->s_flags = GetCoffFlags(coff_sec->s_name); /* flags */
-            coff_sec->s_reserved = 0; /* reserved byte */
-            coff_sec->s_page = 0;     /* memory page id */
-
-            file_pointer += sizeof(SCNHDR);
-        }
-    }
-
-    file_hdr.f_nscns = NSectionsToOutput; /* number of sections */
-
-    // now loop through and determine file pointer locations
-    // for the raw data
-
-    for (i = 1; i < s1->nb_sections; i++) {
-        coff_sec = &section_header[i];
-        tcc_sect = s1->sections[i];
-
-        if (OutputTheSection(tcc_sect)) {
-            // put raw data
-            coff_sec->s_scnptr =
-                file_pointer; /* file ptr to raw data for section */
-            file_pointer += coff_sec->s_size;
-        }
-    }
-
-    // now loop through and determine file pointer locations
-    // for the relocation data
-
-    for (i = 1; i < s1->nb_sections; i++) {
-        coff_sec = &section_header[i];
-        tcc_sect = s1->sections[i];
-
-        if (OutputTheSection(tcc_sect)) {
-            // put relocations data
-            if (coff_sec->s_nreloc > 0) {
-                coff_sec->s_relptr = file_pointer; /* file ptr to relocation */
-                file_pointer += coff_sec->s_nreloc * sizeof(struct reloc);
-            }
-        }
-    }
-
-    // now loop through and determine file pointer locations
-    // for the line number data
-
-    for (i = 1; i < s1->nb_sections; i++) {
-        coff_sec = &section_header[i];
-        tcc_sect = s1->sections[i];
-
-        coff_sec->s_nlnno = 0;
-        coff_sec->s_lnnoptr = 0;
-
-        if (s1->do_debug && tcc_sect == stext) {
-            // count how many line nos data
-
-            // also find association between source file name and function
-            // so we can sort the symbol table
-
-            Stab_Sym* sym, *sym_end;
-            char func_name[MAX_FUNC_NAME_LENGTH],
-                last_func_name[MAX_FUNC_NAME_LENGTH];
-            unsigned long func_addr, last_pc, pc;
-            const char* incl_files[INCLUDE_STACK_SIZE];
-            int incl_index, len, last_line_num;
-            const char* str, *p;
-
-            coff_sec->s_lnnoptr = file_pointer; /* file ptr to linno */
-
-            func_name[0] = '\0';
-            func_addr = 0;
-            incl_index = 0;
-            last_func_name[0] = '\0';
-            last_pc = 0xffffffff;
-            last_line_num = 1;
-            sym = (Stab_Sym*)stab_section->data + 1;
-            sym_end =
-                (Stab_Sym*)(stab_section->data + stab_section->data_offset);
-
-            nFuncs = 0;
-            while (sym < sym_end) {
-                switch (sym->n_type) {
-                /* function start or end */
-                case N_FUN:
-                    if (sym->n_strx == 0) {
-                        // end of function
-
-                        coff_sec->s_nlnno++;
-                        file_pointer += LINESZ;
-
-                        pc = sym->n_value + func_addr;
-                        func_name[0] = '\0';
-                        func_addr = 0;
-                        EndAddress[nFuncs] = pc;
-                        FuncEntries[nFuncs] =
-                            (file_pointer - LineNoFilePtr[nFuncs]) / LINESZ - 1;
-                        LastLineNo[nFuncs++] = last_line_num + 1;
-                    } else {
-                        // beginning of function
-
-                        LineNoFilePtr[nFuncs] = file_pointer;
-                        coff_sec->s_nlnno++;
-                        file_pointer += LINESZ;
-
-                        str = (const char*)stabstr_section->data + sym->n_strx;
-
-                        p = strchr(str, ':');
-                        if (!p) {
-                            pstrcpy(func_name, sizeof(func_name), str);
-                            pstrcpy(Func[nFuncs], sizeof(func_name), str);
-                        } else {
-                            len = p - str;
-                            if (len > sizeof(func_name) - 1)
-                                len = sizeof(func_name) - 1;
-                            memcpy(func_name, str, len);
-                            memcpy(Func[nFuncs], str, len);
-                            func_name[len] = '\0';
-                        }
-
-                        // save the file that it came in so we can sort later
-                        pstrcpy(AssociatedFile[nFuncs], sizeof(func_name),
-                                incl_files[incl_index - 1]);
-
-                        func_addr = sym->n_value;
-                    }
-                    break;
-
-                /* line number info */
-                case N_SLINE:
-                    pc = sym->n_value + func_addr;
-
-                    last_pc = pc;
-                    last_line_num = sym->n_desc;
-
-                    /* XXX: slow! */
-                    strcpy(last_func_name, func_name);
-
-                    coff_sec->s_nlnno++;
-                    file_pointer += LINESZ;
-                    break;
-                /* include files */
-                case N_BINCL:
-                    str = (const char*)stabstr_section->data + sym->n_strx;
-                add_incl:
-                    if (incl_index < INCLUDE_STACK_SIZE) {
-                        incl_files[incl_index++] = str;
-                    }
-                    break;
-                case N_EINCL:
-                    if (incl_index > 1)
-                        incl_index--;
-                    break;
-                case N_SO:
-                    if (sym->n_strx == 0) {
-                        incl_index = 0; /* end of translation unit */
-                    } else {
-                        str = (const char*)stabstr_section->data + sym->n_strx;
-                        /* do not add path */
-                        len = strlen(str);
-                        if (len > 0 && str[len - 1] != '/')
-                            goto add_incl;
-                    }
-                    break;
-                }
-                sym++;
-            }
-        }
-    }
-
-    file_hdr.f_symptr = file_pointer; /* file pointer to symtab */
-
-    if (s1->do_debug)
-        file_hdr.f_nsyms = coff_nb_syms; /* number of symtab entries */
-    else
-        file_hdr.f_nsyms = 0;
-
-    file_pointer += file_hdr.f_nsyms * SYMNMLEN;
-
-    // OK now we are all set to write the file
-
-    fwrite(&file_hdr, FILHSZ, 1, f);
-    fwrite(&o_filehdr, sizeof(o_filehdr), 1, f);
-
-    // write section headers
-    for (i = 1; i < s1->nb_sections; i++) {
-        coff_sec = &section_header[i];
-        tcc_sect = s1->sections[i];
-
-        if (OutputTheSection(tcc_sect)) {
-            fwrite(coff_sec, sizeof(SCNHDR), 1, f);
-        }
-    }
-
-    // write raw data
-    for (i = 1; i < s1->nb_sections; i++) {
-        coff_sec = &section_header[i];
-        tcc_sect = s1->sections[i];
-
-        if (OutputTheSection(tcc_sect)) {
-            fwrite(tcc_sect->data, tcc_sect->data_offset, 1, f);
-        }
-    }
-
-    // write relocation data
-    for (i = 1; i < s1->nb_sections; i++) {
-        coff_sec = &section_header[i];
-        tcc_sect = s1->sections[i];
-
-        if (OutputTheSection(tcc_sect)) {
-            // put relocations data
-            if (coff_sec->s_nreloc > 0) {
-                fwrite(tcc_sect->reloc,
-                       coff_sec->s_nreloc * sizeof(struct reloc), 1, f);
-            }
-        }
-    }
-
-    // group the symbols in order of filename, func1, func2, etc
-    // finally global symbols
-
-    if (s1->do_debug)
-        SortSymbolTable();
-
-    // write line no data
-
-    for (i = 1; i < s1->nb_sections; i++) {
-        coff_sec = &section_header[i];
-        tcc_sect = s1->sections[i];
-
-        if (s1->do_debug && tcc_sect == stext) {
-            // count how many line nos data
-
-            Stab_Sym* sym, *sym_end;
-            char func_name[128], last_func_name[128];
-            unsigned long func_addr, last_pc, pc;
-            const char* incl_files[INCLUDE_STACK_SIZE];
-            int incl_index, len, last_line_num;
-            const char* str, *p;
-
-            LINENO CoffLineNo;
-
-            func_name[0] = '\0';
-            func_addr = 0;
-            incl_index = 0;
-            last_func_name[0] = '\0';
-            last_pc = 0;
-            last_line_num = 1;
-            sym = (Stab_Sym*)stab_section->data + 1;
-            sym_end =
-                (Stab_Sym*)(stab_section->data + stab_section->data_offset);
-
-            while (sym < sym_end) {
-                switch (sym->n_type) {
-                /* function start or end */
-                case N_FUN:
-                    if (sym->n_strx == 0) {
-                        // end of function
-
-                        CoffLineNo.l_addr.l_paddr = last_pc;
-                        CoffLineNo.l_lnno = last_line_num + 1;
-                        fwrite(&CoffLineNo, 6, 1, f);
-
-                        pc = sym->n_value + func_addr;
-                        func_name[0] = '\0';
-                        func_addr = 0;
-                    } else {
-                        // beginning of function
-
-                        str = (const char*)stabstr_section->data + sym->n_strx;
-
-                        p = strchr(str, ':');
-                        if (!p) {
-                            pstrcpy(func_name, sizeof(func_name), str);
-                        } else {
-                            len = p - str;
-                            if (len > sizeof(func_name) - 1)
-                                len = sizeof(func_name) - 1;
-                            memcpy(func_name, str, len);
-                            func_name[len] = '\0';
-                        }
-                        func_addr = sym->n_value;
-                        last_pc = func_addr;
-                        last_line_num = -1;
-
-                        // output a function begin
-
-                        CoffLineNo.l_addr.l_symndx =
-                            FindCoffSymbolIndex(func_name);
-                        CoffLineNo.l_lnno = 0;
-
-                        fwrite(&CoffLineNo, 6, 1, f);
-                    }
-                    break;
-
-                /* line number info */
-                case N_SLINE:
-                    pc = sym->n_value + func_addr;
-
-                    /* XXX: slow! */
-                    strcpy(last_func_name, func_name);
-
-                    // output a line reference
-
-                    CoffLineNo.l_addr.l_paddr = last_pc;
-
-                    if (last_line_num == -1) {
-                        CoffLineNo.l_lnno = sym->n_desc;
-                    } else {
-                        CoffLineNo.l_lnno = last_line_num + 1;
-                    }
-
-                    fwrite(&CoffLineNo, 6, 1, f);
-
-                    last_pc = pc;
-                    last_line_num = sym->n_desc;
-
-                    break;
-
-                /* include files */
-                case N_BINCL:
-                    str = (const char*)stabstr_section->data + sym->n_strx;
-                add_incl2:
-                    if (incl_index < INCLUDE_STACK_SIZE) {
-                        incl_files[incl_index++] = str;
-                    }
-                    break;
-                case N_EINCL: