blob: a44dcdd517b3a9fb6a5608086e2a51f21b8366b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sym
import (
"cmd/internal/objabi"
"cmd/internal/sys"
"debug/elf"
)
// RelocVariant is a linker-internal variation on a relocation.
type RelocVariant uint8
const (
RV_NONE RelocVariant = iota
RV_POWER_LO
RV_POWER_HI
RV_POWER_HA
RV_POWER_DS
// RV_390_DBL is a s390x-specific relocation variant that indicates that
// the value to be placed into the relocatable field should first be
// divided by 2.
RV_390_DBL
RV_CHECK_OVERFLOW RelocVariant = 1 << 7
RV_TYPE_MASK RelocVariant = RV_CHECK_OVERFLOW - 1
)
func RelocName(arch *sys.Arch, r objabi.RelocType) string {
// We didn't have some relocation types at Go1.4.
// Uncomment code when we include those in bootstrap code.
switch {
case r >= objabi.MachoRelocOffset: // Mach-O
// nr := (r - objabi.MachoRelocOffset)>>1
// switch ctxt.Arch.Family {
// case sys.AMD64:
// return macho.RelocTypeX86_64(nr).String()
// case sys.ARM:
// return macho.RelocTypeARM(nr).String()
// case sys.ARM64:
// return macho.RelocTypeARM64(nr).String()
// case sys.I386:
// return macho.RelocTypeGeneric(nr).String()
// default:
// panic("unreachable")
// }
case r >= objabi.ElfRelocOffset: // ELF
nr := r - objabi.ElfRelocOffset
switch arch.Family {
case sys.AMD64:
return elf.R_X86_64(nr).String()
case sys.ARM:
return elf.R_ARM(nr).String()
case sys.ARM64:
return elf.R_AARCH64(nr).String()
case sys.I386:
return elf.R_386(nr).String()
case sys.Loong64:
return elf.R_LARCH(nr).String()
case sys.MIPS, sys.MIPS64:
return elf.R_MIPS(nr).String()
case sys.PPC64:
return elf.R_PPC64(nr).String()
case sys.S390X:
return elf.R_390(nr).String()
default:
panic("unreachable")
}
}
return r.String()
}
|