ctxt.Imports = append(ctxt.Imports, pkg)
}
+const FileSymPrefix = "gofile.."
+
func linkgetlineFromPos(ctxt *Link, xpos src.XPos) (f *LSym, l int32) {
pos := ctxt.PosTable.Pos(xpos)
filename := pos.AbsFilename()
if !pos.IsKnown() || filename == "" {
- return Linklookup(ctxt, "??", HistVersion), 0
+ return Linklookup(ctxt, FileSymPrefix+"??", 0), 0
}
// TODO(gri) Should this use relative or absolute line number?
- return Linklookup(ctxt, filename, HistVersion), int32(pos.RelLine())
+ return Linklookup(ctxt, FileSymPrefix+filename, 0), int32(pos.RelLine())
}
func fieldtrack(ctxt *Link, cursym *LSym) {
for _, test := range tests {
f, l := linkgetlineFromPos(ctxt, ctxt.PosTable.XPos(test.pos))
got := fmt.Sprintf("%s:%d", f.Name, l)
- if got != test.want {
+ if got != FileSymPrefix+test.want {
t.Errorf("linkgetline(%v) = %q, want %q", test.pos, got, test.want)
}
}
P []byte
}
-// symbol version, incremented each time a file is loaded.
-// version==1 is reserved for savehist.
-const (
- HistVersion = 1
-)
-
// Link holds the context for writing object code from a compiler
// to be linker input or for reading that input into the linker.
type Link struct {
ctxt := new(Link)
ctxt.Hash = make(map[SymVer]*LSym)
ctxt.Arch = arch
- ctxt.Version = HistVersion
+ ctxt.Version = 0
ctxt.Pathname = WorkingDir()
ctxt.Headtype.Set(GOOS)
ctxt.Filesyms = append(ctxt.Filesyms, file)
file.Value = int64(len(ctxt.Filesyms))
file.Type = obj.SFILEPATH
- file.Name = expandGoroot(file.Name)
+ path := file.Name[len(obj.FileSymPrefix):]
+ file.Name = expandGoroot(path)
}
}