Hello, all,
I'm having a small difficulty using tcc 0.9.26 to compile SQLite3 (both in Windows XP and 7), as the resulting executable crashes when I try to call the int sqlite3_initialize(void) function. The same code works like a charm using tcc 0.9.25.
Following is a command prompt session showing what I was able to discover about the problem:
------------------------------------------------------------------------------------------
d:\Usuários\fr22509>cd tcc-0.9.25
d:\Usuários\fr22509\tcc-0.9.25>dir
O volume na unidade D não tem nome.
O Número de Série do Volume é B605-C2BB
Pasta de d:\Usuários\fr22509\tcc-0.9.25
27/08/2013 11:46 <DIR> .
27/08/2013 11:46 <DIR> ..
27/08/2013 11:38 <DIR> doc
27/08/2013 11:38 <DIR> examples
27/08/2013 11:38 <DIR> include
27/08/2013 11:38 <DIR> lib
26/08/2013 17:24 4.999.045 sqlite3.c
20/05/2013 12:56 348.618 sqlite3.h
18/05/2009 09:25 135.168 tcc.exe
27/08/2013 07:56 103 test.c
18/05/2009 09:25 8.192 tiny_impdef.exe
18/05/2009 09:25 7.680 tiny_libmaker.exe
6 arquivo(s) 5.498.806 bytes
6 pasta(s) 386.337.153.024 bytes disponíveis
d:\Usuários\fr22509\tcc-0.9.25>type test.c
#include "sqlite3.h"
int
main (int argc, char ** argv) {
sqlite3_initialize();
return 0;
}
d:\Usuários\fr22509\tcc-0.9.25>tcc -c sqlite3.c
sqlite3.c:20250: warning: assignment makes pointer from integer without a cast
sqlite3.c:44872: warning: assignment makes pointer from integer without a cast
sqlite3.c:77174: warning: assignment makes pointer from integer without a cast
d:\Usuários\fr22509\tcc-0.9.25>tcc -o test.exe sqlite3.o test.c
d:\Usuários\fr22509\tcc-0.9.25>test.exe && echo success
success
d:\Usuários\fr22509\tcc-0.9.25>tcc -g -c sqlite3.c
sqlite3.c:20250: warning: assignment makes pointer from integer without a cast
sqlite3.c:44872: warning: assignment makes pointer from integer without a cast
sqlite3.c:77174: warning: assignment makes pointer from integer without a cast
d:\Usuários\fr22509\tcc-0.9.25>tcc -g -o test.exe sqlite3.o test.c
d:\Usuários\fr22509\tcc-0.9.25>gdb test.exe
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) list
1 #include "sqlite3.h"
2
3 int
4 main (int argc, char ** argv) {
5 sqlite3_initialize();
6
7 return 0;
8 }
(gdb) run
Starting program: d:\Usuários\fr22509\tcc-0.9.25/test.exe
Program exited normally.
(gdb) quit
d:\Usuários\fr22509\tcc-0.9.25>objdump -h test.exe
test.exe: file format pei-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0009d228 00401000 00401000 00000400 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 0000a200 0049f000 0049f000 0009d800 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .stab 0007e3b4 004aa000 004aa000 000a7a00 2**2
CONTENTS, READONLY, DEBUGGING, NEVER_LOAD
3 .stabstr 00008cca 00529000 00529000 00125e00 2**0
CONTENTS, READONLY, DEBUGGING, NEVER_LOAD
d:\Usuários\fr22509\tcc-0.9.25>cd ..\tcc-0.9.26
d:\Usuários\fr22509\tcc-0.9.26>dir
O volume na unidade D não tem nome.
O Número de Série do Volume é B605-C2BB
Pasta de d:\Usuários\fr22509\tcc-0.9.26
27/08/2013 11:46 <DIR> .
27/08/2013 11:46 <DIR> ..
27/08/2013 11:38 <DIR> doc
27/08/2013 11:38 <DIR> examples
27/08/2013 11:38 <DIR> include
27/08/2013 11:38 <DIR> lib
27/08/2013 11:38 <DIR> libtcc
15/02/2013 09:26 128.512 libtcc.dll
26/08/2013 17:24 4.999.045 sqlite3.c
20/05/2013 12:56 348.618 sqlite3.h
15/02/2013 09:26 14.848 tcc.exe
27/08/2013 07:57 103 test.c
15/02/2013 09:26 11.776 tiny_impdef.exe
15/02/2013 09:26 11.776 tiny_libmaker.exe
7 arquivo(s) 5.514.678 bytes
7 pasta(s) 386.334.486.528 bytes disponíveis
d:\Usuários\fr22509\tcc-0.9.26>type test.c
#include "sqlite3.h"
int
main (int argc, char ** argv) {
sqlite3_initialize();
return 0;
}
d:\Usuários\fr22509\tcc-0.9.26>tcc -c sqlite3.c
d:\Usuários\fr22509\tcc-0.9.26>tcc -o test.exe sqlite3.o test.c
d:\Usuários\fr22509\tcc-0.9.26>test.exe && echo success
d:\Usuários\fr22509\tcc-0.9.26>tcc -g -c sqlite3.c
d:\Usuários\fr22509\tcc-0.9.26>tcc -g -o test.exe sqlite3.o test.c
d:\Usuários\fr22509\tcc-0.9.26>gdb test.exe
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...The debugging information in `d:\
Usuários\fr22509\tcc-0.9.26/test.exe' is corrupted.
The file has a `.stabs' section, but no `.stabstr' section.
(gdb) list
No symbol table is loaded. Use the "file" command.
(gdb) run
Starting program: d:\Usuários\fr22509\tcc-0.9.26/test.exe
Program received signal SIGILL, Illegal instruction.
0x0049e891 in ?? ()
(gdb) quit
d:\Usuários\fr22509\tcc-0.9.26>objdump -h test.exe
test.exe: file format pei-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0009c300 00401000 00401000 00000400 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 0000a200 0049e000 0049e000 0009c800 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .stab 0007e7bc 004a9000 004a9000 000a6a00 2**2
CONTENTS, READONLY, DEBUGGING, NEVER_LOAD
3 .stabst 00009609 00528000 00528000 00125200 2**2
CONTENTS, READONLY, DEBUGGING, NEVER_LOAD
d:\Usuários\fr22509\tcc-0.9.26>cd ..
d:\Usuários\fr22509>
------------------------------------------------------------------------------------------
It seems like it compiles successfully, but generates corrupt code. Certainly the .stabstr section's name is missing its last character...
Thanks for the attention,
-Tiago
--
In those days, in those distant days, in those nights, in those remote nights, in those years, in those distant years...
- Gilgamesh, Enkidu and the Underworld