summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2015-12-18 23:43:17 +0000
committerPete Cooper <peter_cooper@apple.com>2015-12-18 23:43:17 +0000
commite6fa51c9416b3cb45af9c31992bb5796336d2906 (patch)
tree998e50d9d2855093c975d116ca11c9513a25b0e8
parenta3ff2e4e02562c6732d87f7118ca663f9b3dae37 (diff)
downloadbcm5719-llvm-e6fa51c9416b3cb45af9c31992bb5796336d2906.tar.gz
bcm5719-llvm-e6fa51c9416b3cb45af9c31992bb5796336d2906.zip
Regenerated test according to the example assembly at the top. NFC.
The assembly at the top of this file contained more relocations than the YAML. I regenerated it so that we'd have complete relocation testing. Also added detailed explanations of the relocations in the file so that future people don't have to try decode them when something goes wrong. llvm-svn: 256064
-rw-r--r--lld/test/mach-o/parse-data-relocs-x86_64.yaml170
1 files changed, 133 insertions, 37 deletions
diff --git a/lld/test/mach-o/parse-data-relocs-x86_64.yaml b/lld/test/mach-o/parse-data-relocs-x86_64.yaml
index edeb1606887..b6f38f5d10e 100644
--- a/lld/test/mach-o/parse-data-relocs-x86_64.yaml
+++ b/lld/test/mach-o/parse-data-relocs-x86_64.yaml
@@ -2,7 +2,7 @@
# RUN: lld -flavor darwin -arch x86_64 -r %s -o %t -print_atoms | FileCheck %s \
# RUN: && lld -flavor darwin -arch x86_64 %t -r -print_atoms -o %t2 | FileCheck %s
#
-# Test parsing and writing of x86_64 text relocations.
+# Test parsing and writing of x86_64 data relocations.
#
# The first step tests if the supplied mach-o file is parsed into the correct
# set of references. The second step verifies relocations can be round-tripped
@@ -37,7 +37,9 @@
--- !mach-o
arch: x86_64
file-type: MH_OBJECT
-flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ]
+flags: [ ]
+compat-version: 0.0
+current-version: 0.0
has-UUID: false
OS: unknown
sections:
@@ -52,107 +54,186 @@ sections:
type: S_REGULAR
attributes: [ ]
address: 0x0000000000000002
- content: [ 0x00, 0x00, 0x00, 0x00 ]
+ content: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]
- segment: __DATA
section: __data
type: S_REGULAR
attributes: [ ]
- alignment: 3
- address: 0x0000000000000008
- content: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ address: 0x000000000000000A
+ content: [
+# .quad _foo
+# No addend is needed here as we are referencing _foo directly and that is
+# encoded entirely in the X86_64_RELOC_UNSIGNED
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+# .quad _foo+4
+# Addend of 4 is needed here as we are referencing _foo from the
+# X86_64_RELOC_UNSIGNED, then the addend gives us 4 more.
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+# .quad _foo - .
+# This is the pair X86_64_RELOC_SUBTRACTOR and X86_64_RELOC_UNSIGNED.
+# The subtractor references _d which is the first nonlocal label in this
+# section. The unsigned references _foo.
+# Note the addend here is -16 because that is the offset from here back
+# to _d.
+ 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+# .quad L1
+# This is a X86_64_RELOC_UNSIGNED without extern set.
+# In this case, we encode the section number for L1 in the relocation, and
+# the addend here is the absolute address of the location in that section
+# we want to reference.
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+# .quad L1 + 2
+# This is a X86_64_RELOC_UNSIGNED without extern set.
+# In this case, we encode the section number for L1 in the relocation, and
+# the addend here is the absolute address of the location in that section
+# we want to reference. We have a 4 because the section is at address 2
+# and we want an offset of 2 from there.
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xDC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xD2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xC8, 0xFF, 0xFF, 0xFF, 0xC8, 0xFF, 0xFF, 0xFF,
- 0xC2, 0xFF, 0xFF, 0xFF ]
+# .quad _foo - .
+# This is the pair X86_64_RELOC_SUBTRACTOR and X86_64_RELOC_UNSIGNED.
+# The subtractor references _d which is the first nonlocal label in this
+# section. The unsigned references _foo.
+# Note the addend here is -40 because that is the offset from here back
+# to _d.
+ 0xD8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+# .quad _foo + 4 - .
+# This is the pair X86_64_RELOC_SUBTRACTOR and X86_64_RELOC_UNSIGNED.
+# The subtractor references _d which is the first nonlocal label in this
+# section. The unsigned references _foo.
+# Note the addend here is -44. It would have been -48 because that
+# would take us from the address of this relocation back to _d. But as
+# we also add 4 for the offset, we get -44.
+ 0xD4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+# .quad L1 - .
+# This is the pair X86_64_RELOC_SUBTRACTOR and X86_64_RELOC_UNSIGNED.
+# The subtractor references _d which is the first nonlocal label in this
+# section. The unsigned does not have extern set, so the relocation
+# number is the section number for L1.
+# Note the addend here is -54. Of that, -56 would be the offset from
+# this location from _d. The remaining 2 is the absolute address
+# of L1.
+ 0xCA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+# .long _foo - .
+# This is the pair X86_64_RELOC_SUBTRACTOR and X86_64_RELOC_UNSIGNED.
+# The subtractor references _d which is the first nonlocal label in this
+# section. The unsigned references _foo.
+# Note the addend here is -64 because that is the offset from here back
+# to _d.
+ 0xC0, 0xFF, 0xFF, 0xFF,
+# .long _foo + 4 - .
+# This is the pair X86_64_RELOC_SUBTRACTOR and X86_64_RELOC_UNSIGNED.
+# The subtractor references _d which is the first nonlocal label in this
+# section. The unsigned references _foo.
+# Note the addend here is -64. It would have been -68 because that
+# would take us from the address of this relocation back to _d. But as
+# we also add 4 for the offset, we get -64.
+ 0xC0, 0xFF, 0xFF, 0xFF,
+# .long L1 - .
+# This is the pair X86_64_RELOC_SUBTRACTOR and X86_64_RELOC_UNSIGNED.
+# The subtractor references _d which is the first nonlocal label in this
+# section. The unsigned does not have extern set, so the relocation
+# number is the section number for L1.
+# Note the addend here is -70. Of that, -72 would be the offset from
+# this location from _d. The remaining 2 is the absolute address
+# of L1.
+ 0xBA, 0xFF, 0xFF, 0xFF ]
relocations:
- - offset: 0x00000040
+ - offset: 0x00000048
type: X86_64_RELOC_SUBTRACTOR
length: 2
pc-rel: false
extern: true
symbol: 2
- - offset: 0x00000040
+ - offset: 0x00000048
type: X86_64_RELOC_UNSIGNED
length: 2
pc-rel: false
extern: false
symbol: 2
- - offset: 0x0000003C
+ - offset: 0x00000044
type: X86_64_RELOC_SUBTRACTOR
length: 2
pc-rel: false
extern: true
symbol: 2
- - offset: 0x0000003C
+ - offset: 0x00000044
type: X86_64_RELOC_UNSIGNED
length: 2
pc-rel: false
extern: true
symbol: 0
- - offset: 0x00000038
+ - offset: 0x00000040
type: X86_64_RELOC_SUBTRACTOR
length: 2
pc-rel: false
extern: true
symbol: 2
- - offset: 0x00000038
+ - offset: 0x00000040
type: X86_64_RELOC_UNSIGNED
length: 2
pc-rel: false
extern: true
symbol: 0
- - offset: 0x00000030
+ - offset: 0x00000038
type: X86_64_RELOC_SUBTRACTOR
length: 3
pc-rel: false
extern: true
symbol: 2
- - offset: 0x00000030
+ - offset: 0x00000038
type: X86_64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: false
symbol: 2
- - offset: 0x00000028
+ - offset: 0x00000030
type: X86_64_RELOC_SUBTRACTOR
length: 3
pc-rel: false
extern: true
symbol: 2
- - offset: 0x00000028
+ - offset: 0x00000030
type: X86_64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
symbol: 0
- - offset: 0x00000020
+ - offset: 0x00000028
type: X86_64_RELOC_SUBTRACTOR
length: 3
pc-rel: false
extern: true
symbol: 2
- - offset: 0x00000020
+ - offset: 0x00000028
type: X86_64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
symbol: 0
- - offset: 0x00000018
+ - offset: 0x00000020
type: X86_64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: false
symbol: 2
- - offset: 0x00000010
+ - offset: 0x00000018
type: X86_64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: false
symbol: 2
+ - offset: 0x00000010
+ type: X86_64_RELOC_SUBTRACTOR
+ length: 3
+ pc-rel: false
+ extern: true
+ symbol: 2
+ - offset: 0x00000010
+ type: X86_64_RELOC_UNSIGNED
+ length: 3
+ pc-rel: false
+ extern: true
+ symbol: 0
- offset: 0x00000008
type: X86_64_RELOC_UNSIGNED
length: 3
@@ -177,14 +258,23 @@ local-symbols:
- name: _d
type: N_SECT
sect: 3
- value: 0x0000000000000008
+ value: 0x000000000000000A
+page-size: 0x00000000
...
-# CHECK: defined-atoms:
+# CHECK:defined-atoms:
# CHECK: - name: _d
# CHECK: type: data
-# CHECK: references:
+# CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00, 04, 00, 00, 00,
+# CHECK: 00, 00, 00, 00, F0, FF, FF, FF, FF, FF, FF, FF,
+# CHECK: {{..}}, 00, 00, 00, 00, 00, 00, 00, {{..}}, 00, 00, 00,
+# CHECK: 00, 00, 00, 00, D8, FF, FF, FF, FF, FF, FF, FF,
+# CHECK: D4, FF, FF, FF, FF, FF, FF, FF, {{..}}, {{..}}, {{..}}, {{..}},
+# CHECK: {{..}}, {{..}}, {{..}}, {{..}}, C0, FF, FF, FF, C0, FF, FF, FF,
+# CHECK: {{..}}, {{..}}, {{..}}, {{..}} ]
+# CHECK: dead-strip: never
+# CHECK: references:
# CHECK: - kind: pointer64
# CHECK: offset: 0
# CHECK: target: _foo
@@ -192,39 +282,45 @@ local-symbols:
# CHECK: offset: 8
# CHECK: target: _foo
# CHECK: addend: 4
-# CHECK: - kind: pointer64Anon
+# CHECK: - kind: delta64
# CHECK: offset: 16
-# CHECK: target: L003
+# CHECK: target: _foo
# CHECK: - kind: pointer64Anon
# CHECK: offset: 24
# CHECK: target: L003
+# CHECK: - kind: pointer64Anon
+# CHECK: offset: 32
+# CHECK: target: L003
# CHECK: addend: 2
# CHECK: - kind: delta64
-# CHECK: offset: 32
+# CHECK: offset: 40
# CHECK: target: _foo
# CHECK: - kind: delta64
-# CHECK: offset: 40
+# CHECK: offset: 48
# CHECK: target: _foo
# CHECK: addend: 4
# CHECK: - kind: delta64Anon
-# CHECK: offset: 48
+# CHECK: offset: 56
# CHECK: target: L003
# CHECK: - kind: delta32
-# CHECK: offset: 56
+# CHECK: offset: 64
# CHECK: target: _foo
# CHECK: - kind: delta32
-# CHECK: offset: 60
+# CHECK: offset: 68
# CHECK: target: _foo
# CHECK: addend: 4
# CHECK: - kind: delta32Anon
-# CHECK: offset: 64
+# CHECK: offset: 72
# CHECK: target: L003
# CHECK: - name: _foo
# CHECK: content: [ C3 ]
+# CHECK: dead-strip: never
# CHECK: - name: _bar
# CHECK: content: [ C3 ]
+# CHECK: dead-strip: never
# CHECK: - ref-name: L003
# CHECK: type: unknown
-# CHECK: content: [ 00, 00, 00, 00 ]
+# CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
# CHECK: section-choice: custom-required
# CHECK: section-name: __DATA/__custom
+
OpenPOWER on IntegriCloud