Skip to content

Commit ab08f79

Browse files
committed
cmd/link: stop linker crashing with -s flag on windows
Update #10254 Change-Id: I3ddd26607813ca629e3ab62abf87dc5ab453e36f Reviewed-on: https://go-review.googlesource.com/10835 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 93e57a2 commit ab08f79

File tree

1 file changed

+16
-15
lines changed
  • src/cmd/link/internal/ld

1 file changed

+16
-15
lines changed

src/cmd/link/internal/ld/pe.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,6 @@ func initdynimport() *Dll {
545545
r.Off = 0
546546
r.Siz = uint8(Thearch.Ptrsize)
547547
r.Type = obj.R_ADDR
548-
549-
// pre-allocate symtab entries for those symbols
550-
dynSym.Dynid = int32(ncoffsym)
551-
ncoffsym++
552548
}
553549
}
554550
} else {
@@ -988,20 +984,25 @@ func addpesym(s *LSym, name string, type_ int, addr int64, size int64, ver int,
988984
ncoffsym++
989985
}
990986

987+
func pegenasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) {
988+
if Linkmode == LinkExternal {
989+
for d := dr; d != nil; d = d.next {
990+
for m := d.ms; m != nil; m = m.next {
991+
s := m.s.R[0].Xsym
992+
put(s, s.Name, 'U', 0, int64(Thearch.Ptrsize), 0, nil)
993+
}
994+
}
995+
}
996+
genasmsym(put)
997+
}
998+
991999
func addpesymtable() {
992-
if Debug['s'] == 0 {
993-
genasmsym(addpesym)
1000+
if Debug['s'] == 0 || Linkmode == LinkExternal {
1001+
ncoffsym = 0
1002+
pegenasmsym(addpesym)
9941003
coffsym = make([]COFFSym, ncoffsym)
9951004
ncoffsym = 0
996-
if Linkmode == LinkExternal {
997-
for d := dr; d != nil; d = d.next {
998-
for m := d.ms; m != nil; m = m.next {
999-
s := m.s.R[0].Xsym
1000-
addpesym(s, s.Name, 'U', 0, int64(Thearch.Ptrsize), 0, nil)
1001-
}
1002-
}
1003-
}
1004-
genasmsym(addpesym)
1005+
pegenasmsym(addpesym)
10051006
}
10061007
size := len(strtbl) + 4 + 18*ncoffsym
10071008

0 commit comments

Comments
 (0)