diff --git a/lib/libtcc1.c b/lib/libtcc1.c index dacee28..bfe683b 100644 --- a/lib/libtcc1.c +++ b/lib/libtcc1.c @@ -689,3 +689,14 @@ void __va_end(struct __va_list_struct *ap) } #endif /* __x86_64__ */ + +/* Flushing for tccrun */ +#if defined(__x86_64__) || defined(__i386__) + +void __clear_cache(char *beginning, char *end) +{ +} + +#else +#warning __clear_cache not defined for this architecture, avoid using tcc -run +#endif diff --git a/tccrun.c b/tccrun.c index 50178a8..174b6c2 100644 --- a/tccrun.c +++ b/tccrun.c @@ -225,6 +225,7 @@ static void set_pages_executable(void *ptr, unsigned long length) end = (addr_t)ptr + length; end = (end + PAGESIZE - 1) & ~(PAGESIZE - 1); mprotect((void *)start, end - start, PROT_READ | PROT_WRITE | PROT_EXEC); + __clear_cache(ptr, prog_main + length); #endif }