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
diff --git a/misc/cgo/test/issue5740b.c b/misc/cgo/test/issue5740b.c
new file mode 100644
index 0000000..22893f3
--- /dev/null
+++ b/misc/cgo/test/issue5740b.c
@@ -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;
+}