From fa9be141644138bad55f9425fc2ac0b9e8baa0f0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 9 Aug 2018 15:21:08 +0200 Subject: pkg/csource: fix 32-bit syscall calls syscall accepts args as ellipsis, resources are uint64 and take 2 slots without the cast, which is wrong. Cast resources to long when passing to syscall. --- pkg/csource/csource.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pkg/csource') diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index 0b3793afd..46d1711f7 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -234,7 +234,13 @@ func (ctx *context) emitCall(w *bytes.Buffer, call prog.ExecCall, ci int, haveCo if arg.Format != prog.FormatNative && arg.Format != prog.FormatBigEndian { panic("sring format in syscall argument") } - fmt.Fprintf(w, "%v", ctx.resultArgToStr(arg)) + val := ctx.resultArgToStr(arg) + if native && ctx.target.PtrSize == 4 { + // syscall accepts args as ellipsis, resources are uint64 + // and take 2 slots without the cast, which would be wrong. + val = "(long)" + val + } + fmt.Fprintf(w, "%v", val) default: panic(fmt.Sprintf("unknown arg type: %+v", arg)) } -- cgit mrf-deployment