aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/base')
-rw-r--r--src/cmd/compile/internal/base/link.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/base/link.go b/src/cmd/compile/internal/base/link.go
index 49fe4352b2..d8aa5a7dcc 100644
--- a/src/cmd/compile/internal/base/link.go
+++ b/src/cmd/compile/internal/base/link.go
@@ -8,6 +8,19 @@ import (
"cmd/internal/obj"
)
+// ReservedImports are import paths used internally for generated
+// symbols by the compiler.
+//
+// The linker uses the magic symbol prefixes "go:" and "type:".
+// Avoid potential confusion between import paths and symbols
+// by rejecting these reserved imports for now. Also, people
+// "can do weird things in GOPATH and we'd prefer they didn't
+// do _that_ weird thing" (per rsc). See also #4257.
+var ReservedImports = map[string]bool{
+ "go": true,
+ "type": true,
+}
+
var Ctxt *obj.Link
// TODO(mdempsky): These should probably be obj.Link methods.
@@ -20,7 +33,11 @@ func PkgLinksym(prefix, name string, abi obj.ABI) *obj.LSym {
// TODO(mdempsky): Cleanup callers and Fatalf instead.
return linksym(prefix, "_", abi)
}
- return linksym(prefix, prefix+"."+name, abi)
+ sep := "."
+ if ReservedImports[prefix] {
+ sep = ":"
+ }
+ return linksym(prefix, prefix+sep+name, abi)
}
// Linkname returns the linker symbol for the given name as it might