Author: wmb Date: Fri Mar 1 10:00:57 2013 New Revision: 3577 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3577
Log: ARM - fixed wrapper to avoid Segmentation Violations when compiled for the SYSV ABI, which disallows self-modifying code by default. The solution is to call mprotect(..., PROT_READ | PROT_WRITE | PROT_EXEC);
Modified: forth/wrapper/wrapper.c
Modified: forth/wrapper/wrapper.c ============================================================================== --- forth/wrapper/wrapper.c Wed Feb 27 10:16:19 2013 (r3576) +++ forth/wrapper/wrapper.c Fri Mar 1 10:00:57 2013 (r3577) @@ -56,6 +56,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/mman.h>
/* * The following #includes and externs fix GCC warnings when compiled with @@ -1011,7 +1012,12 @@ # endif # endif
+#if defined(__linux__) && defined(ARM) + /* This is a hack to make sure loadaddr is page-aligned for mprotect() in s_flushcache() */ + loadaddr = (char *)sbrk(memsize); +#else loadaddr = (char *)m_alloc(memsize); +#endif if ((loadaddr == (char *) -1) || (loadaddr == (char *) 0)) { error("forth: Can't get memory",""); exit(1); @@ -2195,6 +2201,7 @@ return 0L; #endif #if defined(__linux__) && defined(ARM) + mprotect(adr, len, PROT_READ | PROT_WRITE | PROT_EXEC); __clear_cache(adr, adr+len); return 0L; #endif
openfirmware@openfirmware.info