aboutsummaryrefslogtreecommitdiff
path: root/libtcc.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove some unused-parameter lintLarry Doolittle2017-05-081-0/+3
| | | | | | | | Mark TCCState parameter as unused in tcc_undefine_symbol(), tcc_add_symbol(), tcc_print_stats(), asm_get_local_label_name(), use_section1(), tccpp_delete(), tcc_tool_ar(), tcc_tool_impdef(), and tcc_tool_cross(). Also mark it unused in tcc_add_bcheck() unless CONFIG_TCC_BCHECK. Remove it entirely in ld_next().
* Spelling fixes in C comments onlyLarry Doolittle2017-05-071-2/+2
|
* Simple-minded fix for bug #50847Larry Doolittle2017-04-251-0/+1
| | | | | | bug #50847: #line directive corrupts #include search path Keep a second copy of the filename, that isn't changed by the #line directive, and use that on the initial search path for #include files.
* final adjustments for releasegrischka2017-04-251-17/+10
| | | | | | | | | | | | | | | | | | | | | - configure/Makefiles: minor adjustments - build-tcc.bat: add -static to gcc options (avoids libgcc_s*.dll dependency with some mingw versions) - tccpe.c/tcctools.c: eliminate MAX_PATH (not available for cross compilers) - tccasm.c: use uint64_t/strtoull in unary() (unsigned long sometimes is only uint32_t, as always on windows) - tccgen.c: Revert (f077d16c) "tccgen: gen_cast: cast FLOAT to DOUBLE" Was a rather experimental, tentative commit, not really necessary and somewhat ugly too. - cleanup recent osx support: - Makefile/libtcc.c: cleanup copy&paste code - tccpp.c: restore deleted function
* tcc: early OSX native supportAndrei Warkentin2017-04-251-2/+17
| | | | | | | | | | | | - build scripts - working '-run' mode, e.g.: ./tcc -B. -I./include -I. -I.. -D_ANSI_SOURCE -run examples/ex1.c Note: we don't bother parsing Mach-O/Fat images yet. We blindly dlopen the image. Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
* Add support of musl-libcMarc Vertes2017-04-201-0/+4
| | | | The port is functional. Bound checking is not supported yet.
* tccgen/win32: let __declspec(dllimport) imply externgrischka2017-04-041-1/+5
| | | | | | | | | | | | | | | | | | | | | | | Also, retain storage qualifiers in type_decl, in particular also for function pointers. This allows to get rid of this very early hack in decl() type.t |= (btype.t & VT_STATIC); /* Retain "static". */ which was to fix the case of int main() { static int (*foo)(); ... Also: - missing __declspec(dllimport) is an error now - except if the symbol is "_imp__symbol" - demonstrate export/import of data in the dll example (while 'extern' isn't strictly required with dllimport anymore) - new function 'patch_storage()' replaces 'weaken_symbol()' and 'apply_visibility()' - new function 'update_storage()' applies storage attributes to Elf symbols. - put_extern_sym/2 accepts new pseudo section SECTION_COMMON - add -Wl,-export-all-symbols as alias for -rdynamic - add -Wl,-subsystem=windows for mingw compatibility - redefinition of 'sym' error for initialized global data
* cross-compilers: allow individual configurationgrischka2017-02-231-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-19/+0
| | | | | | | | | | | | | | | 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/+4
|
* tcctools.c: integrate tiny_libmaker/_impdefgrischka2017-02-181-82/+128
| | | | | | | | | | | | | | 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/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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(-)
* win32: adjust new unicode supportgrischka2017-02-181-3/+0
| | | | | | | | | | | | | | | | | | | - lib/Makefile: add (win)crt1_w.o - crt1.c/_runtmain: return to tcc & only use for UNICODE (because it might be not 100% reliable with for example wildcards (tcc *.c -run ...) - tccrun.c/tccpe.c: load -run startup_code only if called from tcc_run(). Otherwise main may not be defined. See libtcc_test.c - tests2/Makefile: pass extra options in FLAGS to allow overriding TCC Also: - tccpe.c: support weak attribute. (I first tried to solve the problem above by using it but then didn't)
* mems & leaksgrischka2017-02-131-4/+15
| | | | | | | | | | | | - define_start: set above preprocess_start because now preprocess_start is defining macros. - free "cmd_include_files" - free defines always (after error-longjmps) - close all files (after error-longjmps) - tccpe.c: free imports always - libtcc.c: call tcc_memstats only after all states have been deleted.
* fixes & cleanupsgrischka2017-02-131-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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 ...
* libtcc: support multiple -Wl,-rpath=...'sgrischka2017-02-111-7/+11
|
* tcc: don't use pstrcpy, fix win32 spanwn quotinggrischka2017-02-081-4/+4
| | | | | | | | | | | | - 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.
* win32: support "-Wl,--large-address-aware" optionPavlas, Zdenek2016-12-301-0/+2
|
* tests: OOT build fixes etc.grischka2016-12-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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-177/+124
| | | | | | | | | | | 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-10/+13
| | | | | | | | | | | | | 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
* Handle multiple -O optionsMichael Matz2016-12-151-3/+5
| | | | the last one wins, i.e. "-O2 -O0" does _not_ set __OPTIMIZ__.
* x86_64: Add -mno-sse optionMichael Matz2016-12-151-2/+13
| | | | | This disables generation of any SSE instructions (in particular in stdarg function prologues). Necessary for kernel compiles.
* Handle __builtin_extract_return_addrMichael Matz2016-12-151-0/+3
| | | | | Our architectures don't need anything special for this builtin, just pass through the argument.
* Fix access-after-free with statement expressionsMichael Matz2016-12-151-2/+2
| | | | | | | | | | | | 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.
* Accept -Wp,argsMichael Matz2016-12-151-0/+6
| | | | | | | These are preprocessor cmdline arguments, but even in GCC they aren't specified but rather left as being subject to changes. Nobody should use them, but let's to a half-assed attempt at accepting them.
* Add --param, reject -mARG if ARG not 32 or 64Michael Matz2016-12-151-0/+4
|
* Implement -include cmdline optionMichael Matz2016-12-151-0/+6
| | | | | | 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.
* Free defines before gen_inline_functionsMichael Matz2016-12-151-2/+2
| | | | | | | | gen_inline_functions uses the macro facilities of the preprocessor, which would interact when macros would still be defined in a different pre-processor implementation I'm working on. So always free defines before generating inline functions, they are all macro expanded already.
* tccelf: some linker cleanupgrischka2016-12-151-1/+0
| | | | | | | | | | - 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)
* Do section relocation in architecture backendThomas Preud'homme2016-12-031-0/+5
|
* 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/+6
|
* tccrun/win64: cleanup runtime function tablegrischka2016-10-191-6/+2
| | | | | | | | | | | | | | - 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
* tccpp_new/delete and other cleanupsgrischka2016-10-171-42/+19
|
* system-hacks: define __GNUC__ for FreeBSDMichael Matz2016-10-171-10/+9
| | | | | | | | | | | | FreeBSDs system headers contain unconditional usage of macros like __aligned(x), which are only conditionally defined in sys/cdefs.h (conditional on __GNUC__ or __INTEL_COMPILER). Bug in FreeBSD, but as work-around we can define __GNUC__ which picks up these defs. [This also moves back the glibc defines we had before into the non-BSD ifdef branch]
* No 'Thread Storage Local' on FreeBSD with tcc.Christian Jullien2016-10-151-0/+2
|
* Backslash was missing after reindentation to let code be < 80 col.Christian Jullien2016-10-151-1/+1
|
* #define __GNUC__ = 2.1grischka2016-10-151-6/+19
| | | | | | | | | | __GNUC__ nowadays as macro seems to mean the "GNU C dialect" rather than the compiler itself. See also http://gcc.gnu.org/ml/gcc/2008-07/msg00026.html This patch will probably cause problems of various kinds but maybe we should try nonetheless.
* tccgen/tccelf: move code from libtcc.cgrischka2016-10-151-442/+96
|
* Add more OpenBSD support.Christian Jullien2016-10-151-1/+4
|
* Misc. fixesgrischka2016-10-051-9/+13
| | | | | | | | | | | | | | | | | | | | 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
* tccpp: no cache for include if #elif seengrischka2016-10-041-2/+0
| | | | | | | | #ifndef guards are cached, however after #elif on the same level, the file must be re-read. Also: preprocess asm as such even when there is no assembler (arm).
* configure: fix tcc_lddir, cpugrischka2016-10-031-3/+5
| | | | ... and other minor cosmetic fixes
* Revert "-fnormalize-inc-dirs"grischka2016-10-011-93/+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/+3
| | | | | | | | | | | | 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-82/+69
| | | | - taking advantage of previous commit "incremental -Wl parsing"
* libtcc: -Wl,... incremental parsinggrischka2016-10-011-34/+27
| | | | parse -Wl linker options immediately
* Revert "output all sections if we produce an executable file"grischka2016-10-011-2/+1
| | | | | | | | | -- 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.
* Revert part of "fix installation amd bcheck for Windows"grischka2016-10-011-10/+0
| | | | | | | tccelf.c : force linking bcheck by adding elf symbol __bound_init bcheck.c : use (size_t)1 for x86_64 Fixes 7e7e6148fdb4adbda936f80b5d4ac3d738908d95