]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/5l, cmd/6l, cmd/8l: fix segfault on reading LOCALS for a duplicate definition.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 25 Mar 2013 21:09:55 +0000 (22:09 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 25 Mar 2013 21:09:55 +0000 (22:09 +0100)
Fixes #5105.

R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7965043

src/cmd/5l/obj.c
src/cmd/6l/obj.c
src/cmd/8l/obj.c
test/fixedbugs/issue5105.dir/a.go [new file with mode: 0644]
test/fixedbugs/issue5105.dir/b.go [new file with mode: 0644]
test/fixedbugs/issue5105.go [new file with mode: 0644]

index d38da204a373c304fc943649020b0df78316cd98..f5128c6780f53ee366fb3b1fa5b6cb06a88d9728 100644 (file)
@@ -608,11 +608,15 @@ loop:
                break;
 
        case ALOCALS:
+               if(skip)
+                       goto casedef;
                cursym->locals = p->to.offset;
                pc++;
                break;
 
        case ATYPE:
+               if(skip)
+                       goto casedef;
                pc++;
                goto loop;
 
index 3775df9de5cffacd25640a1fe50e7878b29f691a..ab8b22e231b48f6e5a6c1b4fc0099363141d77fc 100644 (file)
@@ -597,11 +597,15 @@ loop:
                goto loop;
 
        case ALOCALS:
+               if(skip)
+                       goto casdef;
                cursym->locals = p->to.offset;
                pc++;
                goto loop;
        
        case ATYPE:
+               if(skip)
+                       goto casdef;
                pc++;
                goto loop;
 
index 306e288a357f819c3513e8e790f5c82c48647e3b..fda96d09caad32c2ee5ac8eaabd1663155e99670 100644 (file)
@@ -607,11 +607,15 @@ loop:
                goto loop;
 
        case ALOCALS:
+               if(skip)
+                       goto casdef;
                cursym->locals = p->to.offset;
                pc++;
                goto loop;
 
        case ATYPE:
+               if(skip)
+                       goto casdef;
                pc++;
                goto loop;
 
diff --git a/test/fixedbugs/issue5105.dir/a.go b/test/fixedbugs/issue5105.dir/a.go
new file mode 100644 (file)
index 0000000..f20abb9
--- /dev/null
@@ -0,0 +1,7 @@
+// Copyright 2013 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 a
+
+var A = [2]string{"hello", "world"}
diff --git a/test/fixedbugs/issue5105.dir/b.go b/test/fixedbugs/issue5105.dir/b.go
new file mode 100644 (file)
index 0000000..b12e739
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2013 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 main
+
+import "./a"
+
+var B = [2]string{"world", "hello"}
+
+func main() {
+       if a.A[0] != B[1] {
+               panic("bad hello")
+       }
+}
diff --git a/test/fixedbugs/issue5105.go b/test/fixedbugs/issue5105.go
new file mode 100644 (file)
index 0000000..e3e5e5c
--- /dev/null
@@ -0,0 +1,10 @@
+// rundir
+
+// Copyright 2013 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 5105: linker segfaults on duplicate definition
+// of a type..hash.* function.
+
+package ignored