Changeset 3577


Ignore:
Timestamp:
Mar 1, 2013, 9:00:57 AM (3 years ago)
Author:
wmb
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • forth/wrapper/wrapper.c

    r2834 r3577  
    5757#include <string.h>
    5858#include <unistd.h>
     59#include <sys/mman.h>
    5960
    6061/*
     
    10121013# endif
    10131014
     1015#if defined(__linux__) && defined(ARM)
     1016        /* This is a hack to make sure loadaddr is page-aligned for mprotect() in s_flushcache() */
     1017        loadaddr = (char *)sbrk(memsize);
     1018#else
    10141019        loadaddr = (char *)m_alloc(memsize);
     1020#endif
    10151021        if ((loadaddr == (char *) -1) || (loadaddr == (char *) 0)) {
    10161022                error("forth: Can't get memory","");
     
    21962202#endif
    21972203#if defined(__linux__) && defined(ARM)
     2204        mprotect(adr, len, PROT_READ | PROT_WRITE | PROT_EXEC);
    21982205        __clear_cache(adr, adr+len);
    21992206        return 0L;
Note: See TracChangeset for help on using the changeset viewer.