@@ -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);
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(-)