Commit Graph

277 Commits

Author SHA1 Message Date
grischka
0085c648f6 bcheck: restore malloc hooks when done 2009-07-18 21:54:47 +02:00
grischka
c4b7e77bbe accept option -x <lang> 2009-06-17 02:11:27 +02:00
grischka
67aebdd5b7 enable making tcc using libtcc 2009-05-11 18:46:02 +02:00
grischka
0a35f9d66e move static prototypes to libtcc.c 2009-05-11 18:45:56 +02:00
grischka
f9181416f6 move some global variables into TCCState 2009-05-11 18:45:44 +02:00
grischka
5c6509578e make tcc from tcc.c and libtcc from libtcc.c 2009-05-05 20:41:17 +02:00
grischka
b8f6e1ae30 move minor things from libtcc.c to other files 2009-05-05 20:30:39 +02:00
grischka
9dc9cbf319 move libtcc interface and helper functions to libtcc.c 2009-05-05 20:18:53 +02:00
grischka
0d1ed74102 move parser/generator to tccgen.c 2009-05-05 20:18:10 +02:00
grischka
805990b94e move preprocessor to tccpp.c 2009-05-05 20:17:49 +02:00
grischka
ae37bd5abc move declarations to tcc.h 2009-05-05 20:17:26 +02:00
grischka
e9e89ad699 enable backtrace only when it's supported 2009-04-18 18:39:27 +02:00
grischka
d165e87340 libtcc: new api tcc_set_lib_path 2009-04-18 15:08:03 +02:00
grischka
73ba078d2f tcc_relocate: return error and remove unused code 2009-04-18 15:08:03 +02:00
Shinichiro Hamaji
d36fea34e3 Call relocate_sym() before we return the offset, so user doesn't need to check the return value twice. 2009-04-18 15:08:03 +02:00
grischka
dd5630ff95 tcc -E: fix pasting empty tokens
/* test case */
#define t(x,y,z) x ## y ## z
int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
        t(10,,), t(,11,), t(,,12), t(,,) };

tcc -E: xpected result:
int j[] = { 123, 45, 67, 89,
 10, 11, 12, };
2009-04-18 15:08:02 +02:00
grischka
0f0ed4a8bf tcc -E: preserve spaces, alternative solution
/* test case */
#define STR(x) #x
#define MKSTR(x) STR(x)
MKSTR(-A-)
MKSTR(+ B +)

tcc -E: expected result:
"-A-"
"+ B +"
2009-04-18 15:08:02 +02:00
grischka
90697c4c56 CONFIG_TCC_STATIC: add dummy for dlclose 2009-04-18 15:08:02 +02:00
grischka
d62301b050 avoid warning uninitialized 2009-04-18 15:08:02 +02:00
Shinichiro Hamaji
9a7173bf69 x86-64: Fix tcc -run. We need extra memory for PLT and GOT.
Size of the extra buffer is too large for now.
2009-04-18 15:08:02 +02:00
grischka
e6ba81b012 get rid of 8 bytes memory leak 2009-04-18 15:08:02 +02:00
grischka
b1697be691 change tcc_add/get_symbol to use void* 2009-04-18 15:08:02 +02:00
grischka
795f67428e alternative int tcc_relocate(TCCState *s1, void *ptr); 2009-04-18 15:08:02 +02:00
grischka
9a8b2912ed TOK_builtin_malloc: alternative solution 2009-04-18 15:08:02 +02:00
Shinichiro Hamaji
39a4b859d4 x86-64: Fix cast from integers to pointers.
Now,

./tcc -run -DTCC_TARGET_X86_64 tcc.c -run tcctest.c

