1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:18:35 -06:00

[dev.link] cmd/link: use new-style Reloc accessors in loadxcoff

Change-Id: I606b60807b4a8b6e5c0f489db3c5d9e75bd1e728
Reviewed-on: https://go-review.googlesource.com/c/go/+/227898
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2020-04-09 19:56:05 -04:00
parent 0505e8a3a3
commit 69f3bc04e5

View File

@ -119,15 +119,16 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read
if sect.Type != xcoff.STYP_TEXT && sect.Type != xcoff.STYP_DATA {
continue
}
rs := make([]loader.Reloc, sect.Nreloc)
for i, rx := range sect.Relocs {
r := &rs[i]
r.Sym = l.LookupOrCreateSym(rx.Symbol.Name, 0)
sb := l.MakeSymbolUpdater(sect.sym)
for _, rx := range sect.Relocs {
rSym := l.LookupOrCreateSym(rx.Symbol.Name, 0)
if uint64(int32(rx.VirtualAddress)) != rx.VirtualAddress {
return errorf("virtual address of a relocation is too big: 0x%x", rx.VirtualAddress)
}
r.Off = int32(rx.VirtualAddress)
rOff := int32(rx.VirtualAddress)
var rSize uint8
var rType objabi.RelocType
var rAdd int64
switch rx.Type {
default:
return errorf("section %s: unknown relocation of type 0x%x", sect.Name, rx.Type)
@ -137,19 +138,21 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read
if rx.Length != 64 {
return errorf("section %s: relocation R_POS has length different from 64: %d", sect.Name, rx.Length)
}
r.Size = 8
r.Type = objabi.R_CONST
r.Add = int64(rx.Symbol.Value)
rSize = 8
rType = objabi.R_CONST
rAdd = int64(rx.Symbol.Value)
case xcoff.R_RBR:
r.Size = 4
r.Type = objabi.R_CALLPOWER
r.Add = 0 //
rSize = 4
rType = objabi.R_CALLPOWER
rAdd = 0
}
r, _ := sb.AddRel(rType)
r.SetOff(rOff)
r.SetSiz(rSize)
r.SetSym(rSym)
r.SetAdd(rAdd)
}
bld := l.MakeSymbolUpdater(sect.sym)
bld.SetRelocs(rs[:sect.Nreloc])
}
return textp, nil