diff options
author | Austin Clements <austin@google.com> | 2019-05-31 15:45:06 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2019-06-06 19:44:10 +0000 |
commit | dde7c770ef44d45b8a9f98bf0f46556f18df2f6e (patch) | |
tree | 6eb6394de6c492340ead1a1cb230afdda24a84b8 /src/cmd/compile/doc.go | |
parent | b402bd4499a59c6f1fac4dc2684390b5d4d1c2eb (diff) | |
download | go-dde7c770ef44d45b8a9f98bf0f46556f18df2f6e.tar.gz go-dde7c770ef44d45b8a9f98bf0f46556f18df2f6e.zip |
cmd/compile: make the second argument to go:linkname optional
The //go:linkname directive can be used to make a symbol accessible to
another package (when it wouldn't normally be). Sometimes you want to
do this without actually changing the symbol's object file symbol
name; for example, in gccgo this makes unexported symbols non-static,
and in gc this provides ABI0 wrappers for Go symbols so they can be
called from assembly in other packages. Currently, this results in
stutter like
//go:linkname entersyscall runtime.entersyscall
This CL makes the second argument to go:linkname optional for the case
where the intent is simply to expose the symbol rather than to rename
it in the object file.
Updates #31230.
Change-Id: Id06d9c4b2ec3d8e27f9b8a0d65212ab8048d734f
Reviewed-on: https://go-review.googlesource.com/c/go/+/179861
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/doc.go')
-rw-r--r-- | src/cmd/compile/doc.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/compile/doc.go b/src/cmd/compile/doc.go index 5291a8b0eb..5b437d6804 100644 --- a/src/cmd/compile/doc.go +++ b/src/cmd/compile/doc.go @@ -216,11 +216,15 @@ not include a stack overflow check. This is most commonly used by low-level runtime sources invoked at times when it is unsafe for the calling goroutine to be preempted. - //go:linkname localname importpath.name + //go:linkname localname [importpath.name] The //go:linkname directive instructs the compiler to use ``importpath.name'' as the object file symbol name for the variable or function declared as ``localname'' in the -source code. Because this directive can subvert the type system and package +source code. +If the ``importpath.name'' argument is omitted, the directive uses the +symbol's default object file symbol name and only has the effect of making +the symbol accessible to other packages. +Because this directive can subvert the type system and package modularity, it is only enabled in files that have imported "unsafe". */ package main |