1 /* ------------------------------------------------------------- */
2 /* for linking rt_printline and the signal/exception handler
3 from tccrun.c into executables. */
5 #define CONFIG_TCC_BACKTRACE_ONLY
7 #define pstrcpy tcc_pstrcpy
10 int (*__rt_error
)(void*, void*, const char *, va_list);
11 void (*__rt_location
)(void*, void*, const char *);
12 __attribute__((weak
)) void __bound_checking_lock(void);
13 __attribute__((weak
)) void __bound_checking_unlock(void);
16 # define __declspec(n)
20 void __bt_init(rt_context
*p
, int num_callers
)
22 __attribute__((weak
)) int main();
23 __attribute__((weak
)) void __bound_init(void*, int);
24 struct rt_context
*rc
= &g_rtctxt
;
25 //fprintf(stderr, "__bt_init %d %p %p\n", num_callers, p->stab_sym, p->bounds_start), fflush(stderr);
26 /* call __bound_init here due to redirection of sigaction */
27 /* needed to add global symbols */
28 if (p
->bounds_start
) {
29 __bound_init(p
->bounds_start
, -1);
30 __bound_checking_lock();
33 memcpy(rc
, p
, offsetof(rt_context
, next
));
34 rc
->num_callers
= num_callers
- 1;
36 __rt_error
= _rt_error
;
37 __rt_location
= _rt_location
;
38 set_exception_handler();
40 p
->next
= rc
->next
, rc
->next
= p
;
43 __bound_checking_unlock();
47 void __bt_exit(rt_context
*p
)
49 __attribute__((weak
)) void __bound_exit_dll(void*);
50 struct rt_context
*rc
= &g_rtctxt
;
52 if (p
->bounds_start
) {
53 __bound_exit_dll(p
->bounds_start
);
54 __bound_checking_lock();
58 rc
->next
= rc
->next
->next
;
64 __bound_checking_unlock();
67 /* copy a string and truncate it. */
68 ST_FUNC
char *pstrcpy(char *buf
, size_t buf_size
, const char *s
)