From eae9fee3bf8c58c7403bcd103050ef2196fdfed1 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 11 Aug 2014 13:53:38 -0400 Subject: [PATCH] cmd/link: fix zig-zag decoding The >>1 shift needs to happen before converting to int32, otherwise large values will decode with an incorrect sign bit. The <<31 shift can happen before or after, but before is consistent with liblink and the go12symtab doc. Bug demo at http://play.golang.org/p/jLrhPUakIu LGTM=rsc R=golang-codereviews, minux, rsc CC=golang-codereviews https://golang.org/cl/119630043 --- src/cmd/link/pclntab.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/link/pclntab.go b/src/cmd/link/pclntab.go index b0b19ad53c..a950895aa5 100644 --- a/src/cmd/link/pclntab.go +++ b/src/cmd/link/pclntab.go @@ -437,7 +437,7 @@ func (it *PCIter) Next() { return } it.start = false - sv := int32(uv)>>1 ^ int32(uv)<<31>>31 + sv := int32(uv>>1) ^ int32(uv<<31)>>31 it.Value += sv // pc delta -- 2.48.1