aboutsummaryrefslogtreecommitdiff
path: root/src/debug/macho
diff options
context:
space:
mode:
authorHiroshi Ioka <hirochachacha@gmail.com>2017-08-14 19:39:17 +0900
committerIan Lance Taylor <iant@golang.org>2017-08-14 18:45:40 +0000
commitbac1cc0d1675a0e958b366837e6230f4f09c2a5b (patch)
treee4eca68173a37486d90b50a2fa5f60dc044868a0 /src/debug/macho
parentb7c600d6ba8828dbdc6a047aac240d40b4fc44a7 (diff)
downloadgo-bac1cc0d1675a0e958b366837e6230f4f09c2a5b.tar.xz
debug/macho: add relocation types
Fixes #21435 Change-Id: I5f8d93a45b84a871ceea881ecb1a38a37e96006c Reviewed-on: https://go-review.googlesource.com/55263 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/debug/macho')
-rw-r--r--src/debug/macho/file_test.go9
-rw-r--r--src/debug/macho/reloctype.go72
-rw-r--r--src/debug/macho/reloctype_string.go49
3 files changed, 130 insertions, 0 deletions
diff --git a/src/debug/macho/file_test.go b/src/debug/macho/file_test.go
index 9ff6c5d96e..71896d1b2e 100644
--- a/src/debug/macho/file_test.go
+++ b/src/debug/macho/file_test.go
@@ -208,3 +208,12 @@ func TestOpenFatFailure(t *testing.T) {
t.Errorf("OpenFat %s: got %v, want nil", filename, ff)
}
}
+
+func TestRelocTypeString(t *testing.T) {
+ if X86_64_RELOC_BRANCH.String() != "X86_64_RELOC_BRANCH" {
+ t.Errorf("got %v, want %v", X86_64_RELOC_BRANCH.String(), "X86_64_RELOC_BRANCH")
+ }
+ if X86_64_RELOC_BRANCH.GoString() != "macho.X86_64_RELOC_BRANCH" {
+ t.Errorf("got %v, want %v", X86_64_RELOC_BRANCH.GoString(), "macho.X86_64_RELOC_BRANCH")
+ }
+}
diff --git a/src/debug/macho/reloctype.go b/src/debug/macho/reloctype.go
new file mode 100644
index 0000000000..496dfce7ec
--- /dev/null
+++ b/src/debug/macho/reloctype.go
@@ -0,0 +1,72 @@
+// 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 macho
+
+//go:generate stringer -type=RelocTypeGeneric,RelocTypeX86_64,RelocTypeARM,RelocTypeARM64 -output reloctype_string.go
+
+type RelocTypeGeneric int
+
+const (
+ GENERIC_RELOC_VANILLA RelocTypeGeneric = 0
+ GENERIC_RELOC_PAIR RelocTypeGeneric = 1
+ GENERIC_RELOC_SECTDIFF RelocTypeGeneric = 2
+ GENERIC_RELOC_PB_LA_PTR RelocTypeGeneric = 3
+ GENERIC_RELOC_LOCAL_SECTDIFF RelocTypeGeneric = 4
+ GENERIC_RELOC_TLV RelocTypeGeneric = 5
+)
+
+func (r RelocTypeGeneric) GoString() string { return "macho." + r.String() }
+
+type RelocTypeX86_64 int
+
+const (
+ X86_64_RELOC_UNSIGNED RelocTypeX86_64 = 0
+ X86_64_RELOC_SIGNED RelocTypeX86_64 = 1
+ X86_64_RELOC_BRANCH RelocTypeX86_64 = 2
+ X86_64_RELOC_GOT_LOAD RelocTypeX86_64 = 3
+ X86_64_RELOC_GOT RelocTypeX86_64 = 4
+ X86_64_RELOC_SUBTRACTOR RelocTypeX86_64 = 5
+ X86_64_RELOC_SIGNED_1 RelocTypeX86_64 = 6
+ X86_64_RELOC_SIGNED_2 RelocTypeX86_64 = 7
+ X86_64_RELOC_SIGNED_4 RelocTypeX86_64 = 8
+ X86_64_RELOC_TLV RelocTypeX86_64 = 9
+)
+
+func (r RelocTypeX86_64) GoString() string { return "macho." + r.String() }
+
+type RelocTypeARM int
+
+const (
+ ARM_RELOC_VANILLA RelocTypeARM = 0
+ ARM_RELOC_PAIR RelocTypeARM = 1
+ ARM_RELOC_SECTDIFF RelocTypeARM = 2
+ ARM_RELOC_LOCAL_SECTDIFF RelocTypeARM = 3
+ ARM_RELOC_PB_LA_PTR RelocTypeARM = 4
+ ARM_RELOC_BR24 RelocTypeARM = 5
+ ARM_THUMB_RELOC_BR22 RelocTypeARM = 6
+ ARM_THUMB_32BIT_BRANCH RelocTypeARM = 7
+ ARM_RELOC_HALF RelocTypeARM = 8
+ ARM_RELOC_HALF_SECTDIFF RelocTypeARM = 9
+)
+
+func (r RelocTypeARM) GoString() string { return "macho." + r.String() }
+
+type RelocTypeARM64 int
+
+const (
+ ARM64_RELOC_UNSIGNED RelocTypeARM64 = 0
+ ARM64_RELOC_SUBTRACTOR RelocTypeARM64 = 1
+ ARM64_RELOC_BRANCH26 RelocTypeARM64 = 2
+ ARM64_RELOC_PAGE21 RelocTypeARM64 = 3
+ ARM64_RELOC_PAGEOFF12 RelocTypeARM64 = 4
+ ARM64_RELOC_GOT_LOAD_PAGE21 RelocTypeARM64 = 5
+ ARM64_RELOC_GOT_LOAD_PAGEOFF12 RelocTypeARM64 = 6
+ ARM64_RELOC_POINTER_TO_GOT RelocTypeARM64 = 7
+ ARM64_RELOC_TLVP_LOAD_PAGE21 RelocTypeARM64 = 8
+ ARM64_RELOC_TLVP_LOAD_PAGEOFF12 RelocTypeARM64 = 9
+ ARM64_RELOC_ADDEND RelocTypeARM64 = 10
+)
+
+func (r RelocTypeARM64) GoString() string { return "macho." + r.String() }
diff --git a/src/debug/macho/reloctype_string.go b/src/debug/macho/reloctype_string.go
new file mode 100644
index 0000000000..6d5c5d87e8
--- /dev/null
+++ b/src/debug/macho/reloctype_string.go
@@ -0,0 +1,49 @@
+// Code generated by "stringer -type=RelocTypeGeneric,RelocTypeX86_64,RelocTypeARM,RelocTypeARM64 -output reloctype_string.go"; DO NOT EDIT.
+
+package macho
+
+import "fmt"
+
+const _RelocTypeGeneric_name = "GENERIC_RELOC_VANILLAGENERIC_RELOC_PAIRGENERIC_RELOC_SECTDIFFGENERIC_RELOC_PB_LA_PTRGENERIC_RELOC_LOCAL_SECTDIFFGENERIC_RELOC_TLV"
+
+var _RelocTypeGeneric_index = [...]uint8{0, 21, 39, 61, 84, 112, 129}
+
+func (i RelocTypeGeneric) String() string {
+ if i < 0 || i >= RelocTypeGeneric(len(_RelocTypeGeneric_index)-1) {
+ return fmt.Sprintf("RelocTypeGeneric(%d)", i)
+ }
+ return _RelocTypeGeneric_name[_RelocTypeGeneric_index[i]:_RelocTypeGeneric_index[i+1]]
+}
+
+const _RelocTypeX86_64_name = "X86_64_RELOC_UNSIGNEDX86_64_RELOC_SIGNEDX86_64_RELOC_BRANCHX86_64_RELOC_GOT_LOADX86_64_RELOC_GOTX86_64_RELOC_SUBTRACTORX86_64_RELOC_SIGNED_1X86_64_RELOC_SIGNED_2X86_64_RELOC_SIGNED_4X86_64_RELOC_TLV"
+
+var _RelocTypeX86_64_index = [...]uint8{0, 21, 40, 59, 80, 96, 119, 140, 161, 182, 198}
+
+func (i RelocTypeX86_64) String() string {
+ if i < 0 || i >= RelocTypeX86_64(len(_RelocTypeX86_64_index)-1) {
+ return fmt.Sprintf("RelocTypeX86_64(%d)", i)
+ }
+ return _RelocTypeX86_64_name[_RelocTypeX86_64_index[i]:_RelocTypeX86_64_index[i+1]]
+}
+
+const _RelocTypeARM_name = "ARM_RELOC_VANILLAARM_RELOC_PAIRARM_RELOC_SECTDIFFARM_RELOC_LOCAL_SECTDIFFARM_RELOC_PB_LA_PTRARM_RELOC_BR24ARM_THUMB_RELOC_BR22ARM_THUMB_32BIT_BRANCHARM_RELOC_HALFARM_RELOC_HALF_SECTDIFF"
+
+var _RelocTypeARM_index = [...]uint8{0, 17, 31, 49, 73, 92, 106, 126, 148, 162, 185}
+
+func (i RelocTypeARM) String() string {
+ if i < 0 || i >= RelocTypeARM(len(_RelocTypeARM_index)-1) {
+ return fmt.Sprintf("RelocTypeARM(%d)", i)
+ }
+ return _RelocTypeARM_name[_RelocTypeARM_index[i]:_RelocTypeARM_index[i+1]]
+}
+
+const _RelocTypeARM64_name = "ARM64_RELOC_UNSIGNEDARM64_RELOC_SUBTRACTORARM64_RELOC_BRANCH26ARM64_RELOC_PAGE21ARM64_RELOC_PAGEOFF12ARM64_RELOC_GOT_LOAD_PAGE21ARM64_RELOC_GOT_LOAD_PAGEOFF12ARM64_RELOC_POINTER_TO_GOTARM64_RELOC_TLVP_LOAD_PAGE21ARM64_RELOC_TLVP_LOAD_PAGEOFF12ARM64_RELOC_ADDEND"
+
+var _RelocTypeARM64_index = [...]uint16{0, 20, 42, 62, 80, 101, 128, 158, 184, 212, 243, 261}
+
+func (i RelocTypeARM64) String() string {
+ if i < 0 || i >= RelocTypeARM64(len(_RelocTypeARM64_index)-1) {
+ return fmt.Sprintf("RelocTypeARM64(%d)", i)
+ }
+ return _RelocTypeARM64_name[_RelocTypeARM64_index[i]:_RelocTypeARM64_index[i+1]]
+}