Author: Armin Rigo <[email protected]>
Branch: shadowstack-issue2722
Changeset: r96570:c790dcca68e1
Date: 2019-05-04 15:55 +0200
http://bitbucket.org/pypy/pypy/changeset/c790dcca68e1/

Log:    These changes might be enough to allow the shadowstack's address to
        be changed at any point

diff --git a/rpython/translator/c/gc.py b/rpython/translator/c/gc.py
--- a/rpython/translator/c/gc.py
+++ b/rpython/translator/c/gc.py
@@ -452,7 +452,6 @@
         #
         yield ('typedef struct { void %s; } pypy_ss_t;'
                    % ', '.join(['*s%d' % i for i in range(numcolors)]))
-        yield 'pypy_ss_t *ss;'
         funcgen.gcpol_ss = gcpol_ss
 
     def OP_GC_PUSH_ROOTS(self, funcgen, op):
@@ -462,26 +461,27 @@
         raise Exception("gc_pop_roots should be removed by postprocess_graph")
 
     def OP_GC_ENTER_ROOTS_FRAME(self, funcgen, op):
-        return 'ss = (pypy_ss_t *)%s; %s = (void *)(ss+1);' % (
-            funcgen.gcpol_ss, funcgen.gcpol_ss)
+        return '%s += sizeof(pypy_ss_t);' % (funcgen.gcpol_ss,)
 
     def OP_GC_LEAVE_ROOTS_FRAME(self, funcgen, op):
-        return '%s = (void *)ss;' % funcgen.gcpol_ss
+        return '%s -= sizeof(pypy_ss_t);' % (funcgen.gcpol_ss,)
 
     def OP_GC_SAVE_ROOT(self, funcgen, op):
         num = op.args[0].value
         exprvalue = funcgen.expr(op.args[1])
-        return 'ss->s%d = (void *)%s;\t/* gc_save_root */' % (num, exprvalue)
+        return '((pypy_ss_t *)%s)[-1].s%d = (void *)%s;' % (
+            funcgen.gcpol_ss, num, exprvalue)
 
     def OP_GC_RESTORE_ROOT(self, funcgen, op):
         num = op.args[0].value
         exprvalue = funcgen.expr(op.args[1])
         typename = funcgen.db.gettype(op.args[1].concretetype)
-        result = '%s = (%s)ss->s%d;' % (exprvalue, cdecl(typename, ''), num)
+        result = '%s = (%s)((pypy_ss_t *)%s)[-1].s%d;' % (
+            exprvalue, cdecl(typename, ''), funcgen.gcpol_ss, num)
         if isinstance(op.args[1], Constant):
-            return '/* %s\t* gc_restore_root */' % result
+            return '/* %s */' % result
         else:
-            return '%s\t/* gc_restore_root */' % result
+            return result
 
 
 class AsmGcRootFrameworkGcPolicy(BasicFrameworkGcPolicy):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to