cmd/internal/ld, cmd/6l: external linking for windows/amd64

Change-Id: I2d2ea233f976aab3f356f9b508cdd246d5013e30
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7534
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Shenghou Ma 2015-03-13 22:10:48 -04:00 committed by Minux Ma
parent 484d9399de
commit e7df053977
4 changed files with 66 additions and 10 deletions

View file

@ -499,8 +499,13 @@ func relocsym(s *LSym) {
} else {
o += int64(r.Siz)
}
} else if HEADTYPE == Hwindows {
// nothing to do
} else if HEADTYPE == Hwindows && Thearch.Thechar == '6' { // only amd64 needs PCREL
// PE/COFF's PC32 relocation uses the address after the relocated
// bytes as the base. Compensate by skewing the addend.
o += int64(r.Siz)
// GNU ld always add VirtualAddress of the .text section to the
// relocated address, compensate that.
o -= int64(s.Sect.(*Section).Vaddr - PEBASE)
} else {
Diag("unhandled pcrel relocation for %s", headstring)
}