]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: fix zig-zag decoding
authorMatthew Dempsky <mdempsky@google.com>
Mon, 11 Aug 2014 17:53:38 +0000 (13:53 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 11 Aug 2014 17:53:38 +0000 (13:53 -0400)
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

index b0b19ad53c07b5f549134667215175d057399333..a950895aa5f31074c9c0993160c5a0bace1bbab5 100644 (file)
@@ -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