Skip to content

Commit 93dfc1c

Browse files
committed
fix bug
1 parent a8ed996 commit 93dfc1c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/reflect/abi.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,20 @@ func intFromReg(r *abi.RegArgs, reg int, argSize uintptr, to unsafe.Pointer) {
479479
// argSize must be non-zero, fit in a register, and a power-of-two.
480480
func intToReg(r *abi.RegArgs, reg int, argSize uintptr, from unsafe.Pointer) {
481481
memmove(r.IntRegArgAddr(reg, argSize), from, argSize)
482+
483+
if argSize < goarch.PtrSize {
484+
regBytes := unsafe.Slice((*byte)(unsafe.Pointer(&r.Ints[reg])), goarch.PtrSize)
485+
if goarch.BigEndian {
486+
offset := goarch.PtrSize - argSize
487+
for i := uintptr(0); i < offset; i++ {
488+
regBytes[i] = 0
489+
}
490+
} else {
491+
for i := argSize; i < goarch.PtrSize; i++ {
492+
regBytes[i] = 0
493+
}
494+
}
495+
}
482496
}
483497

484498
// floatFromReg loads a float value from its register representation in r.

0 commit comments

Comments
 (0)