tccrun: update for apple and openbsd

Apple needs CONFIG_RUNMEM_RO=1
I now only set CONFIG_RUNMEM_RO=0 on _WIN32

Openbsd does not have malloc.h so remove some code

Also fix some warnings when compiling lib with gcc
This commit is contained in:
herman ten brugge 2024-02-26 07:18:07 +01:00
parent 4e91d38ddc
commit f9cb198aa8
2 changed files with 8 additions and 12 deletions

View file

@ -69,6 +69,7 @@ void exit(int code)
f.fp = 0; f.fp = 0;
f.ip = exit; f.ip = exit;
__rt_exit(&f, code); __rt_exit(&f, code);
for (;;); // avoid noreturn warning
} }
#ifndef _WIN32 #ifndef _WIN32

View file

@ -91,17 +91,6 @@ static void *win64_add_function_table(TCCState *s1);
static void win64_del_function_table(void *); static void win64_del_function_table(void *);
#endif #endif
#ifdef __APPLE__
# define CONFIG_RUNMEM_ALIGNED 0
#else
# ifndef CONFIG_RUNMEM_ALIGNED
# define CONFIG_RUNMEM_ALIGNED 1
# endif
# if CONFIG_RUNMEM_ALIGNED
# include <malloc.h> /* memalign() */
# endif
#endif
#if !_WIN32 && !__APPLE__ #if !_WIN32 && !__APPLE__
//#define HAVE_SELINUX 1 //#define HAVE_SELINUX 1
#endif #endif
@ -286,7 +275,11 @@ static void cleanup_sections(TCCState *s1)
/* 0 = .text rwx other rw */ /* 0 = .text rwx other rw */
/* 1 = .text rx .rdata r .data/.bss rw */ /* 1 = .text rx .rdata r .data/.bss rw */
#ifndef CONFIG_RUNMEM_RO #ifndef CONFIG_RUNMEM_RO
# define CONFIG_RUNMEM_RO 0 # ifdef _WIN32
# define CONFIG_RUNMEM_RO 0
# else
# define CONFIG_RUNMEM_RO 1
# endif
#endif #endif
/* relocate code. Return -1 on error, required size if ptr is NULL, /* relocate code. Return -1 on error, required size if ptr is NULL,
@ -1184,7 +1177,9 @@ int _tcc_backtrace(rt_frame *f, const char *fmt, va_list ap)
} }
rt_printf("\n"); rt_printf("\n");
#ifndef CONFIG_TCC_BACKTRACE_ONLY
check_break: check_break:
#endif
if (rc2 if (rc2
&& bi.func_pc && bi.func_pc
&& bi.func_pc == (addr_t)rc2->top_func) && bi.func_pc == (addr_t)rc2->top_func)