Allow tcc to run with bounds checking enabled

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.
This commit is contained in:
herman ten brugge
2024-02-15 07:17:15 +01:00
parent f2e8b2ad79
commit 8d8d75ca75
3 changed files with 25 additions and 9 deletions

View File

@@ -66,9 +66,15 @@ TCC_SEM(static rt_sem);
static int signal_set;
static void set_exception_handler(void);
int _rt_error(rt_frame *f, const char *msg, const char *fmt, va_list ap);
void rt_wait_sem(void) { WAIT_SEM(&rt_sem); }
void rt_post_sem(void) { POST_SEM(&rt_sem); }
#ifdef _WIN32
#define ATTR_WEAK
#else
#define ATTR_WEAK __attribute__((weak))
#endif
int ATTR_WEAK _rt_error(rt_frame *f, const char *msg, const char *fmt, va_list ap);
void ATTR_WEAK rt_wait_sem(void) { WAIT_SEM(&rt_sem); }
void ATTR_WEAK rt_post_sem(void) { POST_SEM(&rt_sem); }
#undef ATTR_WEAK
#endif /* def CONFIG_TCC_BACKTRACE */
/* handle exit/atexit for tcc_run() -- thread-unsafe */