1
0
mirror of https://github.com/golang/go synced 2024-11-23 04:40:09 -07:00

cmd/ld: handle duplicate static symbols in COFF and Mach-O files.

Fixes #5740.

R=iant, rsc, luisbebop
CC=gobot, golang-dev
https://golang.org/cl/10345046
This commit is contained in:
Shenghou Ma 2013-09-18 22:27:25 -04:00
parent ba10318607
commit 9add729a1f
5 changed files with 36 additions and 0 deletions

View File

@ -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 cgotest
// int test5740a(void), test5740b(void);
import "C"
import "testing"
func test5740(t *testing.T) {
if v := C.test5740a() + C.test5740b(); v != 5 {
t.Errorf("expected 5, got %v", v)
}
}

View File

@ -0,0 +1,9 @@
// 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.
static int volatile val = 2;
int test5740a() {
return val;
}

View File

@ -0,0 +1,9 @@
// 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.
static int volatile val = 3;
int test5740b() {
return val;
}

View File

@ -611,6 +611,8 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn)
if(!(sym->type&N_EXT))
v = version;
s = lookup(name, v);
if(!(sym->type&N_EXT))
s->dupok = 1;
sym->sym = s;
if(sym->sectnum == 0) // undefined
continue;

View File

@ -469,6 +469,7 @@ readsym(PeObj *obj, int i, PeSym **y)
case IMAGE_SYM_CLASS_NULL:
case IMAGE_SYM_CLASS_STATIC:
s = lookup(name, version);
s->dupok = 1;
break;
default:
werrstr("%s: invalid symbol binding %d", sym->name, sym->sclass);