Commit Graph

2623 Commits

Author SHA1 Message Date
herman ten brugge
56e70bfa31 Fix bounds checking new functions.
There was a problem with strncpy and strncmp.
Made bound_ptr_add and bound_ptr_indir a little bit faster.
Fix statistic counter types. Change long into long long.
2019-12-13 10:02:20 +01:00
herman ten brugge
39c0ff311d Add new bounds checking functions.
The following functions are now also bounds checked:
memcmp, strncpy, strcmp, strncmp, strcat, strchr, strdup.

Add statistics code for bounds checking functions.
The statistics can be printed by settings environment variable
"TCC_BOUNDS_PRINT_STATISTIC".

Enabled more tests in test/Makefile.
2019-12-12 20:49:35 +01:00
herman ten brugge
35512be1ee Fix typo with -ba option 2019-12-12 14:21:07 +01:00
herman ten brugge
75145ddc1a Add -ba option for bounds_checking 2019-12-12 13:29:45 +01:00
herman ten brugge
4a2e33d160 Update bounds checking.
The bounds checking code has now enabled gen_bounded_ptr_add tests.
This makes the code slower but finds more errors.
I had to correct some things in tcc to make it work.
- Fixed off by one in lib/bcheck.c
- Corrected tccelf.c sym_versions.
- Disabled USE_TAL when using bounds checking.
- Fixed cstr_printf va_start.
- Fixed tests/tests2/46_grep.c off by one error.
- Updated gen_bounded_ptr_add in x86_64-gen.c
- Fixed x86_64-link.c pointer diff.
For gen_vla_alloc now always use alloca call when bounds checking.
Added line/filename in %rax before bound calls to find location of error.
2019-12-12 12:56:06 +01:00
Michael Matz
ce4eafb34f Include some headers in new multi-thread test
for usleep and gettimeofday.
2019-12-12 03:31:21 +01:00
Michael Matz
11fc58fa13 Fix parallel make targets
my last patch here fixed a missing dependency, but in the wrong
way.  It would build some object files twice, which could race.
The lib/all target already builds both libtcc{,b}1.a libs, so
a simple dependency is enough.
2019-12-12 02:00:13 +01:00
Michael Matz
90e09ed75f Disable thumb code generation on tcctest.gcc
this breaks getting the alignment of functions via bit masking
which we assume to work in one test.
2019-12-12 01:52:50 +01:00
Michael Matz
83f822d0cd Also parse -Dfoo in libtcc_test_mt
otherwise the -DTCC_ARM_VFP doesn't get through.
2019-12-12 01:39:58 +01:00
Michael Matz
8b23662d53 Fix libtcc_test_mt with lib64
we need to pass NATIVE_DEFINES, and we need to actually parse
and pass them into the state.
2019-12-11 17:57:43 +01:00
herman ten brugge
b3893baa45 Fix3 alloca on x86_64 windows 2019-12-11 14:26:27 +01:00
herman ten brugge
b45a8d456d Fix2 alloca on x86_64 windows 2019-12-11 14:22:01 +01:00
herman ten brugge
426d32af23 Fix alloca on x86_64 windows 2019-12-11 14:06:15 +01:00
herman ten brugge
a0bc149b0c Fix bounds checking after concurrently commit 2019-12-11 12:07:48 +01:00
grischka
72729d8e36 allow libtcc states to be used concurrently
This allows creation of TCCStates and operation with API
calls independently from each other, even from threads.

Frontend (option parsing/libtcc.c) and backend (linker/tccelf.c)
now depend only on the TCCState (s1) argument.

Compilation per se (tccpp.c, tccgen.c) is still using
globals for convenience.  There is only one entry point
to this section which is tcc_compile() which is protected
by a semaphore.

There are some hacks involved to avoid too many changes,
as well as some changes in order to avoid too many hacks ;)

The test libtcc_test_mt.c shows the feature.  Except this
new file the patch adds 87 lines overall.
2019-12-11 02:36:19 +01:00
grischka
6082dd62bb tcc -vv ... : show objects loaded from archives 2019-12-10 20:55:57 +01:00
grischka
df349ddc43 versym cleanup
get rid of some globals, in the first place.  Also, for the
PE target, ifdef out ELF executable creation.
2019-12-10 20:41:35 +01:00
herman ten brugge
4d297d354c Add bound checking print heap 2019-12-10 19:47:33 +01:00
Michael Matz
fb22e0c12d Fix type/r/r2 confusion differently
on i386 111_conversion.c breaks when save_reg_upstack isn't careful
about r2 and type mismatches.  The bcheck patches fixed this by
enlarging the stack slot beyond the natural type, this variant simply
avoids saving the second register is the type indicates that it isn't
needed.

