func nacladdr(ctxt *liblink.Link, p *liblink.Prog, a *liblink.Addr) { if p.As == ALEAL || p.As == ALEAQ { return } if a.Typ == D_BP || a.Typ == D_INDIR+D_BP { ctxt.Diag("invalid address: %P", p) return } if a.Typ == D_INDIR+D_TLS { a.Typ = D_INDIR + D_BP } else if a.Typ == D_TLS { a.Typ = D_BP } if D_INDIR <= a.Typ && a.Typ <= D_INDIR+D_INDIR { switch a.Typ { // 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 = a.Typ - D_INDIR if a.Index != D_NONE { a.Scale = 1 } a.Typ = D_INDIR + D_R15 break } } }
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.Typ = int(rdint(b)) a.Index = int(rdint(b)) a.Scale = int8(rdint(b)) a.Reg = int(rdint(b)) a.Name = int(rdint(b)) a.Class = int(rdint(b)) a.Etype = uint8(rdint(b)) a.Offset2 = int(rdint(b)) a.Width = rdint(b) }