Skip to content

Commit

Permalink
cmd/link: stop linker crashing with -s flag on windows
Browse files Browse the repository at this point in the history
Update golang#10254

Change-Id: I3ddd26607813ca629e3ab62abf87dc5ab453e36f
Reviewed-on: https://go-review.googlesource.com/10835
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
alexbrainman committed Jun 10, 2015
1 parent 93e57a2 commit ab08f79
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/cmd/link/internal/ld/pe.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,6 @@ func initdynimport() *Dll {
r.Off = 0
r.Siz = uint8(Thearch.Ptrsize)
r.Type = obj.R_ADDR

// pre-allocate symtab entries for those symbols
dynSym.Dynid = int32(ncoffsym)
ncoffsym++
}
}
} else {
Expand Down Expand Up @@ -988,20 +984,25 @@ func addpesym(s *LSym, name string, type_ int, addr int64, size int64, ver int,
ncoffsym++
}

func pegenasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) {
if Linkmode == LinkExternal {
for d := dr; d != nil; d = d.next {
for m := d.ms; m != nil; m = m.next {
s := m.s.R[0].Xsym
put(s, s.Name, 'U', 0, int64(Thearch.Ptrsize), 0, nil)
}
}
}
genasmsym(put)
}

func addpesymtable() {
if Debug['s'] == 0 {
genasmsym(addpesym)
if Debug['s'] == 0 || Linkmode == LinkExternal {
ncoffsym = 0
pegenasmsym(addpesym)
coffsym = make([]COFFSym, ncoffsym)
ncoffsym = 0
if Linkmode == LinkExternal {
for d := dr; d != nil; d = d.next {
for m := d.ms; m != nil; m = m.next {
s := m.s.R[0].Xsym
addpesym(s, s.Name, 'U', 0, int64(Thearch.Ptrsize), 0, nil)
}
}
}
genasmsym(addpesym)
pegenasmsym(addpesym)
}
size := len(strtbl) + 4 + 18*ncoffsym

Expand Down

0 comments on commit ab08f79

Please sign in to comment.