File tree 3 files changed +18
-12
lines changed
3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import (
12
12
13
13
func TestLinkgetlineFromPos (t * testing.T ) {
14
14
ctxt := new (Link )
15
- ctxt .hash = make (map [SymVer ]* LSym )
15
+ ctxt .hash = make (map [string ]* LSym )
16
+ ctxt .vhash = make (map [string ]* LSym )
16
17
17
18
afile := src .NewFileBase ("a.go" , "a.go" )
18
19
bfile := src .NewFileBase ("b.go" , "/foo/bar/b.go" )
Original file line number Diff line number Diff line change @@ -480,7 +480,8 @@ type Link struct {
480
480
Flag_optimize bool
481
481
Bso * bufio.Writer
482
482
Pathname string
483
- hash map [SymVer ]* LSym
483
+ hash map [string ]* LSym // name -> sym mapping for version == 0
484
+ vhash map [string ]* LSym // name -> sym mapping for version == 1
484
485
PosTable src.PosTable
485
486
InlTree InlTree // global inlining tree used by gc/inl.go
486
487
Imports []string
@@ -522,11 +523,6 @@ func (ctxt *Link) FixedFrameSize() int64 {
522
523
}
523
524
}
524
525
525
- type SymVer struct {
526
- Name string
527
- Version int // TODO: make int16 to match LSym.Version?
528
- }
529
-
530
526
// LinkArch is the definition of a single architecture.
531
527
type LinkArch struct {
532
528
* sys.Arch
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ import (
40
40
41
41
func Linknew (arch * LinkArch ) * Link {
42
42
ctxt := new (Link )
43
- ctxt .hash = make (map [SymVer ]* LSym )
43
+ ctxt .hash = make (map [string ]* LSym )
44
+ ctxt .vhash = make (map [string ]* LSym )
44
45
ctxt .Arch = arch
45
46
ctxt .Pathname = objabi .WorkingDir ()
46
47
@@ -63,13 +64,21 @@ func (ctxt *Link) Lookup(name string, v int) *LSym {
63
64
// LookupInit looks up the symbol with name name and version v.
64
65
// If it does not exist, it creates it and passes it to initfn for one-time initialization.
65
66
func (ctxt * Link ) LookupInit (name string , v int , init func (s * LSym )) * LSym {
66
- s := ctxt .hash [SymVer {name , v }]
67
- if s != nil {
67
+ var m map [string ]* LSym
68
+ switch v {
69
+ case 0 :
70
+ m = ctxt .hash
71
+ case 1 :
72
+ m = ctxt .vhash
73
+ default :
74
+ ctxt .Diag ("LookupInit: bad version %d" , v )
75
+ }
76
+ if s := m [name ]; s != nil {
68
77
return s
69
78
}
70
79
71
- s = & LSym {Name : name , Version : int16 (v )}
72
- ctxt . hash [ SymVer { name , v } ] = s
80
+ s : = & LSym {Name : name , Version : int16 (v )}
81
+ m [ name ] = s
73
82
if init != nil {
74
83
init (s )
75
84
}
You can’t perform that action at this time.
0 commit comments