Adds also a comment how this should ideally work, namely that type
and r/r2 entries in the vstack are consistent.  In the 111_conversion
testcase it's specifically gen_cast via gen_cvt_ftoi that breaks
this, but there more general code broken as well, so that would deserve
a careful fixup based on some additional asserts.
2019-12-10 17:49:04 +01:00
Michael Matz
ac2a61d1b3 Add dependency on libtccb1.a
otherwise parallel makes might throw errors.
2019-12-10 17:48:23 +01:00
Michael Matz
353db307ed Fix compile warning with cross compilers
'make i386-tcc' on a x86-64 host gave a warning about the
unconditionally declared static tcc_add_bcheck function.
2019-12-10 16:56:10 +01:00
herman ten brugge
88dd577302 Disable bounds_check1_test on arm 2019-12-10 09:39:45 +01:00
herman ten brugge
17850a51f5 Fix bounds checking on targets with no bcheck.c 2019-12-10 08:44:44 +01:00
herman ten brugge
4461f38a9e Fix bounds checking for linux/windows 2019-12-10 08:07:25 +01:00
Michael Matz
474f95dda8 Fix setting of options
now that the type of boolean options is uchar set_flag() needs
an accompanying change.
2019-12-05 17:04:04 +01:00
Michael Matz
1dc92f8ff8 Fix indentation and run_test type
tcc_state.run_test is used as counter, not flag, so int is appropriate.
Also fix indentation garbled by last patch.
2019-12-02 19:20:56 +01:00
Sergey Sushilin
4873f6fada use uchar instead of int to save memory 2019-12-01 23:22:57 +03:00
Sergey Sushilin
14fc6b6dcb use size_t instead of int when work with strings 2019-12-01 22:45:42 +03:00
herman ten brugge
df72b8d487 Add windows constructor/destructor support 2019-11-27 18:29:12 +01:00
Michael Matz
4e9ce59fe8 Workaround false positive warning 2019-11-27 17:35:24 +01:00
Michael Matz
8a93ce106a elf: rewrite version support
so it isn't quadratic in number of symbols.  It's still quadratic
in number of lib/version combinations (at library load time the
sym versions are internalized), but that's much less a problem as
in practice only glibc uses sym versioning.
2019-11-25 21:06:07 +01:00
Christian Jullien
25781e4552 Fix float conversion in arm64 backend 2019-11-08 07:55:05 +01:00
Jookia
f420259ee5 arm: Don't override syscall implementation 2019-11-06 01:01:56 +11:00
herman ten brugge
96f1fb1da0 rename testcase 2019-10-29 12:02:58 +01:00
herman ten brugge
fadfc118e5 Fix sse calling bug 2019-10-29 07:19:42 +01:00
herman ten brugge
800c3a5e0b Add constructor/destructor support 2019-10-29 07:02:58 +01:00
herman ten brugge
c4c5ea4381 remove wine 2019-10-25 07:40:37 +02:00
herman ten brugge
b84ab23011 Add wine support 2019-10-24 22:10:04 +02:00
herman ten brugge
588dd6827a Fix elf version info 2019-10-24 20:47:02 +02:00
Pursuer2
a7b37f9c63 Fix bug in gen_cvt_ftoi1. Add test 107_stack_safe for this fix.
(Thanks to the support of herman ten brugge)
2019-10-24 00:57:59 +08:00
herman ten brugge
749dd15ee8 Fix testcase for elf version 2019-10-23 13:14:41 +02:00
herman ten brugge
66a14a1e33 Add testcase for elf_version 2019-10-22 20:45:03 +02:00
herman ten brugge
b073a9c103 Add testcase for elf_version 2019-10-22 20:43:30 +02:00
herman ten brugge
7268fe7239 Add elf version support 2019-10-22 16:55:20 +02:00
Luc Everse
491773ac58
Add error_func and error_opaque getters to libtcc 2019-10-14 09:36:14 +02:00
Jan Boon
944c4003bd Add function to list all symbols, for purpose of linking separate in-memory compilations 2019-09-16 15:24:16 +08:00
Øyvind A. Holm
c6635504fe README: Fix typo and remove trailing whitespace 2019-09-14 15:37:20 +02:00
Sergey Sushilin
53a1521c2e fix _Noreturn keyword 2019-09-08 18:35:15 +03:00
grischka
7b8799e5ff tccgen.c: local extern decls: copy s->ref for VT_PTR too
This fixes the issue

    int main() { extern char *x; }
    void main1() { extern char *x; }
    t2.c:5: error: incompatible types for redefinition of 'x'

(reported by Giovanni Mascellani 2019/07/16)
2019-09-08 16:59:17 +02:00
Sergey Sushilin
9298555eb6 add C11 stdalign.h header 2019-09-08 15:04:06 +03:00