Use `t1` instead of `t0` for the cases when `rr` is not set so `t0` is
used by default and this happens:
lui t0, XXX
add t0, t0, t0
Instead, now we do:
lui t1, XXX
add t0, t0, t1
This commit fixes the case where the register of for the Extended Asm
input or output is known. Before this commit, the following case:
register long __a0 asm ("a0") = one;
asm volatile (
"ecall\n\t"
: "+r" (__a0) // NOTE the +r here
);
Didn't treat `a0` as an input+output register (+ contraint) as the code
skipped the constraint processing when the register was already chosen
(instead of allocated later).
This issue comes from f081acbfba, that was
taken as a reference in every other Extended Assembler implementation.
NOTE: In order to be able to deal with general-purpose vs floating-point
registers, this commit adds a flag in the 6th bit of the register. If
set, it means the register is a floating-point one. This affects all the
assembler.
Before:
ld rd, rs, imm
sd rs1, rs2, imm
Now:
ld rd, imm(rs)
sd rs2, imm(rs1)
NOTES: Just as in GAS:
- In stores the register order is swapped
- imm is optional
- when imm is not included parenthesis can be removed
- tccgen.c: cleanup switch data etc. after errors (*)
- tccpe.c: faster get_dllexports (*)
- tccpe.c: support -Wl,-e[ntry]=... (*)
- libtcc.c: win32: use ANSI functions (GetModuleFileNameA etc.)
- tccrun.c: be nice to tcc-0.9.26 ("struct/enum already defined")
- tccpp.c: be nice to tcc-0.9.27's va_start/end macros
(*) suggested by Robert Schlicht
https://lists.gnu.org/archive/html/tinycc-devel/2024-03/msg00012.html
See test. We need to use 'ind' from later when the address
field of the instruction is put.
Also: fix crash when the substracted symbol is undefined
Also: assume asm-symbols to be lvalues (except func/array)
Apple needs CONFIG_RUNMEM_RO=1
I now only set CONFIG_RUNMEM_RO=0 on _WIN32
Openbsd does not have malloc.h so remove some code
Also fix some warnings when compiling lib with gcc
- LIBTCCAPI int tcc_set_backtrace_func(void *ud, ...)
accept opaque user data pointer,
- tcc -vv -run... : show section info
- use memalign() to allocate runtime memory
- printline_/dwarf : pass output to parent function
- tccpe.c : fix -nostdlib -run
- --config-backtrace=no : make it work again
- new LIBTCC API tcc_setjmp() to allow longjmps & signals
from compiled code back to libtcc per TCCState
- new LIBTCC API tcc_set_backtrace_func() to handle backtrace output
- move c/dtor/atexit stuff to runtime (lib/runmain.c)
- move bt-log.o into libtcc1.a
- add timeouts to github action (beware, it did happen to hang
infinitely in the signal handler at some point)
tcc failed to run with bounds checking enabled because the functions
rt_wait_sem, rt_post_sem and _rt_error where defined twice.
This is solved by making them weak in tccrun.c
Also a nested lock was present when setting TCC_BOUNDS_PRINT_CALLS=1
This is solved in lib/bt-exe.c by moving lock/unlock code.
Also added a testcase in tests/Makefile to test tcc with bounds
checking enabled.
- abort with notice when tcc_relocate() is called with the
former two-step method
- support backtrace & bcheck not only with tcc_run() but also
for directly called functions from tcc_get_symbol(); enable
witn 'tcc_set_options("-bt/-b");'
- move struct rt_context and debug sections into compiled code
for TCC_OUTPUT_MEMORY also
- protect access (g_rc) with semaphore
Also:
- add armv7/aarch4/riscv64 github tests (qemu emulated)
- win32/build-tcc.bat: build cross compiler only with -x
- remove TOK_NOSUBST, mark the token itself instead
- get_tok_str(); mask out SYM_FIELD & update uses
- next(): optimize (~5% faster with tcc -E)
- tok_flags: remove some redundancy
- parse_define(): do not remove spaces around '##' and after '#'
and mark macros with '##' as MACRO_JOIN to avoid unnecessary
call to macro_twosharps(mstr):
- next_nomacro(): removed, next_nomacro1(): renamed to next_nomacro()
- next_argstream(): cleanup & new function peek_file()
- macro_subst_tok(): handle special macros (__DATE__ etc.)
like normal macros if they are #defined
- -DPP_DEBUG : more structured output
- pp_error(): better preprocessor expression error message
- tcctok.h: sort basic keywords (somehow)
- testspp/Makefile: generate .expect with 'make testspp.##+'
- tcc.c: tcc -E -o file : put unixy LFs also on windows
removed second argument for tcc_relocate(s). previous
'TCC_RELOCATE_AUTO' is now default and only behavior.
Rationale:
In the past, the option to compile into memory provided by the
user was introduced because only one TCCState could exist at a time.
This is no longer a limitation. As such it is also possible now to
keep any number of compiled code snippets around together with their
state in order to run them as needed.
- Also
- LIBTCCAPI tcc_get_error_func/opaque() removed
- tccrun/SELINUX: switch rx/rw mappings such that rx comes first
(risc64-link.c:relocate_plt() does not like got < plt)
- tcc_relocate_ex(): free local symbols and obsolete sections
to reduce memory after tcc_relocate()