works!
2009-04-18 15:08:02 +02:00
Shinichiro Hamaji
83fd36333a Fixes for issues I've just found/introduced to x86 TCC.
- Cast from pointer to long long makes TCC output an error. Use cast to int before we apply shift operation for a pointer value.
- Removed test cases for casts from pointer to char/short because they produce warning.
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
be43c8e0ed x86-64: Cast from 64bit pointer to long long must not generate movslq. 2009-04-18 15:08:01 +02:00
grischka
a9c78d04f2 win32: accept uppercase filename suffixes 2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
b879ffa193 x86-64: There can be valid addresses which is greater than 0xc0000000. 2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
de3f0a46fe Fix for x86-64: The first and second arguments of memcpy must be pointers. 2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
2e9b57b6d0 Fix silly typos in the previous change. 2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
9fe28b610e x86-64: Make ABI for long double compatible with GCC.
- Now we use x87's stack top the long double return values.
- Add rc_fret and reg_fret, wrapper functions for RC_FRET and REG_FRET.
- Add a test case to check if strto* works OK.
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
fcf2e5981f x86-64: Combine buffers of sections before we call tcc_run().
- Now we can run tcc -run tcc.c successfully, though there are some bugs.
- Remove jmp_table and got_table and use text_section for got and plt entries.
- Combine buffers in tcc_relocate().
- Use R_X86_64_64 instead of R_X86_64_32 for R_DATA_32 (now the name R_DATA_32 is inappropriate...).
2009-04-18 15:08:01 +02:00
Shinichiro Hamaji
830b7533c9 Generate PIC code so that we can create shared objects properly.
- Add got_table in TCCState. This approach is naive and the distance between executable code and GOT can be longer than 32bit.
- Handle R_X86_64_GOTPCREL properly. We use got_table for TCC_OUTPUT_MEMORY case for now.
- Fix load() and store() so that they access global variables via GOT.
2009-04-18 15:08:01 +02:00
grischka
6c10429aa5 check for absolute include paths
Suggested by Sandor Zsolt <narkoskatona@yahoo.com>
2009-04-18 15:07:28 +02:00
grischka
29c8e1545a get rid of "free_section problem" with private sections 2009-04-18 15:07:28 +02:00
grischka
5818945ef6 accept "restrict" in array-decl (STDC 199901) 2009-04-18 15:07:27 +02:00
grischka
0e015988cc i386: apply "align=8 for doubles ..." for PE only 2009-04-18 15:07:27 +02:00
Shinichiro Hamaji
e6db5f5fb6 x86-64 bug fix: Use stack with alignment just like 32bit environments. 2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
ebb874e216 Remove multiple definition error caused by combination of x86-64 and va_list.
We need malloc and free to implement va_start and va_end.
Since malloc and free may be replaced by #define, we add __builtin_malloc and __builtin_free.
2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
6512d9e2ea Add check for invalid numbers.
If there are some characters after TCC parses a number, it is an error.

This bug was reported on list:

http://www.mail-archive.com/tinycc-devel@nongnu.org/msg02014.html
2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
af6cbc48d1 Fix overrun in decl_initializer_alloc.
This bug was reported on

http://lists.gnu.org/archive/html/tinycc-devel/2009-03/msg00035.html

This happens because parser of array initializer doesn't stop to read until semi-colon or comma.
2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
006c907da7 Code cleaning: utilize vpushll(). 2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
4f056031f4 Support long long bitfields for all architectures.
- Modified gv() and vstore(), added vpushll().
- Added a test case for long long bitfields.
- Tested on x86 and x86-64.
2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
ae607280c5 Allow long long as a type of bitfields on x86-64. 2009-04-18 15:07:08 +02:00
grischka
3116744bdd i386: align=8 for double and long long 2009-04-18 15:07:08 +02:00
grischka
b41fc95566 win32: fix for VC8Express compiler 2009-04-18 15:07:08 +02:00
Kirill Smelkov
00f0932760 tcc -E: preserve spaces (partial solution)
Recently I needed to trim storage space on an embedded distro which has
X.

X depend on cpp which is ~8MB in size as shipped in Debian, so the idea
was to remove cpp and use `tcc -E` instead where appropriate.

I've done this with the following 'hack' put inplace of /usr/bin/cpp :

    #!/bin/sh -e
    TCC=/home/kirr/local/tcc/bin/tcc
    last="${!#}"

    # hack to distinguish between '... -D...'  and '... file'
    if test -r "$last"; then
        exec $TCC -E "$@"
    else
        exec $TCC -E "$@" -
    fi

But the problem turned out to be in `tcc -E` inability to preserve
spaces between tokens. So e.g. the following ~/.Xresources

    XTerm*VT100*foreground: black
    ...

got translated to

    XTerm * VT100 * foreground : black

which is bad, bacause now X don't understand it.

Below is a newbie "fix" for the problem.

It still does not preserve spaces on macro expansion, but since the fix
cures original problem, I think it is at least one step forward.

Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
2009-04-18 15:07:08 +02:00
Alexander Egorenkov
5a044b67bb type_size function returned incorrect size
of multi dimensional arrays if dimension is divisable by 2
2009-04-18 15:07:08 +02:00
grischka
64147b346b fix constant optimization for unsigneds 2009-04-18 15:07:08 +02:00