aboutsummaryrefslogtreecommitdiff
path: root/tcc.h
Commit message (Collapse)AuthorAgeFilesLines
...
* tccpp: Fix token pastingMichael Matz2016-12-151-0/+1
| | | | | | | | | See testcase. We must always paste tokens (at least if not currently substing a normal argument, which is a speed optimization only now) but at the same time must not regard a ## token coming from argument expansion as the token-paste operator, nor if we constructed a ## token due to pasting itself (that was already checked by pp/01.c).
* Fix initializing members multiple timesMichael Matz2016-12-151-0/+2
| | | | | | | When intializing members where the initializer needs relocations and the member is initialized multiple times we can't allow that to lead to multiple relocations to the same place. The last one must win.
* Support local register variablesMichael Matz2016-12-151-3/+5
| | | | | | | | | Similar to GCC a local asm register variable enforces the use of a specified register in asm operands (and doesn't otherwise matter). Works only if the variable is directly mentioned as operand. For that we now generally store a backpointer from an SValue to a Sym when the SValue was the result of unary() parsing a symbol identifier.
* x86_64: Add -mno-sse optionMichael Matz2016-12-151-0/+3
| | | | | This disables generation of any SSE instructions (in particular in stdarg function prologues). Necessary for kernel compiles.
* x86-64: relocation addend is 64bitMichael Matz2016-12-151-2/+2
| | | | | | | | Some routines were using the wrong type (int) in passing addends, truncating it. This matters when bit 31 isn't set and the high 32 bits are set: the truncation would make it unsigned where in reality it's signed (happen e.g. on the x86-64 with it's load address at top-2GB).
* tccasm: Support refs to anon symbols from asmMichael Matz2016-12-151-0/+1
| | | | | | | This happens when e.g. string constants (or other static data) are passed as operands to inline asm as immediates. The produced symbol ref wouldn't be found. So tighten the connection between C and asm-local symbol table even more.
* tccasm: Don't ignore # in preprocessor directivesMichael Matz2016-12-151-0/+6
| | | | | | | Our preprocessor throws away # line-comments in asm mode. It did so also inside preprocessor directives, thereby removing stringification. Parse defines in non-asm mode (but retain '.' as identifier character inside macro definitions).
* Fix access-after-free with statement expressionsMichael Matz2016-12-151-1/+1
| | | | | | | | | | | | The return value of statement expressions might refer to local symbols, so those can't be popped. The old error message always was just a band-aid, and since disabling it for pointer types it wasn't effective anyway. It also never considered that also the vtop->sym member might have referred to such symbols (see the testcase with the local static, that used to segfault). For fixing this (can be seen better with valgrind and SYM_DEBUG) simply leave local symbols of stmt exprs on the stack.
* enums and ints are compatibleMichael Matz2016-12-151-1/+2
| | | | | | | But like GCC do warn about changes in signedness. The latter leads to some changes in gen_assign_cast to not also warn about unsigned* = int* (where GCC warns, but only with extra warnings).
* inline asm: accept concatenated strings in constraintsMichael Matz2016-12-151-0/+1
| | | | | This really should be handled implicitly in the preprocessor, but for now this is enough.
* x86-64-asm: Accept expressions for .quadMichael Matz2016-12-151-0/+3
| | | | | The x86-64 target has 64bit relocs, and hence can accept generic expressions for '.quad'.
* Accept more asm expressionsMichael Matz2016-12-151-0/+1
| | | | | | In particular subtracting a defined symbol from current section makes the value PC relative, and .org accepts symbolic expressions as well, if the symbol is from the current section.
* tccasm: Implement .pushsection and .popsectionMichael Matz2016-12-151-2/+2
|
* Implement -include cmdline optionMichael Matz2016-12-151-0/+4
| | | | | | This option includes a file as if '#include "file"' is the first line of compiled files. It's processed after all -D/-U options and is processed per input file.
* tccelf: some linker cleanupgrischka2016-12-151-18/+11
| | | | | | | | | | - generate and use SYM@PLT for plt addresses - get rid of patch_dynsym_undef hack (no idea what it did on FreeBSD) - use sym_attrs instead of symtab_to_dynsym - special case for function pointers into .so on i386 - libtcc_test: test tcc_add_symbol with data object - move target specicic code to *-link.c files - add R_XXX_RELATIVE (needed for PE)
* Use functions to get relocation infoThomas Preud'homme2016-12-101-20/+14
| | | | | | | MSVC does not support array designator so cannot compile source using relocs_info. This commit replace the relocs_info array into a set of functions, each returning the value given by a given field of the struct reloc_info.
* Remove now useless pltoff_addend reloc infoThomas Preud'homme2016-12-101-3/+2
| | | | | | Last use for pltoff_addend field of relocs_info array was removed in commit 25927df3b75c5ce2b64ab8acdcc5974b4e1c89c1. It is now useless so this commit removes it and all initialization related to it.
* Error on unrecognized relocationsThomas Preud'homme2016-12-051-1/+2
|
* Fix relocs_info declaration in tcc.hThomas Preud'homme2016-12-051-1/+6
| | | | | | | | | C standard specifies that array should be declared with a non null size or with * for standard array. Declaration of relocs_info in tcc.h was not respecting this rule. This commit add a R_NUM macro that maps to the R_<ARCH>_NUM macros and declare relocs_info using it. This commit also moves all linker-related macros from <arch>-gen.c files to <arch>-link.c ones.
* Control symbol table of which to relocate symbolsThomas Preud'homme2016-12-031-1/+1
| | | | Pass pointer to symbol table to relocate the symbols of in relocate_syms
* Allow to get sym attr and fail if no entryThomas Preud'homme2016-12-031-2/+4
| | | | | | Change alloc_sym_attr into get_sym_attr and add a parameter to control whether to allocate a new symattr structure or return NULL if symbol is not found;
* Make build_got_entries more target independentThomas Preud'homme2016-12-031-0/+20
| | | | | Factor most of common logic between targets in build_got_entries by defining target specific info into structures in the backends.
* Do section relocation in architecture backendThomas Preud'homme2016-12-031-0/+5
|
* Improve put_got_entry doc and structureThomas Preud'homme2016-12-031-0/+3
|
* Rename add_elf_sym to set_elf_symThomas Preud'homme2016-12-031-1/+1
| | | | | | | | | | add_elf_sym is a confusing name because it is not clear what the function does compared to put_elf_sym. As a matter of fact, put_elf_sym also adds a symbol in a symbol table. Besides, "add_elf_sym" fails to convey that the function can be used to update a symbol (for instance its value). "set_elf_sym" seems like a more appropriate name: it will set a symbol to a given set of properties (value, size, etc.) and create a new one if non exist for that name as one would expect.
* Implement gcc bitfield algorithm; add -mms-bitfieldsDavid Mertens2016-11-281-0/+1
|
* tccelf: introduce add32/64le()grischka2016-11-201-0/+6
|
* remove warningsThomas Stalder2016-11-131-1/+1
|
* tccgen: fix inline_functions double free fixgrischka2016-11-111-1/+2
|
* tccgen: inline_functions double free fixgrischka2016-11-111-1/+1
| | | | | | Fix double free of the inline function token_string which could happen when an error/longjmp occurred while compiling the inline function.
* lib/libtcc1.c: cleanupgrischka2016-10-191-1/+1
| | | | | | | - remove #include dependencies from libtcc1.c for easier cross compilation - clear_cache only on ARM - error-message for mprotect failure
* tccrun/win64: cleanup runtime function tablegrischka2016-10-191-7/+3
| | | | | | | | | | | | | | - call RtlDeleteFunctionTable (important for multiple compilations) - the RUNTIME_FUNCTION* is now at the beginning of the runtime memory. Therefor when tcc_relocate is called with user memory, this should be done manually before it is free'd: RtlDeleteFunctionTable(*(void**)user_mem); [ free(user_mem); ] - x86_64-gen.c: expand char/short return values to int
* configure: --triplet= option, Makefile: cleanupgrischka2016-10-171-18/+13
|
* tccpp_new/delete and other cleanupsgrischka2016-10-171-38/+38
|
* tccgen/tccelf: move code from libtcc.cgrischka2016-10-151-26/+33
|
* Start support of OpenBSD, tcc compiler can be produced from source treeChristian Jullien2016-10-151-1/+3
|
* tccpp : "tcc -E -P" : suppress empty linesgrischka2016-10-091-73/+35
| | | | | | | | | Also: - regenerate all tests/pp/*.expect with gcc - test "insert one space" feature - test "0x1E-1" in asm mode case - PARSE_FLAG_SPACES: ignore \f\v\r better - tcc.h: move some things
* Misc. fixesgrischka2016-10-051-3/+6
| | | | | | | | | | | | | | | | | | | | Makefile : - do not 'uninstall' peoples /usr/local/doc entirely libtcc.c : - MEM_DEBUG : IDE-friendly output "file:line: ..." - always ELF for objects tccgen.c : - fix memory leak in new switch code - move static 'in_sizeof' out of function profiling : - define 'static' to empty resolve_sym() : - replace by dlsym() win32/64: fix R_XXX_RELATIVE fixme - was fixed for i386 already in 8e4d64be2fc1d707c7800c5096f6e0ea22cbd - do not -Lsystemdir if compiling to .o
* tccgen: arm/i386: save_reg_upstackgrischka2016-10-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tccgen.c:gv() when loading long long from lvalue, before was saving all registers which caused problems in the arm function call register parameter preparation, as with void foo(long long y, int x); int main(void) { unsigned int *xx[1], x; unsigned long long *yy[1], y; foo(**yy, **xx); return 0; } Now only the modified register is saved if necessary, as in this case where it is used to store the result of the post-inc: long long *p, v, **pp; v = 1; p = &v; p[0]++; printf("another long long spill test : %lld\n", *p); i386-gen.c : - found a similar problem with TOK_UMULL caused by the vstack juggle in tccgen:gen_opl() (bug seen only when using EBX as 4th register)
* configure: fix tcc_lddir, cpugrischka2016-10-031-0/+2
| | | | ... and other minor cosmetic fixes
* Revert "-fnormalize-inc-dirs"grischka2016-10-011-1/+0
| | | | | | | Too much code. gcc 3.x doesn't have that either. This reverts commit 41785a0bf9d505a3647a10ddc330417f52fd4528. This reverts commit 21665f433890e2038626f0b3123b189a62a67dc9.
* build: revert Makefiles to 0.9.26 state (mostly)grischka2016-10-011-3/+8
| | | | | | | | | | | | Except - that libtcc1.a is now installed in subdirs i386/ etc. - the support for arm and arm64 - some of the "Darwin" fixes - tests are mosly unchanged Also - removed the "legacy links for cross compilers" (was total mess) - removed "out-of-tree" build support (was broken anyway)
* libtcc: reimplement option -Wl,[-no]-whöle-archivegrischka2016-10-011-6/+14
| | | | - taking advantage of previous commit "incremental -Wl parsing"
* libtcc: -Wl,... incremental parsinggrischka2016-10-011-4/+1
| | | | parse -Wl linker options immediately
* Revert "output all sections if we produce an executable file"grischka2016-10-011-1/+0
| | | | | | | | | -- Not a fix This reverts commit 089ce6235c99638ad4542a57af4d09e2be0efc88. Revert "handle a -s option by executing sstrip/strip program" -- related, not a fix. This reverts commit 5cd4393a542ef4c64df7dcbb3fbe3a629666239d.
* libtcc: filetype cleanupgrischka2016-10-011-5/+14
| | | | - does not change signature of tcc_add_file
* tccpp: cleanupgrischka2016-10-011-93/+48
| | | | | | | | | | | | | | | | - "utf8 in identifiers" from 936819a1b90f2618bb3f86730189cf2895948ba0 - CValue: remove member str.data_allocated - make tiny allocator private to tccpp - allocate macro_stack objects on heap because otherwise it could crash after error/setjmp in preprocess_delete():end_macro() - mov "TinyAlloc" defs to tccpp.c - define_push: take int* str again
* libtcc: cleanup @listfilegrischka2016-10-011-11/+5
| | | | | | | | | Also: - allow more than one item per line - respect "quoted items" and escaped quotes \" (also for LIBTCCAPI tcc_setoptions) - cleanup some copy & paste
* libtcc: cleanup -x<filetype> switch codegrischka2016-10-011-1/+5
| | | | | Abusing filename[0] as type is just too much of a hack. -- From 05364072042ff37904a7b0b14cdd85a1ea1ca11d
* tccpp: #pragma once: make it workgrischka2016-10-011-2/+2
| | | | | | | | | | | after several "fixes" and "improvements" b3782c3cf5e66f74207303c381a305daabccdb12 5fb57bead41cd3a84f0aa3f98d00b5fe5de25a08 feature did not work at all - Use 'once' flag, not 'ifndef_macro' - Ignore filename letter case on _WIN32 - Increment global pp_once for each compilation