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
12 # define __declspec(n)
16 void __bt_init(rt_context
*p
, int is_exe
)
18 __attribute__((weak
)) int main();
19 __attribute__((weak
)) void __bound_init(void*, int);
21 //fprintf(stderr, "__bt_init %d %p %p %p\n", is_exe, p, p->stab_sym, p->bounds_start), fflush(stderr);
23 /* call __bound_init here due to redirection of sigaction */
24 /* needed to add global symbols */
26 __bound_init(p
->bounds_start
, -1);
30 p
->next
= g_rc
, g_rc
= p
;
33 /* we are the executable (not a dll) */
35 set_exception_handler();
40 void __bt_exit(rt_context
*p
)
42 struct rt_context
*rc
, **pp
;
43 __attribute__((weak
)) void __bound_exit_dll(void*);
45 //fprintf(stderr, "__bt_exit %d %p\n", !!p->top_func, p);
48 __bound_exit_dll(p
->bounds_start
);
50 /* remove from chain */
52 for (pp
= &g_rc
; rc
= *pp
, rc
; pp
= &rc
->next
)
60 /* copy a string and truncate it. */
61 ST_FUNC
char *pstrcpy(char *buf
, size_t buf_size
, const char *s
)