From af99c2092a878500d508433baddcfcc12910c21b Mon Sep 17 00:00:00 2001 From: Xiaodong Liu Date: Wed, 30 Mar 2022 15:47:04 +0800 Subject: [PATCH] cmd/internal/objabi: define Go relocation types for loong64 Contributors to the loong64 port are: Weining Lu Lei Wang Lingqin Gong Xiaolin Zhao Meidan Li Xiaojuan Zhai Qiyuan Pu Guoqi Chen This port has been updated to Go 1.15.6: https://github.com/loongson/go Updates #46229 Change-Id: I8d31b3cd827325aa0ff748ca8c0c0da6df6ed99f Reviewed-on: https://go-review.googlesource.com/c/go/+/396734 Reviewed-by: David Chase TryBot-Result: Gopher Robot Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor --- src/cmd/internal/objabi/reloctype.go | 30 ++++++++++++++++++++- src/cmd/internal/objabi/reloctype_string.go | 20 +++++++++----- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/cmd/internal/objabi/reloctype.go b/src/cmd/internal/objabi/reloctype.go index a9c3030181..f60cac2b95 100644 --- a/src/cmd/internal/objabi/reloctype.go +++ b/src/cmd/internal/objabi/reloctype.go @@ -250,6 +250,32 @@ const ( // TODO(mundaym): remove once variants can be serialized - see issue 14218. R_PCRELDBL + // Loong64. + + // R_ADDRLOONG64 resolves to the low 12 bits of an external address, by encoding + // it into the instruction. + R_ADDRLOONG64 + + // R_ADDRLOONG64U resolves to the sign-adjusted "upper" 20 bits (bit 5-24) of an + // external address, by encoding it into the instruction. + R_ADDRLOONG64U + + // R_ADDRLOONG64TLS resolves to the low 12 bits of a TLS address (offset from + // thread pointer), by encoding it into the instruction. + R_ADDRLOONG64TLS + + // R_ADDRLOONG64TLSU resolves to the high 20 bits of a TLS address (offset from + // thread pointer), by encoding it into the instruction. + R_ADDRLOONG64TLSU + + // R_CALLLOONG64 resolves to non-PC-relative target address of a CALL (BL/JIRL) + // instruction, by encoding the address into the instruction. + R_CALLLOONG64 + + // R_JMPLOONG64 resolves to non-PC-relative target address of a JMP instruction, + // by encoding the address into the instruction. + R_JMPLOONG64 + // R_ADDRMIPSU (only used on mips/mips64) resolves to the sign-adjusted "upper" 16 // bits (bit 16-31) of an external address, by encoding it into the instruction. R_ADDRMIPSU @@ -286,7 +312,7 @@ const ( // the target address in register or memory. func (r RelocType) IsDirectCall() bool { switch r { - case R_CALL, R_CALLARM, R_CALLARM64, R_CALLMIPS, R_CALLPOWER, R_RISCV_CALL, R_RISCV_CALL_TRAMP: + case R_CALL, R_CALLARM, R_CALLARM64, R_CALLLOONG64, R_CALLMIPS, R_CALLPOWER, R_RISCV_CALL, R_RISCV_CALL_TRAMP: return true } return false @@ -301,6 +327,8 @@ func (r RelocType) IsDirectJump() bool { switch r { case R_JMPMIPS: return true + case R_JMPLOONG64: + return true } return false } diff --git a/src/cmd/internal/objabi/reloctype_string.go b/src/cmd/internal/objabi/reloctype_string.go index d1b15b5a19..9756f2a321 100644 --- a/src/cmd/internal/objabi/reloctype_string.go +++ b/src/cmd/internal/objabi/reloctype_string.go @@ -65,16 +65,22 @@ func _() { _ = x[R_RISCV_TLS_IE_ITYPE-55] _ = x[R_RISCV_TLS_IE_STYPE-56] _ = x[R_PCRELDBL-57] - _ = x[R_ADDRMIPSU-58] - _ = x[R_ADDRMIPSTLS-59] - _ = x[R_ADDRCUOFF-60] - _ = x[R_WASMIMPORT-61] - _ = x[R_XCOFFREF-62] + _ = x[R_ADDRLOONG64-58] + _ = x[R_ADDRLOONG64U-59] + _ = x[R_ADDRLOONG64TLS-60] + _ = x[R_ADDRLOONG64TLSU-61] + _ = x[R_CALLLOONG64-62] + _ = x[R_JMPLOONG64-63] + _ = x[R_ADDRMIPSU-64] + _ = x[R_ADDRMIPSTLS-65] + _ = x[R_ADDRCUOFF-66] + _ = x[R_WASMIMPORT-67] + _ = x[R_XCOFFREF-68] } -const _RelocType_name = "R_ADDRR_ADDRPOWERR_ADDRARM64R_ADDRMIPSR_ADDROFFR_SIZER_CALLR_CALLARMR_CALLARM64R_CALLINDR_CALLPOWERR_CALLMIPSR_CONSTR_PCRELR_TLS_LER_TLS_IER_GOTOFFR_PLT0R_PLT1R_PLT2R_USEFIELDR_USETYPER_USEIFACER_USEIFACEMETHODR_USEGENERICIFACEMETHODR_METHODOFFR_KEEPR_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_CALLR_RISCV_CALL_TRAMPR_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_SIZER_CALLR_CALLARMR_CALLARM64R_CALLINDR_CALLPOWERR_CALLMIPSR_CONSTR_PCRELR_TLS_LER_TLS_IER_GOTOFFR_PLT0R_PLT1R_PLT2R_USEFIELDR_USETYPER_USEIFACER_USEIFACEMETHODR_USEGENERICIFACEMETHODR_METHODOFFR_KEEPR_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_CALLR_RISCV_CALL_TRAMPR_RISCV_PCREL_ITYPER_RISCV_PCREL_STYPER_RISCV_TLS_IE_ITYPER_RISCV_TLS_IE_STYPER_PCRELDBLR_ADDRLOONG64R_ADDRLOONG64UR_ADDRLOONG64TLSR_ADDRLOONG64TLSUR_CALLLOONG64R_JMPLOONG64R_ADDRMIPSUR_ADDRMIPSTLSR_ADDRCUOFFR_WASMIMPORTR_XCOFFREF" -var _RelocType_index = [...]uint16{0, 6, 17, 28, 38, 47, 53, 59, 68, 79, 88, 99, 109, 116, 123, 131, 139, 147, 153, 159, 165, 175, 184, 194, 210, 233, 244, 250, 261, 271, 280, 293, 307, 321, 335, 351, 362, 375, 388, 402, 416, 430, 445, 459, 473, 484, 498, 513, 530, 548, 569, 581, 599, 618, 637, 657, 677, 687, 698, 711, 722, 734, 744} +var _RelocType_index = [...]uint16{0, 6, 17, 28, 38, 47, 53, 59, 68, 79, 88, 99, 109, 116, 123, 131, 139, 147, 153, 159, 165, 175, 184, 194, 210, 233, 244, 250, 261, 271, 280, 293, 307, 321, 335, 351, 362, 375, 388, 402, 416, 430, 445, 459, 473, 484, 498, 513, 530, 548, 569, 581, 599, 618, 637, 657, 677, 687, 700, 714, 730, 747, 760, 772, 783, 796, 807, 819, 829} func (i RelocType) String() string { i -= 1