mirror of
https://github.com/golang/go
synced 2024-11-11 20:20:23 -07:00
cmd/link: add relocation type R_AARCH64_LDST16_ABS_LO12_NC for arm64
The linker already has R_AARCH64_LDST{8,32,64,128}_ABS_LO12_NC, some cgo tests require R_AARCH64_LDST16_ABS_LO12_NC, this CL adds this relocation type. Fixes #42660 Change-Id: I9a5120cd872f5095c61175cb602427c6ab3225cc Reviewed-on: https://go-review.googlesource.com/c/go/+/271017 Reviewed-by: eric fang <eric.fang@arm.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: eric fang <eric.fang@arm.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: eric fang <eric.fang@arm.com> Trust: Benny Siegert <bsiegert@gmail.com>
This commit is contained in:
parent
f6dcc975f7
commit
1308f11897
@ -156,6 +156,9 @@ const (
|
|||||||
// R_ARM64_LDST8 sets a LD/ST immediate value to bits [11:0] of a local address.
|
// R_ARM64_LDST8 sets a LD/ST immediate value to bits [11:0] of a local address.
|
||||||
R_ARM64_LDST8
|
R_ARM64_LDST8
|
||||||
|
|
||||||
|
// R_ARM64_LDST16 sets a LD/ST immediate value to bits [11:1] of a local address.
|
||||||
|
R_ARM64_LDST16
|
||||||
|
|
||||||
// R_ARM64_LDST32 sets a LD/ST immediate value to bits [11:2] of a local address.
|
// R_ARM64_LDST32 sets a LD/ST immediate value to bits [11:2] of a local address.
|
||||||
R_ARM64_LDST32
|
R_ARM64_LDST32
|
||||||
|
|
||||||
|
@ -46,32 +46,33 @@ func _() {
|
|||||||
_ = x[R_ARM64_GOT-36]
|
_ = x[R_ARM64_GOT-36]
|
||||||
_ = x[R_ARM64_PCREL-37]
|
_ = x[R_ARM64_PCREL-37]
|
||||||
_ = x[R_ARM64_LDST8-38]
|
_ = x[R_ARM64_LDST8-38]
|
||||||
_ = x[R_ARM64_LDST32-39]
|
_ = x[R_ARM64_LDST16-39]
|
||||||
_ = x[R_ARM64_LDST64-40]
|
_ = x[R_ARM64_LDST32-40]
|
||||||
_ = x[R_ARM64_LDST128-41]
|
_ = x[R_ARM64_LDST64-41]
|
||||||
_ = x[R_POWER_TLS_LE-42]
|
_ = x[R_ARM64_LDST128-42]
|
||||||
_ = x[R_POWER_TLS_IE-43]
|
_ = x[R_POWER_TLS_LE-43]
|
||||||
_ = x[R_POWER_TLS-44]
|
_ = x[R_POWER_TLS_IE-44]
|
||||||
_ = x[R_ADDRPOWER_DS-45]
|
_ = x[R_POWER_TLS-45]
|
||||||
_ = x[R_ADDRPOWER_GOT-46]
|
_ = x[R_ADDRPOWER_DS-46]
|
||||||
_ = x[R_ADDRPOWER_PCREL-47]
|
_ = x[R_ADDRPOWER_GOT-47]
|
||||||
_ = x[R_ADDRPOWER_TOCREL-48]
|
_ = x[R_ADDRPOWER_PCREL-48]
|
||||||
_ = x[R_ADDRPOWER_TOCREL_DS-49]
|
_ = x[R_ADDRPOWER_TOCREL-49]
|
||||||
_ = x[R_RISCV_PCREL_ITYPE-50]
|
_ = x[R_ADDRPOWER_TOCREL_DS-50]
|
||||||
_ = x[R_RISCV_PCREL_STYPE-51]
|
_ = x[R_RISCV_PCREL_ITYPE-51]
|
||||||
_ = x[R_RISCV_TLS_IE_ITYPE-52]
|
_ = x[R_RISCV_PCREL_STYPE-52]
|
||||||
_ = x[R_RISCV_TLS_IE_STYPE-53]
|
_ = x[R_RISCV_TLS_IE_ITYPE-53]
|
||||||
_ = x[R_PCRELDBL-54]
|
_ = x[R_RISCV_TLS_IE_STYPE-54]
|
||||||
_ = x[R_ADDRMIPSU-55]
|
_ = x[R_PCRELDBL-55]
|
||||||
_ = x[R_ADDRMIPSTLS-56]
|
_ = x[R_ADDRMIPSU-56]
|
||||||
_ = x[R_ADDRCUOFF-57]
|
_ = x[R_ADDRMIPSTLS-57]
|
||||||
_ = x[R_WASMIMPORT-58]
|
_ = x[R_ADDRCUOFF-58]
|
||||||
_ = x[R_XCOFFREF-59]
|
_ = x[R_WASMIMPORT-59]
|
||||||
|
_ = x[R_XCOFFREF-60]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _RelocType_name = "R_ADDRR_ADDRPOWERR_ADDRARM64R_ADDRMIPSR_ADDROFFR_WEAKADDROFFR_SIZER_CALLR_CALLARMR_CALLARM64R_CALLINDR_CALLPOWERR_CALLMIPSR_CALLRISCVR_CONSTR_PCRELR_TLS_LER_TLS_IER_GOTOFFR_PLT0R_PLT1R_PLT2R_USEFIELDR_USETYPER_USEIFACER_USEIFACEMETHODR_METHODOFFR_POWER_TOCR_GOTPCRELR_JMPMIPSR_DWARFSECREFR_DWARFFILEREFR_ARM64_TLS_LER_ARM64_TLS_IER_ARM64_GOTPCRELR_ARM64_GOTR_ARM64_PCRELR_ARM64_LDST8R_ARM64_LDST32R_ARM64_LDST64R_ARM64_LDST128R_POWER_TLS_LER_POWER_TLS_IER_POWER_TLSR_ADDRPOWER_DSR_ADDRPOWER_GOTR_ADDRPOWER_PCRELR_ADDRPOWER_TOCRELR_ADDRPOWER_TOCREL_DSR_RISCV_PCREL_ITYPER_RISCV_PCREL_STYPER_RISCV_TLS_IE_ITYPER_RISCV_TLS_IE_STYPER_PCRELDBLR_ADDRMIPSUR_ADDRMIPSTLSR_ADDRCUOFFR_WASMIMPORTR_XCOFFREF"
|
const _RelocType_name = "R_ADDRR_ADDRPOWERR_ADDRARM64R_ADDRMIPSR_ADDROFFR_WEAKADDROFFR_SIZER_CALLR_CALLARMR_CALLARM64R_CALLINDR_CALLPOWERR_CALLMIPSR_CALLRISCVR_CONSTR_PCRELR_TLS_LER_TLS_IER_GOTOFFR_PLT0R_PLT1R_PLT2R_USEFIELDR_USETYPER_USEIFACER_USEIFACEMETHODR_METHODOFFR_POWER_TOCR_GOTPCRELR_JMPMIPSR_DWARFSECREFR_DWARFFILEREFR_ARM64_TLS_LER_ARM64_TLS_IER_ARM64_GOTPCRELR_ARM64_GOTR_ARM64_PCRELR_ARM64_LDST8R_ARM64_LDST16R_ARM64_LDST32R_ARM64_LDST64R_ARM64_LDST128R_POWER_TLS_LER_POWER_TLS_IER_POWER_TLSR_ADDRPOWER_DSR_ADDRPOWER_GOTR_ADDRPOWER_PCRELR_ADDRPOWER_TOCRELR_ADDRPOWER_TOCREL_DSR_RISCV_PCREL_ITYPER_RISCV_PCREL_STYPER_RISCV_TLS_IE_ITYPER_RISCV_TLS_IE_STYPER_PCRELDBLR_ADDRMIPSUR_ADDRMIPSTLSR_ADDRCUOFFR_WASMIMPORTR_XCOFFREF"
|
||||||
|
|
||||||
var _RelocType_index = [...]uint16{0, 6, 17, 28, 38, 47, 60, 66, 72, 81, 92, 101, 112, 122, 133, 140, 147, 155, 163, 171, 177, 183, 189, 199, 208, 218, 234, 245, 256, 266, 275, 288, 302, 316, 330, 346, 357, 370, 383, 397, 411, 426, 440, 454, 465, 479, 494, 511, 529, 550, 569, 588, 608, 628, 638, 649, 662, 673, 685, 695}
|
var _RelocType_index = [...]uint16{0, 6, 17, 28, 38, 47, 60, 66, 72, 81, 92, 101, 112, 122, 133, 140, 147, 155, 163, 171, 177, 183, 189, 199, 208, 218, 234, 245, 256, 266, 275, 288, 302, 316, 330, 346, 357, 370, 383, 397, 411, 425, 440, 454, 468, 479, 493, 508, 525, 543, 564, 583, 602, 622, 642, 652, 663, 676, 687, 699, 709}
|
||||||
|
|
||||||
func (i RelocType) String() string {
|
func (i RelocType) String() string {
|
||||||
i -= 1
|
i -= 1
|
||||||
|
@ -177,6 +177,14 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade
|
|||||||
su.SetRelocType(rIdx, objabi.R_ARM64_LDST8)
|
su.SetRelocType(rIdx, objabi.R_ARM64_LDST8)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_AARCH64_LDST16_ABS_LO12_NC):
|
||||||
|
if targType == sym.SDYNIMPORT {
|
||||||
|
ldr.Errorf(s, "unexpected relocation for dynamic symbol %s", ldr.SymName(targ))
|
||||||
|
}
|
||||||
|
su := ldr.MakeSymbolUpdater(s)
|
||||||
|
su.SetRelocType(rIdx, objabi.R_ARM64_LDST16)
|
||||||
|
return true
|
||||||
|
|
||||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_AARCH64_LDST32_ABS_LO12_NC):
|
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_AARCH64_LDST32_ABS_LO12_NC):
|
||||||
if targType == sym.SDYNIMPORT {
|
if targType == sym.SDYNIMPORT {
|
||||||
ldr.Errorf(s, "unexpected relocation for dynamic symbol %s", ldr.SymName(targ))
|
ldr.Errorf(s, "unexpected relocation for dynamic symbol %s", ldr.SymName(targ))
|
||||||
@ -769,6 +777,14 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
|
|||||||
o0 := uint32(t&0xfff) << 10
|
o0 := uint32(t&0xfff) << 10
|
||||||
return val | int64(o0), noExtReloc, true
|
return val | int64(o0), noExtReloc, true
|
||||||
|
|
||||||
|
case objabi.R_ARM64_LDST16:
|
||||||
|
t := ldr.SymAddr(rs) + r.Add() - ((ldr.SymValue(s) + int64(r.Off())) &^ 0xfff)
|
||||||
|
if t&1 != 0 {
|
||||||
|
ldr.Errorf(s, "invalid address: %x for relocation type: R_AARCH64_LDST16_ABS_LO12_NC", t)
|
||||||
|
}
|
||||||
|
o0 := (uint32(t&0xfff) >> 1) << 10
|
||||||
|
return val | int64(o0), noExtReloc, true
|
||||||
|
|
||||||
case objabi.R_ARM64_LDST32:
|
case objabi.R_ARM64_LDST32:
|
||||||
t := ldr.SymAddr(rs) + r.Add() - ((ldr.SymValue(s) + int64(r.Off())) &^ 0xfff)
|
t := ldr.SymAddr(rs) + r.Add() - ((ldr.SymValue(s) + int64(r.Off())) &^ 0xfff)
|
||||||
if t&3 != 0 {
|
if t&3 != 0 {
|
||||||
|
@ -1019,6 +1019,7 @@ func relSize(arch *sys.Arch, pn string, elftype uint32) (uint8, error) {
|
|||||||
ARM64 | uint32(elf.R_AARCH64_ADR_PREL_PG_HI21)<<16,
|
ARM64 | uint32(elf.R_AARCH64_ADR_PREL_PG_HI21)<<16,
|
||||||
ARM64 | uint32(elf.R_AARCH64_ADD_ABS_LO12_NC)<<16,
|
ARM64 | uint32(elf.R_AARCH64_ADD_ABS_LO12_NC)<<16,
|
||||||
ARM64 | uint32(elf.R_AARCH64_LDST8_ABS_LO12_NC)<<16,
|
ARM64 | uint32(elf.R_AARCH64_LDST8_ABS_LO12_NC)<<16,
|
||||||
|
ARM64 | uint32(elf.R_AARCH64_LDST16_ABS_LO12_NC)<<16,
|
||||||
ARM64 | uint32(elf.R_AARCH64_LDST32_ABS_LO12_NC)<<16,
|
ARM64 | uint32(elf.R_AARCH64_LDST32_ABS_LO12_NC)<<16,
|
||||||
ARM64 | uint32(elf.R_AARCH64_LDST64_ABS_LO12_NC)<<16,
|
ARM64 | uint32(elf.R_AARCH64_LDST64_ABS_LO12_NC)<<16,
|
||||||
ARM64 | uint32(elf.R_AARCH64_LDST128_ABS_LO12_NC)<<16,
|
ARM64 | uint32(elf.R_AARCH64_LDST128_ABS_LO12_NC)<<16,
|
||||||
|
Loading…
Reference in New Issue
Block a user