Check-in [b850d29737]
Overview
Comment:Updated to build tcc statically and enable stubs
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b850d29737b4dbeb7aa267629102d18d25014e5a
User & Date: rkeene on 2014-05-05 17:16:38
Other Links: manifest | tags
Context
2014-05-05
20:48
Updated to be quieter during installation of header files check-in: 2e16cde0c4 user: rkeene tags: trunk
17:16
Updated to build tcc statically and enable stubs check-in: b850d29737 user: rkeene tags: trunk
17:16
Updated to keep GCC headers into gcc directory check-in: e8cbf3c10e user: rkeene tags: trunk
Changes

Modified Makefile.in from [a463bb46e0] to [3392a9b99d].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_VERSION = @PACKAGE_VERSION@

TCLCONFIGPATH = @TCLCONFIGPATH@
TCL_PACKAGE_PATH = @TCL_PACKAGE_PATH@
tcllibdir = $(shell if echo "$(libdir)" | grep '^UNSPECIFIED' >/dev/null; then echo $(TCL_PACKAGE_PATH); else echo "$(libdir)"; fi)
PACKAGE_INSTALL_DIR = $(tcllibdir)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
TCC_CONFIGURE_OPTS = --extra-cflags='$(CPPFLAGS) $(CFLAGS)' --with-tcl=$(TCLCONFIGPATH) --sysincludepaths='{B}/include' --libpaths='{B}/lib' @TCC_CONFIGURE_OPTS@
INSTALL_HEADERS = tcl.h assert.h ctype.h errno.h float.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h string.h time.h wctype.h
srcdir = @srcdir@
host_os = @host_os@
@SET_MAKE@

all: $(TARGET)








|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_VERSION = @PACKAGE_VERSION@

TCLCONFIGPATH = @TCLCONFIGPATH@
TCL_PACKAGE_PATH = @TCL_PACKAGE_PATH@
tcllibdir = $(shell if echo "$(libdir)" | grep '^UNSPECIFIED' >/dev/null; then echo $(TCL_PACKAGE_PATH); else echo "$(libdir)"; fi)
PACKAGE_INSTALL_DIR = $(tcllibdir)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
TCC_CONFIGURE_OPTS = --extra-cflags='$(CPPFLAGS) $(CFLAGS) -DCONFIG_TCC_STATIC=1' --with-tcl=$(TCLCONFIGPATH) --sysincludepaths='{B}/include' --libpaths='{B}/lib' @TCC_CONFIGURE_OPTS@
INSTALL_HEADERS = tcl.h assert.h ctype.h errno.h float.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h string.h time.h wctype.h
srcdir = @srcdir@
host_os = @host_os@
@SET_MAKE@

all: $(TARGET)

Modified build/tcc-patches/0.9.26/tcc-0.9.26-tcl.diff from [e03734effa] to [f74bb07351].


1
2
3
4
5
6
7
8
9
..
47
48
49
50
51
52
53
















54
55
56
57
58
59
60
61
62
63
64
65
























--- tcc-0.9.26.orig/configure	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1tcl/configure	2014-05-01 19:50:10.103740647 -0500
@@ -43,6 +43,7 @@
 tcc_libpaths=""
 tcc_crtprefix=""
 tcc_elfinterp=""
+tcc_tcl_path=""
 tcc_lddir=
 confvars=
................................................................................
+		fi
+	done
+fi
+
 cat <<EOF
 Binary  directory   $bindir
 TinyCC directory    $tccdir
















--- tcc-0.9.26.orig/tcc.h	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1tcl/tcc.h	2014-05-01 19:50:24.973630534 -0500
@@ -23,6 +23,9 @@
 
 #define _GNU_SOURCE
 #include "config.h"
+#ifdef HAVE_TCL_H
+#  include <tcl.h>
+#endif
 
 #ifdef CONFIG_TCCBOOT
 #include "tccboot.h"























>
|
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
..
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
diff -uNr tcc-0.9.26.orig/configure tcc-0.9.26-1tcl/configure
--- tcc-0.9.26.orig/configure	2013-02-15 09:24:00.000000000 -0500
+++ tcc-0.9.26-1tcl/configure	2014-05-05 12:35:23.109943527 -0400
@@ -43,6 +43,7 @@
 tcc_libpaths=""
 tcc_crtprefix=""
 tcc_elfinterp=""
+tcc_tcl_path=""
 tcc_lddir=
 confvars=
................................................................................
+		fi
+	done
+fi
+
 cat <<EOF
 Binary  directory   $bindir
 TinyCC directory    $tccdir
diff -uNr tcc-0.9.26.orig/libtcc.c tcc-0.9.26-1tcl/libtcc.c
--- tcc-0.9.26.orig/libtcc.c	2013-02-15 09:24:00.000000000 -0500
+++ tcc-0.9.26-1tcl/libtcc.c	2014-05-05 13:01:47.556096371 -0400
@@ -981,6 +981,11 @@
     tcc_define_symbol(s, "__WCHAR_TYPE__", "int");
 #endif
 
+    /* Tcl defines */
+#ifdef USE_TCL_STUBS
+    tcc_define_symbol(s, "USE_TCL_STUBS", "1");
+#endif
+
 #ifndef TCC_TARGET_PE
     /* glibc defines */
     tcc_define_symbol(s, "__REDIRECT(name, proto, alias)", "name proto __asm__ (#alias)");
diff -uNr tcc-0.9.26.orig/tcc.h tcc-0.9.26-1tcl/tcc.h
--- tcc-0.9.26.orig/tcc.h	2013-02-15 09:24:00.000000000 -0500
+++ tcc-0.9.26-1tcl/tcc.h	2014-05-05 12:35:23.111943547 -0400
@@ -23,6 +23,9 @@
 
 #define _GNU_SOURCE
 #include "config.h"
+#ifdef HAVE_TCL_H
+#  include <tcl.h>
+#endif
 
 #ifdef CONFIG_TCCBOOT
 #include "tccboot.h"
diff -uNr tcc-0.9.26.orig/tccrun.c tcc-0.9.26-1tcl/tccrun.c
--- tcc-0.9.26.orig/tccrun.c	2013-02-15 09:24:00.000000000 -0500
+++ tcc-0.9.26-1tcl/tccrun.c	2014-05-05 13:06:41.105088994 -0400
@@ -697,14 +697,17 @@
 
 /* add the symbol you want here if no dynamic linking is done */
 static TCCSyms tcc_syms[] = {
-#if !defined(CONFIG_TCCBOOT)
 #define TCCSYM(a) { #a, &a, },
+#if !defined(CONFIG_TCCBOOT)
     TCCSYM(printf)
     TCCSYM(fprintf)
     TCCSYM(fopen)
     TCCSYM(fclose)
-#undef TCCSYM
 #endif
+#ifdef USE_TCL_STUBS
+    TCCSYM(tclStubsPtr)
+#endif
+#undef TCCSYM
     { NULL, NULL },
 };
 

Deleted build/tcc-patches/0.9.26/tcc-0.9.26-win32useopenlibs.diff version [44e95e05fe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
diff -uNr tcc-0.9.26.orig/tccpe.c tcc-0.9.26-1win32useopenlibs/tccpe.c
--- tcc-0.9.26.orig/tccpe.c	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1win32useopenlibs/tccpe.c	2014-05-04 02:20:25.285150002 -0500
@@ -38,6 +38,9 @@
 # define ADDR3264 DWORD
 #endif
 
+#ifdef TCC_IS_NATIVE
+#include <psapi.h>
+#endif
 #ifdef _WIN32
 void dbg_printf (const char *fmt, ...)
 {
@@ -831,7 +834,27 @@
                     if (dllref) {
                         if ( !dllref->handle )
                             dllref->handle = LoadLibrary(dllref->name);
-                        v = (ADDR3264)GetProcAddress(dllref->handle, name);
+                        if (dllref->handle) {
+                            v = (ADDR3264)GetProcAddress(dllref->handle, name);
+                        }
+                    }
+                    if (!v) {
+                        HANDLE cur_proc = GetCurrentProcess();
+                        HMODULE *modules;
+                        DWORD needed, i;
+
+                        needed = 0;
+                        EnumProcessModules(cur_proc, NULL, 0, &needed);
+                        modules = tcc_malloc(needed);
+                        if (EnumProcessModules(cur_proc, modules, needed, &needed)) {
+                            for (i = 0; i < needed / sizeof(HMODULE); i++) {
+                                v = (ADDR3264)GetProcAddress(modules[i], name);
+                                if (v) {
+                                    break;
+                                }
+                            }
+                        }
+                        tcc_free(modules);
                     }
                     if (!v)
                         tcc_error_noabort("undefined symbol '%s'", name);
@@ -1209,9 +1232,35 @@
 
             const char *name = symtab_section->link->data + sym->st_name;
             unsigned type = ELFW(ST_TYPE)(sym->st_info);
-            int imp_sym = pe_find_import(pe->s1, sym);
+            int imp_sym;
             struct import_symbol *is;
 
+            imp_sym = pe_find_import(pe->s1, sym);
+            if (0 == imp_sym) {
+                HANDLE cur_proc = GetCurrentProcess();
+                HMODULE *modules;
+                DWORD needed, i;
+                const char *symname;
+                void *addr;
+
+                symname = pe_export_name(pe->s1, sym);
+
+                needed = 0;
+                EnumProcessModules(cur_proc, NULL, 0, &needed);
+                modules = tcc_malloc(needed);
+                if (EnumProcessModules(cur_proc, modules, needed, &needed)) {
+                    for (i = 0; i < needed / sizeof(HMODULE); i++) {
+                        addr = GetProcAddress(modules[i], symname);
+                        if (addr) {
+                            put_elf_sym( pe->s1->dynsymtab_section, (ADDR3264) addr, sizeof(addr), ELFW(ST_INFO)(STB_GLOBAL, STT_OBJECT), 0, SHN_UNDEF, symname);
+                            imp_sym = pe_find_import(pe->s1, sym);
+                            break;
+                        }
+                    }
+                }
+                tcc_free(modules);
+            }
+
             if (0 == imp_sym)
                 goto not_found;
 
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<