wingo pushed a commit to branch lightning
in repository guile.

commit f39eee6694db4880fd5677c89b91ee7095799a55
Author: pcpa <[email protected]>
Date:   Wed Mar 6 16:36:38 2013 -0300

    Make code and data buffer readonly.
    
        * lib/lightning.c: Make data and code buffer readonly.
---
 ChangeLog       | 4 ++++
 lib/lightning.c | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 16ba88d..ecd84bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-03-06 Paulo Andrade <[email protected]>
+
+       * lib/lightning.c: Make data and code buffer readonly.
+
 2013-02-20 Paulo Andrade <[email protected]>
 
        * doc/body.texi: Fool proof validate the examples of what
diff --git a/lib/lightning.c b/lib/lightning.c
index a9b77f6..d069743 100644
--- a/lib/lightning.c
+++ b/lib/lightning.c
@@ -1376,6 +1376,7 @@ _jit_emit(jit_state_t *_jit)
     jit_node_t         *node;
     jit_int32_t                 mult;
     size_t              length;
+    int                         result;
 
     if (_jit->function)
        jit_epilog();
@@ -1430,6 +1431,11 @@ _jit_emit(jit_state_t *_jit)
     _jit->done = 1;
     jit_annotate();
 
+    result = mprotect(_jit->data.ptr, _jit->data.length, PROT_READ);
+    assert(result == 0);
+    result = mprotect(_jit->code.ptr, _jit->code.length, PROT_READ | 
PROT_EXEC);
+    assert(result == 0);
+
     return (code);
 }
 

Reply via email to