var conf … var noSourceConf … // writeDefs creates output files to be compiled by gc and gcc. func (p *Package) writeDefs() { … } // elfImportedSymbols is like elf.File.ImportedSymbols, but it // includes weak symbols. // // A bug in some versions of LLD (at least LLD 8) cause it to emit // several pthreads symbols as weak, but we need to import those. See // issue #31912 or https://bugs.llvm.org/show_bug.cgi?id=42442. // // When doing external linking, we hand everything off to the external // linker, which will create its own dynamic symbol tables. For // internal linking, this may turn weak imports into strong imports, // which could cause dynamic linking to fail if a symbol really isn't // defined. However, the standard library depends on everything it // imports, and this is the primary use of dynamic symbol tables with // internal linking. func elfImportedSymbols(f *elf.File) []elf.ImportedSymbol { … } func dynimport(obj string) { … } // checkImportSymName checks a symbol name we are going to emit as part // of a //go:cgo_import_dynamic pragma. These names come from object // files, so they may be corrupt. We are going to emit them unquoted, // so while they don't need to be valid symbol names (and in some cases, // involving symbol versions, they won't be) they must contain only // graphic characters and must not contain Go comments. func checkImportSymName(s string) { … } // Construct a gcc struct matching the gc argument frame. // Assumes that in gcc, char is 1 byte, short 2 bytes, int 4 bytes, long long 8 bytes. // These assumptions are checked by the gccProlog. // Also assumes that gc convention is to word-align the // input and output parameters. func (p *Package) structType(n *Name) (string, int64) { … } func (p *Package) writeDefsFunc(fgo2 io.Writer, n *Name, callsMalloc *bool) { … } // writeOutput creates stubs for a specific source file to be compiled by gc func (p *Package) writeOutput(f *File, srcfile string) { … } // fixGo converts the internal Name.Go field into the name we should show // to users in error messages. There's only one for now: on input we rewrite // C.malloc into C._CMalloc, so change it back here. func fixGo(name string) string { … } var isBuiltin … func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) { … } // Write out a wrapper for a function when using gccgo. This is a // simple wrapper that just calls the real function. We only need a // wrapper to support static functions in the prologue--without a // wrapper, we can't refer to the function, since the reference is in // a different file. func (p *Package) writeGccgoOutputFunc(fgcc *os.File, n *Name) { … } // packedAttribute returns host compiler struct attribute that will be // used to match gc's struct layout. For example, on 386 Windows, // gcc wants to 8-align int64s, but gc does not. // Use __gcc_struct__ to work around https://gcc.gnu.org/PR52991 on x86, // and https://golang.org/issue/5603. func (p *Package) packedAttribute() string { … } // exportParamName returns the value of param as it should be // displayed in a c header file. If param contains any non-ASCII // characters, this function will return the character p followed by // the value of position; otherwise, this function will return the // value of param. func exportParamName(param string, position int) string { … } // Write out the various stubs we need to support functions exported // from Go so that they are callable from C. func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { … } // Write out the C header allowing C code to call exported gccgo functions. func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) { … } // writeExportHeader writes out the start of the _cgo_export.h file. func (p *Package) writeExportHeader(fgcch io.Writer) { … } // gccgoToSymbol converts a name to a mangled symbol for gccgo. func gccgoToSymbol(ppath string) string { … } // Return the package prefix when using gccgo. func (p *Package) gccgoSymbolPrefix() string { … } // Call a function for each entry in an ast.FieldList, passing the // index into the list, the name if any, and the type. func forFieldList(fl *ast.FieldList, fn func(int, string, ast.Expr)) { … } func c(repr string, args ...interface{ … } var goTypes … // Map an ast type to a Type. func (p *Package) cgoType(e ast.Expr) *Type { … } // Map an ast type to a Type, avoiding cycles. func (p *Package) doCgoType(e ast.Expr, m map[ast.Expr]bool) *Type { … } const gccProlog … const noTsanProlog … const yesTsanProlog … var tsanProlog … const noMsanProlog … const yesMsanProlog … var msanProlog … const builtinProlog … const goProlog … const gccgoGoProlog … const goStringDef … const goStringNDef … const goBytesDef … const cStringDef … const cBytesDef … const cMallocDef … var builtinDefs … const cMallocDefGo … const cMallocDefC … func (p *Package) cPrologGccgo() string { … } const cPrologGccgo … const builtinExportProlog … func (p *Package) gccExportHeaderProlog() string { … } const gccExportHeaderProlog … const gccExportHeaderEpilog … const gccgoExportFileProlog …