Commit Graph

707 Commits

Author SHA1 Message Date
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
742cf05875 x86-64: Define make variable TARGET so that test2 and test3 use correct flag. 2009-04-18 15:08:02 +02:00
Shinichiro Hamaji
85d016b507 x86-64: Remove code for debug print.
Now, we concat buffers before relocation. So this only happens when users try creating >2GB binary.
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
51a7f163ad Work around for the issue TCC doesn't handle -2147483648 properly.
TCC produces code which is incompatible with GCC for the following code:

    printf("%lld\n", (long long)-2147483648);
    printf("%lld\n", (long long)-2147483649);

For now, just avoid using the corner value.
2009-04-18 15:08:01 +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
0e239e2ba5 Improve the test coverage: !val for float/double/long long f. 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
c80f81c199 tiny_libmaker: fix function array overflow 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
97072b3cd7 x86-64: Now TCC can create healthy shared objects from object files generated by GCC
- Handle R_X86_64_GOTPCREL.
- Output R_X86_64_RELATIVE reloc generated from R_X86_64_64.
2009-04-18 15:07:10 +02:00
Shinichiro Hamaji
754b0beb7d x86-64 bug fix: Fix stab generation for x86-64.
The size of a stab entry is 12 bytes even in 64bit environments. We must use int instead of long to keep the size of stab entries.
2009-04-18 15:07:09 +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
06fa15fb99 x86-64: Save RDX and RCX before we use them as function parameters.
When the function call is indirect, these registers may be broken to load a function pointer.
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
040ef000e4 Better DLL support on x86-64.
- Add a macro TCC_OUTPUT_DLL_WITH_PLT.
-- Now, the DLL with PLT support works only on x86-64, but we may be able to support it on all architectures eventually.
- Define TCC_OUTPUT_DLL_WITH_PLT when target architecture is x86-64.
- Current status (x86-64):
-- Main program should be able to call functions in shared objects.
-- Main program should be able to use global variables in shared objects.
-- Shared objects should be able to call functions in main  program.
-- Shared objects can NOT use global variables in main program.
- To fix the last issue, we may need to add support of -fPIC option in our code generator.
2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
fe8f230ab6 First naive DLL support on x86-64.
This logic depends on x86_64-gen.c and doesn't work with objects compiled by GCC.
2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
b8a32d8d40 Generate PIC for addresses of symbols. 2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
7db1e69df2 Suppress noisy pointer signed-ness warnings on x86-64. 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
62e73da612 A uint64 bug fix on x86-64
64bit unsigned literal was handled as 32bit integer.
Added a unittest to catch this.
2009-04-18 15:07:08 +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
4a8c2229ce win32: allow user segments as writable & executable 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
Kirill Smelkov
6213d4b4b6 string_test: we should always use 'unsigned int' for b
As recently shown in fb0ac2 (s/int/unsigned/ since GCC 4.3.2 produces
code which doesn't stop)

comparing (signed) int variable to 0x80000000 is not idea for x86_64.

This is not a good idea for x86_32 either, because GCC 4.3.2 (the one in
Debian Lenny) rightly assumes that a signed int could be never
0x80000000, and thus removes the check from

    while (b != 0x80000000) {
        ...

completely.

If we want this check, we need b to be always 'unsigned'

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
grischka
7c3f19c079 fix data overflow with init_putv
The simplest code to reproduce this bug seems to be
    int a[][] = {{1,1,1,1,1,1,1}};
2008-12-02 02:36:27 +01:00
Shinichiro Hamaji
aa8d22e38e Add several test cases. 2008-12-02 02:32:52 +01:00