Enables code such as:
#undef NDEBUG
#include <assert.h>
#include <stdint.h>
static int st_x = 42;
static int st_x_ __attribute((alias("st_x")));
int main(void){ assert((uintptr_t)&st_x == (uintptr_t)&st_x_); }
which would previously fail with no compiler warnings. The limitation of
this is that the alias must be done (or redone) after an actual definition.
An alias done right after a later overridden tentative declaration won't
work (sufficient for my use case).
echo "void bugged() { do {} }" | tcc -run -
now produces the sensible: -:1: error: 'while' expected (got "}")
I believe (but am far from sure) that the additional use of &tokc is ok.
The testcases 22_floating_point and 24_math_library did not work with
make tcov-test
Add -lm for these in tests/tests2/Makefile
gcc -fanalyzer complains about tcc_malloc and tcc_realloc because
malloc(0) and realloc(ptr, 0) is not tested correctly.
configure:
- option --targetos=... for cross build
- cleanup
win32/build-tcc.bat:
- option -b <bindir>
- make 'libtcc1.a' and cross-prefix-libtcc1.a
(same convention as with makefile)
Makefile:
- streamline tcov-tests, help, etc.
workflow/build.xml: simplify
- using "windows-2019" runner (instead of windows-latest)
because its msys seems more complete and has no problems
with the 96_nodata_wanted.test either.
Changelog,TODO,USES,tcc-doc.texi: update
On windows, create a .pdb file with option "-g.pdb"
Such executables created by tcc can be debugged with
"ollydbg" or "x64dbg"
This currently relies on the 3rd party tool cv2pdb from
https://github.com/rainers/cv2pdb
which again relies on
mspdbsrv.exe mspdbcore.dll msobj80.dll mspdb80.dll
from a MSVC installation.
cv2pdb.exe + the ms* files may be put in the path or in the
same directory as tcc.exe.
libtcc.c:
- revert "Small patch to allow..." (someone's personal easteregg)
(see da3a763e97)
- check return value from macho_load_tbd/dylib
tcc.c:
- remove help for "not yet implemented" option
tccelf.c:
- check PIE's for "unresolved symbols"
tccgen.c:
- avoid int->double->int cast
(see a46372e910)
- fix constant propagation with pseudo long doubles
(must mask out VT_LONG from type)
- cleanup find_field() (again)
tccpp.c:
- disallow strings and double constants in #if expressions
win32/include/uchar.h:
- change file mode
using (modified) tcc_backtrace() instead.
Also
Also fix the original bug with doubles on x86_64.
(which was not caused by incr_offset() actually).
See 598134fff6
Also cleanup on_exit() stuff
From fef701b57f
The following targets are added:
testc / testc2.all / testc2.37 / testc2.37+ / testc2.37-
testcpp.all / make testcpp.17
This allows to check that the testcase(s) test the code modified.
See Makefile tests/pp/Makefile tests/tests2/Makefile
lib/tcov.c: Fix while loops with fgets.
tcc.h: Fix tcc_p compilation with latest gcc
tests/tests2/22_floating_point.*: Better test floating point
The incr_offset offset code was not working with bounds checking.
So I reverted part of tccgen.c.
See new test code 132.
Also added some debugging code that prints location of
bounds checking calls. Needed this to find the problem.
See lib/bcheck.c, lib/bt-dll.c, lib/bt-exe.c, lib/bt-log.c, tccrun.c
defined tokens for C, M, Ziscr extensions.
separate the base RV32 instructions from the RV64, for potential future
re-use in a RV32-only assembler, from which the RV64-tok can #include
scall, sbreak have been renamed (page 7 of spec),
necessitating some renaming in riscv64-asm.c
riscv-spec-20191213.pdf was used,
in which the "V" extension is not yet ratified.
available under https://riscv.org/technical/specifications/
Tables 16.5–16.7 do not list any "scall"
neither does the privileged spec
3 additional tokens not present in the tables were removed
note that this riscv64-asm.c still contains defects, which will
be addressed in another commit
tccgen.c:
- new function incr_offset(int) to increment a lvalue
- use it in gv/vstore to load/store from/to two-word types
- use it to advance the pointer to struct fields
- use it to load/store structs passed in registers
- structs: always assume that reg-classes of registers are 2^n
- adjust stack space when regsize > sizeof the_struct
x86_64-gen.c:
- return regsize=16 for VT_QLONG/QFLOAT
i386-gen.c:
- pass structs of size(8) as two VT_INT rather than one VT_LLONG
(both should work now)
fixes a82aff3337
fixes fd6d2180c5 (slightly)
In order to detect a "same file" faster, this makes one
restriction to the feature: the basenames are required to
match at least (as in "test.h" and "dir/../test.h")
Also remove obsolete 'pp_once' (cached includes do not persist
across compilations anymore anyway)
This rewrites commits
30fd24abd44e363a1728
3 files changed, 38 insertions(+), 74 deletions(-)
The stack was not aligned when a returned structure was stored on stack.
This resulted in destoying of previous values stored on stack.
See testcase 119 (tst_struct_return_align) where value d is overwritten.
On backends that rely on gfunc_return() to handle structures
returned in registers (like RISC-V), gfunc_return() may generate
invalid loads for structures without VT_LOCAL and VT_LVAL. This
commit fixes it and adds a regression test
(131_return_struct_in_reg)
pragma once can now be used with
test.h
./test.h
and other references to the same file just like gcc/clang.
On linux we can use stat and st_ino to check for the same file.
On windows the st_ino does not work so we calculate a file hash
if the size of the file differs and then compare the hash.
avoid memory leaks with lost CStrings on stack after errors.
tccpp.c:
- use/abuse static Cstring tokcstr where possible
tccgen.c:
- use/abuse static Cstring initstr where possible
tcc.h/libtcc.a:
- add 'stk_data' array to track memory pointer on stack
- add macros stk_push/pop() and cstr_new/free_s()
tccasm.c:
- use that
- use char[16] instead of char* for op.constraint
This avoids 'exit(1)' with errors outside of compilation
(nasty in particular with libtcc usage)
As a sideeffect multiple errors can be seen for linker
errors (such as undefined symbols, relocation errors, ...)
tccgen.c:
- allow cross-compiling 0.0L (cross-compile tcc with tcc)
tccelf.c:
- use alignment of TLS section for PT_TLS
tccpp.c:
- support long double constants on systems that do not support
long doubles (i.e. mark them (VT_DOUBLE | VT_LONG))
tccdefs.h:
#define __has_feature() for android
remove _unaligned (why define a msvc extension under !_WIN32)
Value 0 and values >2GB where printed wrong during tests with yarpgen (v1)
Starting the output with a hashtag make it compatible to TAP
--
Regards ... Detlef
These extensions where used by other compiler
to generate different code on old cpu's (arm and x86 before pentium/pentiumpro)
to prevent processor exceptions / very high delays when accessing an unaligned pointer.
--
Regards ... Detlef
if we include standard headers on glibc-based systems then
we can't use '__attribute__' (those are defined away for unknown
compilers) but must use '__attribute' (or #undef that token).
tccgen.c:
- just track local_stack for small scopes (can't declare variables)
- fix a vla problem with nested scopes
- move debug N_L/RBRAC into curly braced block
Also:
- tccpp.c: move 'label_...' functions to tccgen.c
- tccpp.c: let get_tok_str() say "<no name>" for anonymous symbols
- tcctest.c: let __pa_symbol() work for memory > 2GB
- 119_random_stuff.c: revert strtoll test (no reason to test libc)
- tccdefs.h/tcctest.c: enable bit fncs for _WIN32
- Makefile:
- use i686-linux-gnu instead of i386-linux-gnu for cross-i386
- update 'make help'
- revert umplicit 'make all' with 'make install' (but print warning)
instead in vcheck_cmp(), pass the CODE_OFF_BIT to generators
unless other nocode purposes are set.
This reverts commit cad8739594.
Also in 128_run_atexit.c:
avoid line output disorder which may happen on windows when
tcc itself and runned code are using two different printf
implementations and tcc would print the "[Returns 1]" above
any output from the runned test.
The generated code by yarpgen failed. I traced the problem to
expr_landor. The problem was that nocode_wanted was removing
too much code.
See also testcase 33.