diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-08-09 15:21:08 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-08-09 16:05:46 +0200 |
| commit | fa9be141644138bad55f9425fc2ac0b9e8baa0f0 (patch) | |
| tree | 3db3738f021aa4ba517ff673b555cbb205efe85e /pkg/csource | |
| parent | 3a2fe60529aff48ba86c979157df9c1a7eefd658 (diff) | |
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.
Diffstat (limited to 'pkg/csource')
| -rw-r--r-- | pkg/csource/csource.go | 8 |
1 files changed, 7 insertions, 1 deletions
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)) } |
