c0 := c
c = pjc.padJump(ctxt, s, p, c)
- if p.As == obj.APCALIGN || p.As == obj.APCALIGNMAX {
- v := obj.AlignmentPadding(c, p, ctxt, s)
- if v > 0 {
- s.Grow(int64(c) + int64(v))
- fillnop(s.P[c:], int(v))
- }
- p.Pc = int64(c)
- c += int32(v)
- pPrev = p
- continue
-
- }
-
if maxLoopPad > 0 && p.Back&branchLoopHead != 0 && c&(loopAlign-1) != 0 {
// pad with NOPs
v := -c & (loopAlign - 1)
}
}
+ if p.As == obj.APCALIGN || p.As == obj.APCALIGNMAX {
+ v := obj.AlignmentPadding(c, p, ctxt, s)
+ if v > 0 {
+ s.Grow(int64(c) + int64(v))
+ fillnop(s.P[c:], int(v))
+ }
+ p.Pc = int64(c)
+ c += int32(v)
+ pPrev = p
+ continue
+ }
+
p.Rel = nil
p.Pc = int64(c)
--- /dev/null
+// Copyright 2025 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.
+
+TEXT ·F(SB), $0
+ JMP prealigned
+ INT $3 // should never be reached
+prealigned:
+ PCALIGN $0x10
+aligned:
+ RET
--- /dev/null
+// Copyright 2025 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 74648: wrong jump target when using PCALIGN.
+
+package main
+
+func F()
+
+func main() {
+ F()
+}
--- /dev/null
+// runindir
+
+//go:build amd64
+
+// Copyright 2025 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.
+
+package ignored