mirror of
https://github.com/golang/go
synced 2024-11-16 21:14:44 -07:00
cmd/link: add loadelf support for riscv64
Update #36641 Change-Id: I8618da30d8940a56d6cc86a37a2f54b31ee029e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/263601 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
2e6f50020c
commit
0b798c46cd
@ -372,6 +372,11 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
||||
return errorf("elf object but not ppc64")
|
||||
}
|
||||
|
||||
case sys.RISCV64:
|
||||
if mach != elf.EM_RISCV || class != elf.ELFCLASS64 {
|
||||
return errorf("elf object but not riscv64")
|
||||
}
|
||||
|
||||
case sys.S390X:
|
||||
if mach != elf.EM_S390 || class != elf.ELFCLASS64 {
|
||||
return errorf("elf object but not s390x")
|
||||
@ -946,14 +951,15 @@ func relSize(arch *sys.Arch, pn string, elftype uint32) (uint8, error) {
|
||||
// performance.
|
||||
|
||||
const (
|
||||
AMD64 = uint32(sys.AMD64)
|
||||
ARM = uint32(sys.ARM)
|
||||
ARM64 = uint32(sys.ARM64)
|
||||
I386 = uint32(sys.I386)
|
||||
PPC64 = uint32(sys.PPC64)
|
||||
S390X = uint32(sys.S390X)
|
||||
MIPS = uint32(sys.MIPS)
|
||||
MIPS64 = uint32(sys.MIPS64)
|
||||
AMD64 = uint32(sys.AMD64)
|
||||
ARM = uint32(sys.ARM)
|
||||
ARM64 = uint32(sys.ARM64)
|
||||
I386 = uint32(sys.I386)
|
||||
MIPS = uint32(sys.MIPS)
|
||||
MIPS64 = uint32(sys.MIPS64)
|
||||
PPC64 = uint32(sys.PPC64)
|
||||
RISCV64 = uint32(sys.RISCV64)
|
||||
S390X = uint32(sys.S390X)
|
||||
)
|
||||
|
||||
switch uint32(arch.Family) | elftype<<16 {
|
||||
@ -1056,6 +1062,27 @@ func relSize(arch *sys.Arch, pn string, elftype uint32) (uint8, error) {
|
||||
S390X | uint32(elf.R_390_GOT64)<<16,
|
||||
S390X | uint32(elf.R_390_PLT64)<<16:
|
||||
return 8, nil
|
||||
|
||||
case RISCV64 | uint32(elf.R_RISCV_RVC_BRANCH)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_RVC_JUMP)<<16:
|
||||
return 2, nil
|
||||
|
||||
case RISCV64 | uint32(elf.R_RISCV_32)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_BRANCH)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_HI20)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_LO12_I)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_LO12_S)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_GOT_HI20)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_PCREL_HI20)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_PCREL_LO12_I)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_PCREL_LO12_S)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_RELAX)<<16:
|
||||
return 4, nil
|
||||
|
||||
case RISCV64 | uint32(elf.R_RISCV_64)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_CALL)<<16,
|
||||
RISCV64 | uint32(elf.R_RISCV_CALL_PLT)<<16:
|
||||
return 8, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user