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.''.
---
tests/Gtest-dyn1.c | 4 +++-
tests/flush-cache.S | 4 ++++
tests/ia64-test-dyn1.c | 6 ++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/tests/Gtest-dyn1.c b/tests/Gtest-dyn1.c
index b530dd7..df2ab4a 100644
--- a/tests/Gtest-dyn1.c
+++ b/tests/Gtest-dyn1.c
@@ -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
diff --git a/tests/flush-cache.S b/tests/flush-cache.S
index 2a17165..f441a74 100644
--- a/tests/flush-cache.S
+++ b/tests/flush-cache.S
@@ -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
diff --git a/tests/ia64-test-dyn1.c b/tests/ia64-test-dyn1.c
index c47097c..8331913 100644
--- a/tests/ia64-test-dyn1.c
+++ b/tests/ia64-test-dyn1.c
@@ -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;
}
--
1.7.9.5
_______________________________________________
Libunwind-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/libunwind-devel