mirror of
https://github.com/TinyCC/tinycc.git
synced 2025-11-16 12:34:45 +00:00
macos: support bounds checking
* non-process-shared POSIX semaphores aren't supported on Darwin, we use the dispatch framework * dlsym segfaults with RTLD_NEXT from JIT code, so we must not even try this for -run. So we need to know in __bound_init if called from -run code, or from normal code, which means passing this down also from __bt_init and hence from the stub added in tcc_add_btstub * Darwin uses different structures for <ctype.h> facilities, this merely adds a warning about this * __libc_freeres doesn't exist * for non -run modus the context (.prog_base member) is constructed incorrectly (uses symbol zero for trying to get at the load bias, which doesn't really work that way), on Mach-O this errors out (and could also error out on ELF). For now deactivate this, which makes backtraces not be symbolic on MacOS for not -run.
This commit is contained in:
@@ -12,12 +12,12 @@ int (*__rt_error)(void*, void*, const char *, va_list);
|
||||
#endif
|
||||
|
||||
__declspec(dllexport)
|
||||
void __bt_init(rt_context *p, int num_callers)
|
||||
void __bt_init(rt_context *p, int num_callers, int mode)
|
||||
{
|
||||
__attribute__((weak)) int main();
|
||||
__attribute__((weak)) void __bound_init(void*);
|
||||
__attribute__((weak)) void __bound_init(void*, int);
|
||||
struct rt_context *rc = &g_rtctxt;
|
||||
//fprintf(stderr, "__bt_init %d %p %p\n", num_callers, p->stab_sym, p->bounds_start), fflush(stderr);
|
||||
//fprintf(stderr, "__bt_init %d %p %p %d\n", num_callers, p->stab_sym, p->bounds_start, mode), fflush(stderr);
|
||||
if (num_callers) {
|
||||
memcpy(rc, p, offsetof(rt_context, next));
|
||||
rc->num_callers = num_callers - 1;
|
||||
@@ -28,7 +28,7 @@ void __bt_init(rt_context *p, int num_callers)
|
||||
p->next = rc->next, rc->next = p;
|
||||
}
|
||||
if (__bound_init && p->bounds_start)
|
||||
__bound_init(p->bounds_start);
|
||||
__bound_init(p->bounds_start, mode);
|
||||
}
|
||||
|
||||
/* copy a string and truncate it. */
|
||||
|
||||
Reference in New Issue
Block a user