The code I wrote in ldmacho.go in CL 266373 was plainly wrong. It
didn't carry rAdd over correctly. Fixed. Also added sign extension
(as ld64 does).
Internal linking with -race mode now works. Enable it.
Updates #38485.
Change-Id: I78aa949687bf6a0987913059059160b018c7560e
Reviewed-on: https://go-review.googlesource.com/c/go/+/267097
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
// When the race flag is set, the LLVM tsan relocatable file is linked
// into the final binary, which means external linking is required because
// internal linking does not support it.
- if *flagRace && (ctxt.Arch.InFamily(sys.PPC64) || ctxt.IsDarwin() && ctxt.IsARM64()) {
+ if *flagRace && ctxt.Arch.InFamily(sys.PPC64) {
return true, "race on " + objabi.GOARCH
}
if arch.Family == sys.ARM64 && rel.type_ == MACHO_ARM64_RELOC_ADDEND {
// Two relocations. This addend will be applied to the next one.
- rAdd = int64(rel.symnum)
+ rAdd = int64(rel.symnum) << 40 >> 40 // convert unsigned 24-bit to signed 24-bit
continue
- } else {
- rAdd = 0
}
rSize = rel.length
r.SetSiz(rSize)
r.SetSym(rSym)
r.SetAdd(rAdd)
+
+ rAdd = 0 // clear rAdd for next iteration
}
sb.SortRelocs()