Skip to content

Commit

Permalink
cmd/link: remove windows-specific kludges from Adddynrel
Browse files Browse the repository at this point in the history
Adddynrel does nothing on windows. We can make code don't call Adddynrel
on windows in the first place.

Change-Id: I376cc36d44a5df18bda13be57e3916ca3062f181
Reviewed-on: https://go-review.googlesource.com/62611
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
  • Loading branch information
hirochachacha authored and alexbrainman committed Sep 10, 2017
1 parent 8435a74 commit 410b737
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
20 changes: 5 additions & 15 deletions src/cmd/link/internal/amd64/asm.go
Expand Up @@ -239,16 +239,11 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
// nothing to do, the relocation will be laid out in reloc
return true
}
if ld.Headtype == objabi.Hwindows {
// nothing to do, the relocation will be laid out in pereloc1
return true
} else {
// for both ELF and Mach-O
addpltsym(ctxt, targ)
r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(targ.Plt)
return true
}
// for both ELF and Mach-O
addpltsym(ctxt, targ)
r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(targ.Plt)
return true

case objabi.R_ADDR:
if s.Type == ld.STEXT && ld.Iself {
Expand Down Expand Up @@ -359,11 +354,6 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
r.Type = 256 // ignore during relocsym
return true
}

if ld.Headtype == objabi.Hwindows {
// nothing to do, the relocation will be laid out in pereloc1
return true
}
}

return false
Expand Down
6 changes: 4 additions & 2 deletions src/cmd/link/internal/ld/data.go
Expand Up @@ -803,8 +803,10 @@ func windynrelocsym(ctxt *Link, s *Symbol) {
}

func dynrelocsym(ctxt *Link, s *Symbol) {
if Headtype == objabi.Hwindows && Linkmode != LinkExternal {
windynrelocsym(ctxt, s)
if Headtype == objabi.Hwindows {
if Linkmode == LinkInternal {
windynrelocsym(ctxt, s)
}
return
}

Expand Down
5 changes: 0 additions & 5 deletions src/cmd/link/internal/x86/asm.go
Expand Up @@ -335,11 +335,6 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
r.Type = 256 // ignore during relocsym
return true
}

if ld.Headtype == objabi.Hwindows && s.Size == int64(ld.SysArch.PtrSize) {
// nothing to do, the relocation will be laid out in pereloc1
return true
}
}

return false
Expand Down

0 comments on commit 410b737

Please sign in to comment.