mirror of
https://github.com/golang/go
synced 2024-11-23 06:50:05 -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:
parent
ba10318607
commit
9add729a1f
15
misc/cgo/test/issue5740.go
Normal file
15
misc/cgo/test/issue5740.go
Normal 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)
|
||||
}
|
||||
}
|
9
misc/cgo/test/issue5740a.c
Normal file
9
misc/cgo/test/issue5740a.c
Normal 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;
|
||||
}
|
9
misc/cgo/test/issue5740b.c
Normal file
9
misc/cgo/test/issue5740b.c
Normal 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;
|
||||
}
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user