func readaddr(b *bufio.Reader, a *liblink.Addr) { if rdstring(b) != "addr" { log.Fatal("out of sync") } a.Offset = rdint(b) a.U.Dval = rdfloat(b) buf := make([]byte, 8) for i := 0; i < 8; i++ { buf[i] = byte(rdint(b)) } a.U.Sval = string(buf) a.U.Branch = rdprog(b) a.Sym = rdsym(b) a.Gotype = rdsym(b) a.Type_ = int16(rdint(b)) a.Index = uint8(rdint(b)) a.Scale = int8(rdint(b)) a.Reg = int8(rdint(b)) a.Name = int8(rdint(b)) a.Class = int8(rdint(b)) a.Etype = uint8(rdint(b)) a.Offset2 = int32(rdint(b)) a.Width = rdint(b) }
func nacladdr(ctxt *liblink.Link, p *liblink.Prog, a *liblink.Addr) { if p.As == ALEAL || p.As == ALEAQ { return } if a.Type_ == D_BP || a.Type_ == D_INDIR+D_BP { ctxt.Diag("invalid address: %P", p) return } if a.Type_ == D_INDIR+D_TLS { a.Type_ = D_INDIR + D_BP } else if a.Type_ == D_TLS { a.Type_ = D_BP } if D_INDIR <= a.Type_ && a.Type_ <= D_INDIR+D_INDIR { switch a.Type_ { // all ok case D_INDIR + D_BP, D_INDIR + D_SP, D_INDIR + D_R15: break default: if a.Index != D_NONE { ctxt.Diag("invalid address %P", p) } a.Index = uint8(a.Type_ - D_INDIR) if a.Index != D_NONE { a.Scale = 1 } a.Type_ = D_INDIR + D_R15 break } } }