1
2
3
4
5 package sym
6
7 import (
8 "cmd/internal/objabi"
9 "cmd/internal/sys"
10 "debug/elf"
11 )
12
13
14 type RelocVariant uint8
15
16 const (
17 RV_NONE RelocVariant = iota
18 RV_POWER_LO
19 RV_POWER_HI
20 RV_POWER_HA
21 RV_POWER_DS
22
23
24
25
26 RV_390_DBL
27
28 RV_CHECK_OVERFLOW RelocVariant = 1 << 7
29 RV_TYPE_MASK RelocVariant = RV_CHECK_OVERFLOW - 1
30 )
31
32 func RelocName(arch *sys.Arch, r objabi.RelocType) string {
33
34
35
36 switch {
37 case r >= objabi.MachoRelocOffset:
38
39
40
41
42
43
44
45
46
47
48
49
50
51 case r >= objabi.ElfRelocOffset:
52 nr := r - objabi.ElfRelocOffset
53 switch arch.Family {
54 case sys.AMD64:
55 return elf.R_X86_64(nr).String()
56 case sys.ARM:
57 return elf.R_ARM(nr).String()
58 case sys.ARM64:
59 return elf.R_AARCH64(nr).String()
60 case sys.I386:
61 return elf.R_386(nr).String()
62 case sys.MIPS, sys.MIPS64:
63 return elf.R_MIPS(nr).String()
64 case sys.PPC64:
65 return elf.R_PPC64(nr).String()
66 case sys.S390X:
67 return elf.R_390(nr).String()
68 default:
69 panic("unreachable")
70 }
71 }
72
73 return r.String()
74 }
75
View as plain text