Example #1
0
func (p *strPool) declare(lib *link8.Pkg) {
	if lib.Path() != p.pkg {
		panic("package name mismatch")
	}

	ndigit := countDigit(len(p.strs))
	nfmt := fmt.Sprintf(":str_%%0%dd", ndigit)

	for i, s := range p.strs {
		s.name = fmt.Sprintf(nfmt, i)
		s.pkg = p.pkg
		v := link8.NewVar(0)
		v.Write([]byte(s.str))

		lib.DeclareVar(s.name)
		lib.DefineVar(s.name, v)
	}
}
Example #2
0
func (p *datPool) declare(lib *link8.Pkg) {
	if lib.Path() != p.pkg {
		panic("package name mismatch")
	}

	if len(p.dat) == 0 {
		return
	}

	ndigit := countDigit(len(p.dat))
	nfmt := fmt.Sprintf(":dat_%%0%dd", ndigit)
	for i, d := range p.dat {
		d.name = fmt.Sprintf(nfmt, i)
		align := uint32(0)
		if d.regSizeAlign {
			align = regSize
		}
		v := link8.NewVar(align)
		v.Write(d.bs)

		lib.DeclareVar(d.name)
		lib.DefineVar(d.name, v)
	}
}