diff mbox

[3/5] ARM: tests/Gtest-dyn1.c fixes.

Message ID 1303401162-14277-4-git-send-email-ken.werner@linaro.org
State Accepted
Commit 3b917f2d16c1e02e7d3a610ed0bebe51d4f5f610
Headers show

Commit Message

Ken Werner April 21, 2011, 3:52 p.m. UTC
Define an appropriate fdesc struct and its corresponding accessors that take
care of the thumb marker on ARM. Call the __clear_cache built-in instead of
flush_cache if the GNU compiler is used.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
---
 tests/Gtest-dyn1.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/tests/Gtest-dyn1.c b/tests/Gtest-dyn1.c
index ad49a5c..b7b788f 100644
--- a/tests/Gtest-dyn1.c
+++ b/tests/Gtest-dyn1.c
@@ -62,6 +62,16 @@  struct fdesc
 # define get_fdesc(fdesc,func)	(fdesc = *(struct fdesc *) &(func))
 # define get_funcp(fdesc)	((template_t) &(fdesc))
 # define get_gp(fdesc)		((fdesc).gp)
+#elif __arm__
+struct fdesc
+  {
+    long code;
+    long is_thumb;
+  };
+# define get_fdesc(fdesc,func)  ({(fdesc).code = (long) &(func) & ~0x1; \
+				  (fdesc).is_thumb = (long) &(func) & 0x1;})
+# define get_funcp(fdesc)       ((template_t) ((fdesc).code | (fdesc).is_thumb))
+# define get_gp(fdesc)          (0)
 #else
 struct fdesc
   {
@@ -170,7 +180,12 @@  main (int argc, char *argv[])
   memcpy (mem, (void *) fdesc.code, MAX_FUNC_SIZE);
   mprotect ((void *) ((long) mem & ~(getpagesize () - 1)),
 	    2*getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC);
+
+#ifdef __GNUC__
+  __clear_cache(mem, mem + MAX_FUNC_SIZE);
+#else
   flush_cache (mem, MAX_FUNC_SIZE);
+#endif
 
   signal (SIGSEGV, sighandler);