mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: increase the reserved space for ELF relocations
Currently the offset values of ELF relocations and Macho relocations are 256 and 512 respectively, which means that the space reserved for ELF relocations is only 256. But AARCH64 has more than 256 ELF relocation types, in fact the maximum AARCH64 ELF relocation type recorded in file src/debug/elf/elf.go is 1032 currently. So this CL increases the offset of Macho relocations to 2048 to leave enough space for AARCH64 ELF relocations. Change-Id: I784ac38aeb3e102ac7825f6d621086849c8d3146 Reviewed-on: https://go-review.googlesource.com/c/go/+/172497 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
b5946ed48d
commit
3b37ff453e
11 changed files with 109 additions and 101 deletions
|
|
@ -95,7 +95,7 @@ func genplt(ctxt *ld.Link) {
|
|||
for _, s := range ctxt.Textp {
|
||||
for i := range s.R {
|
||||
r := &s.R[i]
|
||||
if r.Type != 256+objabi.RelocType(elf.R_PPC64_REL24) || r.Sym.Type != sym.SDYNIMPORT {
|
||||
if r.Type != objabi.ElfRelocOffset+objabi.RelocType(elf.R_PPC64_REL24) || r.Sym.Type != sym.SDYNIMPORT {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -275,13 +275,13 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
|
|||
|
||||
switch r.Type {
|
||||
default:
|
||||
if r.Type >= 256 {
|
||||
if r.Type >= objabi.ElfRelocOffset {
|
||||
ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type))
|
||||
return false
|
||||
}
|
||||
|
||||
// Handle relocations found in ELF object files.
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_REL24):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL24):
|
||||
r.Type = objabi.R_CALLPOWER
|
||||
|
||||
// This is a local call, so the caller isn't setting
|
||||
|
|
@ -298,7 +298,7 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
|
|||
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC_REL32):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC_REL32):
|
||||
r.Type = objabi.R_PCREL
|
||||
r.Add += 4
|
||||
|
||||
|
|
@ -308,7 +308,7 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
|
|||
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_ADDR64):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_ADDR64):
|
||||
r.Type = objabi.R_ADDR
|
||||
if targ.Type == sym.SDYNIMPORT {
|
||||
// These happen in .toc sections
|
||||
|
|
@ -318,54 +318,54 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
|
|||
rela.AddAddrPlus(ctxt.Arch, s, int64(r.Off))
|
||||
rela.AddUint64(ctxt.Arch, ld.ELF64_R_INFO(uint32(targ.Dynid), uint32(elf.R_PPC64_ADDR64)))
|
||||
rela.AddUint64(ctxt.Arch, uint64(r.Add))
|
||||
r.Type = 256 // ignore during relocsym
|
||||
r.Type = objabi.ElfRelocOffset // ignore during relocsym
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_TOC16):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16):
|
||||
r.Type = objabi.R_POWER_TOC
|
||||
r.Variant = sym.RV_POWER_LO | sym.RV_CHECK_OVERFLOW
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_LO):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_LO):
|
||||
r.Type = objabi.R_POWER_TOC
|
||||
r.Variant = sym.RV_POWER_LO
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_HA):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_HA):
|
||||
r.Type = objabi.R_POWER_TOC
|
||||
r.Variant = sym.RV_POWER_HA | sym.RV_CHECK_OVERFLOW
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_HI):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_HI):
|
||||
r.Type = objabi.R_POWER_TOC
|
||||
r.Variant = sym.RV_POWER_HI | sym.RV_CHECK_OVERFLOW
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_DS):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_DS):
|
||||
r.Type = objabi.R_POWER_TOC
|
||||
r.Variant = sym.RV_POWER_DS | sym.RV_CHECK_OVERFLOW
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_LO_DS):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_LO_DS):
|
||||
r.Type = objabi.R_POWER_TOC
|
||||
r.Variant = sym.RV_POWER_DS
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_REL16_LO):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL16_LO):
|
||||
r.Type = objabi.R_PCREL
|
||||
r.Variant = sym.RV_POWER_LO
|
||||
r.Add += 2 // Compensate for relocation size of 2
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_REL16_HI):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL16_HI):
|
||||
r.Type = objabi.R_PCREL
|
||||
r.Variant = sym.RV_POWER_HI | sym.RV_CHECK_OVERFLOW
|
||||
r.Add += 2
|
||||
return true
|
||||
|
||||
case 256 + objabi.RelocType(elf.R_PPC64_REL16_HA):
|
||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL16_HA):
|
||||
r.Type = objabi.R_PCREL
|
||||
r.Variant = sym.RV_POWER_HA | sym.RV_CHECK_OVERFLOW
|
||||
r.Add += 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue