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);
12 # define __declspec(n)
16 void __bt_init(rt_context
*p
, int num_callers
)
18 __attribute__((weak
)) int main();
19 __attribute__((weak
)) void __bound_init(void*, int);
20 struct rt_context
*rc
= &g_rtctxt
;
21 //fprintf(stderr, "__bt_init %d %p %p\n", num_callers, p->stab_sym, p->bounds_start), fflush(stderr);
22 /* call __bound_init here due to redirection of sigaction */
23 /* needed to add global symbols */
24 if (__bound_init
&& p
->bounds_start
)
25 __bound_init(p
->bounds_start
, -1);
27 memcpy(rc
, p
, offsetof(rt_context
, next
));
28 rc
->num_callers
= num_callers
- 1;
30 __rt_error
= _rt_error
;
31 set_exception_handler();
33 p
->next
= rc
->next
, rc
->next
= p
;
38 void __bt_exit(rt_context
*p
)
40 __attribute__((weak
)) void __bound_exit_dll(void*);
41 struct rt_context
*rc
= &g_rtctxt
;
43 if (__bound_exit_dll
&& p
->bounds_start
)
44 __bound_exit_dll(p
->bounds_start
);
47 rc
->next
= rc
->next
->next
;
54 /* copy a string and truncate it. */
55 ST_FUNC
char *pstrcpy(char *buf
, size_t buf_size
, const char *s
)