)
func iexport(out *bufio.Writer) {
- // Mark inline bodies that are reachable through exported objects.
- // (Phase 0 of bexport.go.)
- {
- // TODO(mdempsky): Separate from bexport logic.
- p := &exporter{marked: make(map[*types.Type]bool)}
- for _, n := range Target.Exports {
- p.markObject(n)
- }
- }
-
p := iexporter{
allPkgs: map[*types.Pkg]bool{},
stringIndex: map[string]uint64{},
return s
}
-// fninit makes an initialization record for the package.
+// fninit makes and returns an initialization record for the package.
// See runtime/proc.go:initTask for its layout.
// The 3 tasks for initialization are:
// 1) Initialize all of the packages the current package depends on.
// 2) Initialize all the variables that have initializers.
// 3) Run any init functions.
-func fninit(n []ir.Node) {
- nf := initOrder(n)
+func fninit() *ir.Name {
+ nf := initOrder(Target.Decls)
var deps []*obj.LSym // initTask records for packages the current package depends on
var fns []*obj.LSym // functions to call for package initialization
// Find imported packages with init tasks.
for _, pkg := range Target.Imports {
- n := resolve(oldname(pkg.Lookup(".inittask")))
+ n := resolve(ir.NewIdent(base.Pos, pkg.Lookup(".inittask")))
if n.Op() == ir.ONONAME {
continue
}
}
if len(deps) == 0 && len(fns) == 0 && types.LocalPkg.Name != "main" && types.LocalPkg.Name != "runtime" {
- return // nothing to initialize
+ return nil // nothing to initialize
}
// Make an .inittask structure.
sym := lookup(".inittask")
- nn := NewName(sym)
- nn.SetType(types.Types[types.TUINT8]) // fake type
- nn.SetClass(ir.PEXTERN)
- sym.Def = nn
- exportsym(nn)
+ task := NewName(sym)
+ task.SetType(types.Types[types.TUINT8]) // fake type
+ task.SetClass(ir.PEXTERN)
+ sym.Def = task
lsym := sym.Linksym()
ot := 0
ot = duintptr(lsym, ot, 0) // state: not initialized yet
// An initTask has pointers, but none into the Go heap.
// It's not quite read only, the state field must be modifiable.
ggloblsym(lsym, int32(ot), obj.NOPTR)
+ return task
}