From 4cb032442a1598611c684ca16f58950358502935 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 22 Sep 2014 23:07:59 +0200 Subject: [PATCH] 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. --- sys/src/cmd/acid/builtin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/src/cmd/acid/builtin.c b/sys/src/cmd/acid/builtin.c index b8d904c7b..e36a5dbdd 100644 --- a/sys/src/cmd/acid/builtin.c +++ b/sys/src/cmd/acid/builtin.c @@ -122,12 +122,13 @@ installbuiltin(void) 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 -- 2.44.0