Skip to content

Commit 61bf26a

Browse files
committed
cmd/link: fix Macho-O X86_64_RELOC_SUBTRACTOR in internal linking
X86_64_RELOC_SUBTRACTOR is handled as a generic R_PCREL relocations, which gets the relocation size subtracted from the relocated value. This is not supposed to happen for this particular relocation, so compensate by adding the size to the addend. Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64-race Change-Id: I6e6889d63bb03b8076e3e409722601dfebec57e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/703776 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Junyang Shao <[email protected]>
1 parent 4b787c8 commit 61bf26a

File tree

1 file changed

+1
-1
lines changed
  • src/cmd/link/internal/amd64

1 file changed

+1
-1
lines changed

src/cmd/link/internal/amd64/asm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade
208208
}
209209
// The second relocation has the target symbol we want
210210
su.SetRelocType(rIdx+1, objabi.R_PCREL)
211-
su.SetRelocAdd(rIdx+1, r.Add()+int64(r.Off())-off)
211+
su.SetRelocAdd(rIdx+1, r.Add()+int64(r.Off())+int64(r.Siz())-off)
212212
// Remove the other relocation
213213
su.SetRelocSiz(rIdx, 0)
214214
return true

0 commit comments

Comments
 (0)