aboutsummaryrefslogtreecommitdiff
path: root/tcc.h
Commit message (Collapse)AuthorAgeFilesLines
* cross-compilers: allow individual configurationgrischka2017-02-231-27/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | since configure supports only native configuration a file 'cross-tcc.mak' needs to be created manually. It is included in the Makefile if present. # ---------------------------------------------------- # Example config-cross.mak: # # windows -> i386-linux cross-compiler # (it expects the linux files in <prefix>/i386-linux) ROOT-i386 = {B}/i386-linux CRT-i386 = $(ROOT-i386)/usr/lib LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include DEF-i386 += -D__linux__ # ---------------------------------------------------- Also: - use libtcc1-<target>.a instead of directories - add dummy arm assembler - remove include dependencies from armeabi.c/lib-arm64.c - tccelf/ld_add_file: add SYSROOT (when defined) to absolute filenames coming from ld-scripts
* tcc: re-enable correct option -r supportgrischka2017-02-201-5/+8
| | | | | | | | | | | | | | | Forgot about it. It allows to compile several sources (and other .o's) to one single .o file; tcc -r -o all.o f1.c f2.c f3.S o4.o ... Also: - option -fold-struct-init-code removed, no effect anymore - (tcc_)set_environment() moved to tcc.c - win32/lib/(win)crt1 minor fix & add dependency - debug line output for asm (tcc -c -g xxx.S) enabled - configure/Makefiles: x86-64 -> x86_64 changes - README: cleanup
* tcc -hh: show more optionsgrischka2017-02-181-0/+1
|
* tcctools.c: integrate tiny_libmaker/_impdefgrischka2017-02-181-7/+27
| | | | | | | | | | | | | | usage: tcc -ar [rcsv] lib files... tcc -impdef lib.dll [-v] [-o lib.def] also: - support more files with -c: tcc -c f1.c f2.c ... - fix a bug which caused tcc f1.c f2.S to produce no asm - allow tcc -ar @listfile too - change prototype: _void_ tcc_set_options(...) - apply -Wl,-whole-archive when a librariy is given as libxxx.a also (not just for -lxxx)
* -Wl, --enable-new-dtags for DT_RUNPATH instead of DT_RPATHSteffen Nurpmeso2017-02-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Today by accident i had to deal with linker problems of some software and found an issue that mentioned DT_RUNPATH, which mentioned that DT_RPATH is legacy and searched for $LD_LIBRARY_PATH, whereas the newer DT_RUNPATH is searched thereafter. Completely unencrypted! Well. For what's it worth, i for one am astonished because of course i want to override $LD_LIBRARY_PATH, but it surely has its merites, smart people came to the conclusion, did they. The attached diff below seems to be sufficient to support DT_RUNPATH instead of DT_RPATH with tcc(1). But i have no insight in what --enable-new-dtags is supposed to change in addition, so i wonder. Ciao! --steffen libtcc.c | 2 ++ tcc-doc.texi | 4 ++++ tcc.h | 1 + tccelf.c | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-)
* fixes & cleanupsgrischka2017-02-131-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - tccgen.c/tcc.h: allow function declaration after use: int f() { return g(); } int g() { return 1; } may be a warning but not an error see also 76cb1144ef91924c53c57ea71e6f67ce73ce1cc6 - tccgen.c: redundant code related to inline functions removed (functions used anywhere have sym->c set automatically) - tccgen.c: make 32bit llop non-equal test portable (probably not on C67) - dynarray_add: change prototype to possibly avoid aliasing problems or at least warnings - lib/alloca*.S: ".section .note.GNU-stack,"",%progbits" removed (has no effect) - tccpe: set SizeOfCode field (for correct upx decompression) - libtcc.c: fixed alternative -run invocation tcc "-run -lxxx ..." file.c (meant to load the library after file). Also supported now: tcc files ... options ... -run @ arguments ...
* tcc: don't use pstrcpy, fix win32 spanwn quotinggrischka2017-02-081-3/+3
| | | | | | | | | | | | - we're now exporting tcc_prefixed symbols from libtcc only - On windows, the msvcrt startup code would remove backslashes from commandline arguments such as -DFOO=\"foo\" which would appear in argv as -DFOO="foo" Therefor before passing these to spawnvp, we need to restore the backslashes.
* tccgen: factor out gfunc_returngrischka2017-02-081-2/+1
| | | | | | | Also: - on windows i386 and x86-64, structures of size <= 8 are NOT returned in registers if size is not one of 1,2,4,8. - cleanup: put all tv-push/pop/swap/rot into one place
* win32: support "-Wl,--large-address-aware" optionPavlas, Zdenek2016-12-301-0/+1
|
* tests: OOT build fixes etc.grischka2016-12-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | tests/Makefile: fix out-of-tree build issues Also: - win64: align(16) MEM_DEBUG user memory on win64 the struct jmp_buf in the TCCState structure which we allocate by tcc_malloc needs alignment 16 because the msvcrt setjmp uses MMX instructions. - libtcc_test.c: win32/64 need __attribute__((dllimport)) for extern data objects - tcctest.c: exclude stuff that gcc does not compile except for relocation_test() the other issues are mostly ASM related. We should probably check GCC versions but I have no idea which mingw/gcc versions support what and which don't. - lib/Makefile: use tcc to compile libtcc1.a (except on arm which needs arm-asm
* libtcc.c: -m option cleanupgrischka2016-12-181-1/+1
| | | | | | | | | | | handle mms-bitfields as sub-options of -m. (-mfloat-abi is still special because it requires arguments) tcc.c: help(): - list -mms-bitfields under 'Target specific options' libtcc.c/MEM_DEBUG - add check for past buffer writes
* tests: add memory leak testgrischka2016-12-181-0/+1
| | | | | | | | | | | | | Also ... tcctest.c: - exclude stuff that gcc doesn't compile on windows. libtcc.c/tccpp.c: - use unsigned for memory sizes to avoid printf format warnings - use "file:line: message" to make IDE error parsers happy. tccgen.c: fix typo
* Support large alignment requestsMichael Matz2016-12-151-1/+1
| | | | | | | | The linux kernel has some structures that are page aligned, i.e. 4096. Instead of enlarging the bit fields to specify this, use the fact that alignment is always power of two, and store only the log2 minus 1 of it. The 5 bits are enough to specify an alignment of 1 << 30.
* Fix 64bit enums and switch casesMichael Matz2016-12-151-3/+3
| | | | | | | See testcases. We now support 64bit case constants. At the same time also 64bit enum constants on L64 platforms (otherwise the Sym struct isn't large enough for now). The testcase also checks for various cases where sign/zero extension was confused.
* 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
|