mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
b402bd4499
commit
dde7c770ef
2 changed files with 32 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue