ref: 4cb032442a1598611c684ca16f58950358502935
parent: 84c40fb226e374efe05bb7d7eaa4f43f713f4929
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Sep 22 19:07:59 EDT 2014
acid: fix sysr1() stack corruption the syscall stubs (for amd64) currently have a unconditional spill of the first (register) argument to the stack. sysr1 (and _nsec) are exceptional in that they do not take any arguments, so the stub is writing unconditionally to ther first argument slot on the stack. i could avoid emiting the spill in the syscall stubs for sysr1 but that would also break truss which assumes fixed instruction sequence from stub start to the syscall number. i'm not going to complicate the syscall stubs just for sysr1 (_nsec is not used in 9front), but just add a dummy argument to sysr1 definition that can receive the bogus argument spill.
--- a/sys/src/cmd/acid/builtin.c
+++ b/sys/src/cmd/acid/builtin.c
@@ -122,12 +122,13 @@
void
dosysr1(Node *r, Node*)
{
- extern int sysr1(void);
+ /* dummy argument for RARG spill */
+ extern int sysr1(void*);
r->op = OCONST;
r->type = TINT;
r->fmt = 'D';
- r->ival = sysr1();
+ r->ival = sysr1(0);
}
void