aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource
diff options
context:
space:
mode:
authorAlexander Egorenkov <Alexander.Egorenkov@ibm.com>2020-07-04 13:54:43 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-07-10 10:25:58 +0200
commit56d01184e3b69688dec04bd97a3017df9462f4fc (patch)
tree791934110ceb23e2e45aae0b76242c240003b3f4 /pkg/csource
parentedf162e8c360dd578d20a86c4ad79b54747a2d64 (diff)
executor: fix bitfields for big-endian arch
Add bitfield tests for big-endian arch Issue: #1885 Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
Diffstat (limited to 'pkg/csource')
-rw-r--r--pkg/csource/csource.go8
1 files changed, 6 insertions, 2 deletions
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)