1 /* ------------------------------------------------------------- */
2 /* for linking rt_printline and the signal/exception handler
3 from tccrun.c into executables. */
5 #define CONFIG_TCC_BACKTRACE_ONLY
9 int (*__rt_error
)(void*, void*, const char *, va_list);
10 __attribute__((weak
)) void __bound_checking_lock(void);
11 __attribute__((weak
)) void __bound_checking_unlock(void);
14 # define __declspec(n)
18 void __bt_init(rt_context
*p
, int num_callers
)
20 __attribute__((weak
)) int main();
21 __attribute__((weak
)) void __bound_init(void*, int);
22 struct rt_context
*rc
= &g_rtctxt
;
23 //fprintf(stderr, "__bt_init %d %p %p\n", num_callers, p->stab_sym, p->bounds_start), fflush(stderr);
24 /* call __bound_init here due to redirection of sigaction */
25 /* needed to add global symbols */
26 if (p
->bounds_start
) {
27 __bound_init(p
->bounds_start
, -1);
28 __bound_checking_lock();
31 memcpy(rc
, p
, offsetof(rt_context
, next
));
32 rc
->num_callers
= num_callers
- 1;
34 __rt_error
= _rt_error
;
35 set_exception_handler();
37 p
->next
= rc
->next
, rc
->next
= p
;
40 __bound_checking_unlock();
44 void __bt_exit(rt_context
*p
)
46 __attribute__((weak
)) void __bound_exit_dll(void*);
47 struct rt_context
*rc
= &g_rtctxt
;
49 if (p
->bounds_start
) {
50 __bound_exit_dll(p
->bounds_start
);
51 __bound_checking_lock();
55 rc
->next
= rc
->next
->next
;
61 __bound_checking_unlock();
64 /* copy a string and truncate it. */
65 ST_FUNC
char *pstrcpy(char *buf
, size_t buf_size
, const char *s
)