aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Fix absolute memory referencesMichael Matz2017-11-151-6/+25
| | | | | | | | This properly fixes what 870271ea tried to fix. Absolute memory references can't use %rip relative addressing, and additionally, if the address doesn't fit 32bit (signed) it must be loaded via movabs. No good testcase added, it would require catching signals and still be unreliable.
* Revert "gen_addrpc32: absolute ptr needs *ABS* relocation"Michael Matz2017-11-141-1/+2
| | | | | | | | This reverts commit 870271ea071971002fa556e09e1873db316fa1a9. The commit is broken, you can't unconditionally emit a PC-relative relocation without a symbol. And if there's a symbol the addend need to be in the relocation, not the section.
* Win64/PE: Changed runtime function unwind info to be added after relocation, ↵janus.lt2017-11-041-4/+5
| | | | fixes SEH + long jmps
* fixed dylib typo in libtcc.cemekoi2017-10-191-1/+1
|
* various stuffgrischka2017-10-1130-654/+424
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | win32/Makefile ("for cygwin") removed - On cygwin, the normal ./configure && make can be used with either cygwin's "GCC for Win32 Toolchain" ./configure --cross-prefix=i686-w64-mingw32- or with an existing tcc: ./configure --cc=<old-tccdir>/tcc.exe tcctest.c: - exclude test_high_clobbers() on _WIN64 (does not work) tests2/95_bitfield.c: - use 'signed char' for ARM (where default 'char' is unsigned) tests: - remove -I "expr" diff option to allow tests with busybox-diff. libtcc.c, tcc.c: - removed -iwithprefix option. It is supposed to be combined with -iprefix which we don't have either. tccgen.c: - fix assignments and return of 'void', as in void f() { void *p, *q; *p = *q: return *p; } This appears to be allowed but should do nothing. tcc.h, libtcc.c, tccpp.c: - Revert "Introduce VIP sysinclude paths which are always searched first" This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1. The patch was giving tcc's system includes priority over -I which is not how it should be. tccelf.c: - add DT_TEXTREL tag only if text relocations are actually used (which is likely not the case on x86_64) - prepare_dynamic_rel(): avoid relocation of unresolved (weak) symbols tccrun.c: - for HAVE_SELINUX, use two mappings to the same (real) file. (it was so once except the RX mapping wasn't used at all). tccpe.c: - fix relocation constant used for x86_64 (by Andrei E. Warentin) - #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin. tccasm.c: - keep forward asm labels static, otherwise they will endup in dynsym eventually. configure, Makefile: - mingw32: respect ./configure options --bindir --docdir --libdir - allow overriding tcc when building libtcc1.a and libtcc.def with make XTCC=<tcc program to use> - use $(wildcard ...) for install to allow installing just a cross compiler for example make cross-arm make install - use name <target>-libtcc1.a build-tcc.bat: - add options: -clean, -b bindir
* Win: crt, initialize global __argc, __targv and _tenviron of msvcrtYX Hao2017-10-102-41/+34
| | | | | _tenviron: as far as possible, not in ASC '-run' mode. __argc and __targv are shortcuts for _tWinMain, when you want to use program parameters.
* Fix Windows++ compilation of previous (YX Hao, Joel Bodenmann)Steffen Nurpmeso2017-10-091-0/+2
|
* Introduce VIP sysinclude paths which are always searched firstSteffen Nurpmeso2017-10-035-9/+36
|
* Adjust va_list to work with muslSteffen Nurpmeso2017-09-302-2/+7
|
* tools directory no more exists, removed in win32 tarball Makefile target.Christian Jullien2017-09-291-1/+0
|
* Use more conventional punctuation for sequential assignmentsLarry Doolittle2017-09-251-6/+6
|
* freebsd: allow building tcc which targets windowsAvi Halachmi (:avih)2017-09-251-1/+2
| | | | | | | | | | | Currently tcc doesn't have a compile-time config indicating that the target is freebsd, and as a result, the tcc binary adds freebsh stuff to elf headers if the compile-time (of tcc) *host* is freebsd. Test also that the target is not PE while generating an elf header. This still likely fails (but untested) when tcc targets other non-freebsd systems on a freebsd system, but for now fix it only when targetting windows.
* Fix some spelling in documentationLarry Doolittle2017-09-241-5/+5
|
* Spelling fixesLarry Doolittle2017-09-2419-28/+28
| | | | Comments only, no change to functionality
* Convert two .c files to LF line endingsLarry Doolittle2017-09-242-317/+317
| | | | ... matching the other 157 .c files in the tree
* 'long' reviewgrischka2017-09-246-176/+164
| | | | | | | | | | | | | | | | | | | | | add some features for more complete 'long' support tcc.h: - use LONG_SIZE=4/8 instead of TCC_LONG_ARE_64_BIT tccgen.c: - add ptrdiff_type, update size_type - support shift and ?: operations - support long enum types - display 'long' from type_to_str - nwchar_t is unsigned short on windows - unrelated: use memcpy in init_putv for long doubles to avoid random bytes in the image (if tcc was compiled by gcc) for diff purposes. tccpp.c: - make parse_number return correct types - improve multi-character-constants 'XX' 'abcd' Changelog: - update
* gen_addrpc32: absolute ptr needs *ABS* relocationZdenek Pavlas2017-09-111-2/+1
| | | | | | | Dereferencing of absolute pointers is broken on x86_64, eg: *(int*)NULL does not segfault but returns -4 instead *(char*)(-10L << 20) does not return 0x55 (vsyscall page, push rbp)
* Add test case for fastcall calling conventionZhang Boyang2017-09-103-1/+278
|
* Add test case for AL/AX extending problemZhang Boyang2017-09-103-0/+53
|
* Add test case for wide char handling in wide string literalZhang Boyang2017-09-102-0/+13
|
* Fix calling function pointers casted from intergers in DLLZhang Boyang2017-09-091-11/+3
| | | | | | The code generated for "((void (*)(void))0x12345678)()" will be a single "CALL 0x12345678" in previous code. However, this will not work for DLLs, because "CALL imm" is PC related, DLL relocation will break the code. This commit fixed the problem by forcing TCC generates indirect CALLs in this situation.
* Fix AL/AX is not extended to EAX when calling indirectlyZhang Boyang2017-09-091-6/+8
| | | | | AL/AX should be extended to EAX when calling functions. However, the previous code did this only for direct calls, indirect calls were ignored. New code also avoid redundant code when generating JMP instruction. (i.e. expanding code should be generated with CALL instruction only)
* Fix wide char handling in wide string literalZhang Boyang2017-09-091-1/+67
| | | | | | This commit fixed the problem that TCC directly cast each byte in wide string literal to wchar_t, which is wrong when wide string literal contains real wide chars. It fixed the problem by assuming input charset is UTF-8, and wchar_t stores wide chars in UTF-16 (Windows) or UTF-32 (others). The UTF-8 decoder is coded according to The Unicode Standard Version 10.
* called function should pop the arguments when using fastcallZhang Boyang2017-08-211-3/+3
|
* Convert from ISO-8859-1 to UTF-8. See aa812e8.Edmund Grimley Evans2017-07-261-1/+1
|
* Revert "use int for ssize_t, (u)intptr_t instead of long in stddef.h"Matthias Gatto2017-07-262-10/+3
| | | | | | This reverts commit 52622c3c0365ad497ce1188e433ac5f0a721c283. Because 28b7c9 was right.
* Revert "simplify VT_LONG parsing"matthias2017-07-251-3/+3
| | | | | | | | | Too simple long parsion. Take me a long long long time to see my mistake, Sorry (long long long wasn't see as an error) This reverts commit a4cd2805f95e1369254762478883e91050f2cba1.
* Remove debug echo in Cygwin MakefileChristian Jullien2017-07-251-1/+1
|
* Update Cygwin Makefile to use -B. for bootstrapChristian Jullien2017-07-251-26/+26
|
* use int for ssize_t, (u)intptr_t instead of long in stddef.hMatthias Gatto2017-07-252-3/+10
|
* check that _Generic match 'signed long int' as 'long'Matthias Gatto2017-07-252-0/+4
|
* simplify VT_LONG parsingMatthias Gatto2017-07-251-3/+3
|
* Update Cygwin Makefile to work with recent changes about ONE_SOURCE and ↵Christian Jullien2017-07-251-5/+7
| | | | CONFG_TCCDIR
* define __SIZE_TYPE__ and __PTRDIFF_TYPE__ as unsigned int and int.Matthias Gatto2017-07-251-2/+2
| | | | | | | As long is now a qualifier, and because compare_type will notice that variables are not the same type, we can't use long as int anymore. So, I've redefine __SIZE_TYPE__ as unsigned int and __PTRDIFF_TYPE__ as int.
* remove inside_generic hackMatthias Gatto2017-07-242-7/+8
| | | | | define uint64_t and int64_t as 'long' instead of 'long long' when __LP64__ is define.
* tccgen: nodata_wanted fix, default ONE_SOURCE, etc...grischka2017-07-2325-163/+350
| | | | | | | | | | | | | | | | | | | | | | | | | tccgen.c: doubles need to be aligned, on ARM. The section_reserve() in init_putv does not do that. -D ONE_SOURCE: is now the default and not longer needed. Also, tcc.h now sets the default native target. These both make compiling tcc simple as "gcc tcc.c -o tcc -ldl" again. arm-asm.c: enable pseudo asm also for inline asm tests/tests2/Makefile: disable bitfield tests except on windows and x86_64 and don't generate-always tcc.c: fix a loop with -dt on errors configure: print compiler version (as recognized) tccpp.c: actually define symbols for tcc -dt clear static variables (needed for -dt or libtcc usage) 96_nodata_wanted.c: use __label__ instead of asm lib/files: use native symbols (__i386__ etc.) instead of TCC_TARGET_...
* mutiples fix for _Genericmatthias2017-07-215-23/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * check that _Generic don't match unsigned char * with char * this case is usefull as with -funsigned-char, 'char *' are unsigned * change VT_LONG so it's now a qualifier VT_LONG are never use for code generation, but only durring parsing state, in _Generic we need to be able to make diference between 'long' and 'long long' So VT_LONG is now use as a type qualifier, it's old behaviour is still here, but we can keep trace of what was a long and what wasn't * add TOK_CLONG and TOK_CULONG tcc was directly converting value like '7171L' into TOK_CLLONG or TOK_CINT depending of the machine architecture. because of that, we was unable to make diference between a long and a long long, which doesn't work with _Generic. So now 7171L is a TOK_CLONG, and we can handle _Generic properly * check that _Generic can make diference between long and long long * uncomment "type match twice" as it should now pass tests on any platforms * add inside_generic global the point of this variable is to use VT_LONG in comparaison only when we are evaluating a _Generic. problem is with my lastest patchs tcc can now make the diference between a 'long long' and a 'long', but in 64 bit stddef.h typedef uint64_t as typedef signed long long int int64_t and stdint.h as unsigned long int, so tcc break when stdint.h and stddef.h are include together. Another solution woud be to modifie include/stddef.h so it define uint64_t as unsigned long int when processor is 64 bit, but this could break some legacy code, so for now, VT_LONG are use only inside generc. * check that _Generic parse first argument correctly * check that _Generic evaluate correctly exresion like "f() / 2"
* tcc -dt -run ... : simpler is bettergrischka2017-07-2031-446/+323
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * -dt now with lowercase t * test snippets now separated by real preprocessor statements which is valid C also for other compilers #if defined test_xxx < test snippet x > #elif defined test_yyy < test snippet y > #elif ... #endif * simpler implementation, behaves like -run if no 'test_...' macros are seen, works with -E too * for demonstration I combined some of the small tests for errors and warnings (56..63,74) in "60_errors_and_warnings.c" Also: * libtcc.c: put tcc_preprocess() and tcc_assemble() under the setjmp clause to let them return to caller after errors. This is for -dt -E. * tccgen.c: - get rid of save/restore_parse_state(), macro_ptr is saved by begin_macro anyway, now line_num too. - use expr_eq for parsing _Generic's controlling_type - set nocode_wanted with const_wanted. too, This is to keep VT_JMP on vtop when parsing preprocessor expressions. * tccpp.c: tcc -E: suppress trailing whitespace from lines with comments (that -E removes) such as NO_GOTPLT_ENTRY,\t /* never generate ... */
* fix typo sellector -> selectorMatthias Gatto2017-07-181-1/+1
|
* fix typo: march -> matchmatthias2017-07-181-1/+1
|
* unqualify volatile in _Generic type checkingMatthias Gatto2017-07-181-0/+1
|
* Fix cross compilersMichael Matz2017-07-162-0/+4
| | | | Only native compilers support -run and hence the new -dT.
* tccgen: nodata_wantedgrischka2017-07-1610-85/+329
| | | | | | | | | | | | | | | | | | | | | | | | The existing variable 'nocode_wanted' is now used to control output of static data too. So... (nocode_wanted == 0) code and data (normal within functions) (nocode_wanted < 0) means: no code, but data (global or static data) (nocode_wanted > 0) means: no code and no data (code and data suppressed) (nocode_wanted & 0xC0000000) means: we're in declaration of static data Also: new option '-dT' to be used with -run tcc -dT -run file.c This will look in file.c for certain comment-boundaries: /*-* test-xxx: ...some description */ and then for each test below run it from memory. This way various features and error messages can be tested with one single file. See 96_nodata_wanted.c for an example. Also: tccgen.c: one more bitfield fix
* #pragma comment(option,"-..."), bitfields test, etc...grischka2017-07-1410-54/+475
| | | | | | | | | | | | | | | | | | tccpp.c: * #pragma comment(option,"-some-option") to set commandline option from C code. May work only for some options. libtcc.c: * option "-d1..9": sets a 'g_debug' global variable. (for development) tests2/Makefile: * new make targets: tests2.37 / tests2.37+ run single test from tests2, optionally update .expect * new variable GEN-ALWAYS to always generate certain .expects * bitfields test tccgen.c: * bitfields: fix a bug and improve slightly more * _Generic: ignore "type match twice"
* Fix function typesMichael Matz2017-07-143-11/+42
| | | | | various cases of function type uses were broken by recent attribute refactoring, this fixes and adds testcases for them.
* tccasm: Fix local statics referenced from asmsMichael Matz2017-07-102-0/+36
| | | | | | | | | | | The assembler uses the ->sym_scope member to walk up the symbols until finding a non-automatic symbol. Since reordering the members of Sym the sym_scope member contains a scope even for local statics. Formerly the use of asm_label for statics was implicitely clearing sym_scope, now we have to do that explicitely. Add a testcase for that, and one I encountered when moving the clearing of sym_scope too deep into the call chain (into put_extern_sym).
* Fix statement exprs returning a local labelMichael Matz2017-07-104-6/+16
| | | | | | Like returned local variables also labels local to a statement expression can be returned, and so their symbols must not be immediately freed (though they need to be removed from the symbol table).
* enums: Accept GNU extensionMichael Matz2017-07-103-2/+46
| | | | See testcase. Happens e.g. in the linux kernel.
* refactor bitfieldsgrischka2017-07-093-193/+384
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use 2 level strategy to access packed bitfields cleanly: 1) Allow to override the original declaration type with an auxilary "access type". This solves cases such as struct { ... unsigned f1:1; }; by using VT_BYTE to access f1. 2) Allow byte-wise split accesses using two new functions load/store_packed_bf. This solves any cases, also ones such as struct __attribute((packed)) _s { unsigned x : 12; unsigned char y : 7; unsigned z : 28; unsigned a: 3; unsigned b: 3; unsigned c: 3; }; where for field 'z': - VT_INT access from offset 2 would be unaligned - VT_LLONG from offset 0 would go past the total struct size (7) and for field 'a' because it is in two bytes and aligned access with VT_SHORT/INT is not possible. Also, static bitfield initializers are stored byte-wise always. Also, cleanup the struct_layout function a bit.
* refactor enumsgrischka2017-07-094-102/+107
| | | | | | Eliminate VT_ENUM as a basic type. Instead use the integral types VT_InT/VT_LLONG with an additional flag to indicate that it is an enum.