Commit 9add729a authored by Shenghou Ma's avatar Shenghou Ma

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
parent ba103186
// 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)
}
}
// 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;
}
// 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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment