// Add reference to Go arguments for assembly functions without them.
if ctxt.IsAsm {
+ pkgPrefix := objabi.PathToPrefix(ctxt.Pkgpath) + "."
for _, s := range text {
- if !strings.HasPrefix(s.Name, "\"\".") {
+ if !strings.HasPrefix(s.Name, `"".`) && !strings.HasPrefix(s.Name, pkgPrefix) {
continue
}
// The current args_stackmap generation in the compiler assumes
if s.ABI() != ABI0 {
continue
}
+ // runtime.addmoduledata is a host ABI function, so it doesn't
+ // need FUNCDATA anyway. Moreover, cmd/link has special logic
+ // for linking it in eccentric build modes, which breaks if it
+ // has FUNCDATA references (e.g., cmd/cgo/internal/testplugin).
+ //
+ // TODO(cherryyz): Fix cmd/link's handling of plugins (see
+ // discussion on CL 523355).
+ if s.Name == "runtime.addmoduledata" {
+ continue
+ }
foundArgMap, foundArgInfo := false, false
for p := s.Func().Text; p != nil; p = p.Link {
if p.As == AFUNCDATA && p.From.Type == TYPE_CONST {
for j := range funcdata {
dataoff := off + int64(4*j)
fdsym := funcdata[j]
+
+ // cmd/internal/obj optimistically populates ArgsPointerMaps and
+ // ArgInfo for assembly functions, hoping that the compiler will
+ // emit appropriate symbols from their Go stub declarations. If
+ // it didn't though, just ignore it.
+ //
+ // TODO(cherryyz): Fix arg map generation (see discussion on CL 523335).
+ if fdsym != 0 && (j == abi.FUNCDATA_ArgsPointerMaps || j == abi.FUNCDATA_ArgInfo) && ldr.IsFromAssembly(s) && ldr.Data(fdsym) == nil {
+ fdsym = 0
+ }
+
if fdsym == 0 {
sb.SetUint32(ctxt.Arch, dataoff, ^uint32(0)) // ^0 is a sentinel for "no value"
continue
// defines the pointer map for the function's arguments.
// GO_ARGS should be the first instruction in a function that uses it.
// It can be omitted if there are no arguments at all.
-// GO_ARGS is inserted implicitly by the linker for any function whose
-// name starts with a middle-dot and that also has a Go prototype; it
-// is therefore usually not necessary to write explicitly.
+// GO_ARGS is inserted implicitly by the assembler for any function
+// whose package-qualified symbol name belongs to the current package;
+// it is therefore usually not necessary to write explicitly.
#define GO_ARGS FUNCDATA $FUNCDATA_ArgsPointerMaps, go_args_stackmap(SB)
// GO_RESULTS_INITIALIZED indicates that the assembly function