1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-12-23 12:03:41 +01:00

Flush icache with __builtin___clear_cache() in tests when compiling with GCC

When compiling with GCC, use the builtin instruction cache flushing
mechanism in all tests where it is needed.

Quoting GCC docs: ''If the target does not require instruction cache
flushes, __builtin___clear_cache has no effect. Otherwise either
instructions are emitted in-line to clear the instruction cache or a
call to the __clear_cache function in libgcc is made.''.
This commit is contained in:
Tommi Rantala 2012-08-11 16:02:33 +03:00
parent 5fedf3407c
commit 39b8398159
3 changed files with 13 additions and 1 deletions

View file

@ -86,7 +86,9 @@ struct fdesc
# define get_gp(fdesc) (0)
#endif
#ifndef __GNUC__
extern void flush_cache (void *addr, size_t len);
#endif
void
template (int i, template_t self,
@ -186,7 +188,7 @@ main (int argc, char *argv[] __attribute__((unused)))
2*getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC);
#ifdef __GNUC__
__clear_cache(mem, mem + MAX_FUNC_SIZE);
__builtin___clear_cache(mem, mem + MAX_FUNC_SIZE);
#else
flush_cache (mem, MAX_FUNC_SIZE);
#endif

View file

@ -1,3 +1,5 @@
#ifndef __GNUC__
#if defined(__ia64__)
.global flush_cache
@ -80,3 +82,5 @@ flush_cache:
/* We do not need executable stack. */
.section .note.GNU-stack,"",@progbits
#endif
#endif

View file

@ -20,7 +20,9 @@ int verbose;
# define EXTRA 0
#endif
#ifndef __GNUC__
extern void flush_cache (void *addr, size_t len);
#endif
int
make_executable (void *addr, size_t len)
@ -31,7 +33,11 @@ make_executable (void *addr, size_t len)
perror ("mprotect");
return -1;
}
#ifdef __GNUC__
__builtin___clear_cache(addr, addr + len);
#else
flush_cache (addr, len);
#endif
return 0;
}