From: Cherry Mui Date: Mon, 23 Jan 2023 18:31:00 +0000 (-0500) Subject: cmd/internal/obj/arm: handle HAUTO etc. in addpool X-Git-Tag: go1.21rc1~129 X-Git-Url: http://www.git.cypherpunks.ru/?a=commitdiff_plain;h=fdb3dc471d099cf04cfa575a2bc8d51999917e1e;p=gostls13.git cmd/internal/obj/arm: handle HAUTO etc. in addpool HAUTO should be handled the same way as other stack offsets for adding to constant pool. Add the missing cases. Fixes #57955. Change-Id: If7fc82cafb2bbf0a6121e73e353b8825cb36b5bc Reviewed-on: https://go-review.googlesource.com/c/go/+/463138 TryBot-Result: Gopher Robot Reviewed-by: Keith Randall Reviewed-by: Keith Randall Run-TryBot: Cherry Mui --- diff --git a/src/cmd/internal/obj/arm/asm5.go b/src/cmd/internal/obj/arm/asm5.go index 7b1682776e..177ffd9797 100644 --- a/src/cmd/internal/obj/arm/asm5.go +++ b/src/cmd/internal/obj/arm/asm5.go @@ -688,13 +688,16 @@ func (c *ctxt5) addpool(p *obj.Prog, a *obj.Addr) { t.Rel = p } - case C_SROREG, - C_LOREG, - C_ROREG, + case C_HOREG, C_FOREG, + C_HFOREG, C_SOREG, - C_HOREG, + C_ROREG, + C_SROREG, + C_LOREG, + C_HAUTO, C_FAUTO, + C_HFAUTO, C_SAUTO, C_LAUTO, C_LACON: diff --git a/test/fixedbugs/issue57955.go b/test/fixedbugs/issue57955.go new file mode 100644 index 0000000000..bee28c6e99 --- /dev/null +++ b/test/fixedbugs/issue57955.go @@ -0,0 +1,43 @@ +// compile + +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 57955: ARM assembler fails to handle certain cases. + +package main + +func main() { + Decode[int16](nil) + Decode[uint16](nil) + Decode[float64](nil) +} + +func DecodeInt16(b []byte) (int16, int) { + return 0, 0 +} + +func DecodeUint16(b []byte) (uint16, int) { + return 0, 0 +} + +func DecodeFloat64(b []byte) (float64, int) { + return 0, 0 +} + +func Decode[T any](b []byte) (T, int) { + switch any(*new(T)).(type) { + case int16: + v, n := DecodeInt16(b) + return any(v).(T), n + case uint16: + v, n := DecodeUint16(b) + return any(v).(T), n + case float64: + v, n := DecodeFloat64(b) + return any(v).(T), n + default: + panic("") + } +}