mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link/internal/arm64: support Mach-O ARM64_RELOC_POINTER_TO_GOT in internal linking
ARM64_RELOC_POINTER_TO_GOT is the arm64 version of X86_64_RELOC_GOT, which has been support for many years now. The standard library still doesn't need it, but I've found it necessary when statically linking against a library I own. Change-Id: I8eb7bf3c74aed663a1fc00b5dd986057130f7f7a Reviewed-on: https://go-review.googlesource.com/c/go/+/703315 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
742f92063e
commit
6e95748335
2 changed files with 12 additions and 0 deletions
|
|
@ -277,6 +277,17 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade
|
||||||
su.SetRelocSym(rIdx, syms.GOT)
|
su.SetRelocSym(rIdx, syms.GOT)
|
||||||
su.SetRelocAdd(rIdx, int64(ldr.SymGot(targ)))
|
su.SetRelocAdd(rIdx, int64(ldr.SymGot(targ)))
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
case objabi.MachoRelocOffset + ld.MACHO_ARM64_RELOC_POINTER_TO_GOT*2 + pcrel:
|
||||||
|
if targType != sym.SDYNIMPORT {
|
||||||
|
ldr.Errorf(s, "unexpected GOT reloc for non-dynamic symbol %s", ldr.SymName(targ))
|
||||||
|
}
|
||||||
|
ld.AddGotSym(target, ldr, syms, targ, 0)
|
||||||
|
su := ldr.MakeSymbolUpdater(s)
|
||||||
|
su.SetRelocType(rIdx, objabi.R_PCREL)
|
||||||
|
su.SetRelocSym(rIdx, syms.GOT)
|
||||||
|
su.SetRelocAdd(rIdx, r.Add()+int64(r.Siz())+int64(ldr.SymGot(targ)))
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reread the reloc to incorporate any changes in type above.
|
// Reread the reloc to incorporate any changes in type above.
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ const (
|
||||||
MACHO_ARM64_RELOC_PAGEOFF12 = 4
|
MACHO_ARM64_RELOC_PAGEOFF12 = 4
|
||||||
MACHO_ARM64_RELOC_GOT_LOAD_PAGE21 = 5
|
MACHO_ARM64_RELOC_GOT_LOAD_PAGE21 = 5
|
||||||
MACHO_ARM64_RELOC_GOT_LOAD_PAGEOFF12 = 6
|
MACHO_ARM64_RELOC_GOT_LOAD_PAGEOFF12 = 6
|
||||||
|
MACHO_ARM64_RELOC_POINTER_TO_GOT = 7
|
||||||
MACHO_ARM64_RELOC_ADDEND = 10
|
MACHO_ARM64_RELOC_ADDEND = 10
|
||||||
MACHO_GENERIC_RELOC_VANILLA = 0
|
MACHO_GENERIC_RELOC_VANILLA = 0
|
||||||
MACHO_FAKE_GOTPCREL = 100
|
MACHO_FAKE_GOTPCREL = 100
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue