From 56d01184e3b69688dec04bd97a3017df9462f4fc Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Sat, 4 Jul 2020 13:54:43 +0200 Subject: executor: fix bitfields for big-endian arch Add bitfield tests for big-endian arch Issue: #1885 Signed-off-by: Alexander Egorenkov --- pkg/csource/csource.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pkg/csource') diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index 4126e2b02..2eda7c76d 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -313,12 +313,16 @@ func (ctx *context) copyin(w *bytes.Buffer, csumSeq *int, copyin prog.ExecCopyin panic("bitfield+string format") } htobe := "" - if arg.Format == prog.FormatBigEndian { + if ctx.target.LittleEndian && arg.Format == prog.FormatBigEndian { htobe = fmt.Sprintf("htobe%v", arg.Size*8) } + bitfieldOffset := arg.BitfieldOffset + if !ctx.target.LittleEndian { + bitfieldOffset = arg.Size*8 - arg.BitfieldOffset - arg.BitfieldLength + } fmt.Fprintf(w, "\tNONFAILING(STORE_BY_BITMASK(uint%v, %v, 0x%x, %v, %v, %v));\n", arg.Size*8, htobe, copyin.Addr, ctx.constArgToStr(arg, false, false), - arg.BitfieldOffset, arg.BitfieldLength) + bitfieldOffset, arg.BitfieldLength) } case prog.ExecArgResult: ctx.copyinVal(w, copyin.Addr, arg.Size, ctx.resultArgToStr(arg), arg.Format) -- cgit mrf-deployment