summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2016-01-06 20:53:19 +0000
committerPete Cooper <peter_cooper@apple.com>2016-01-06 20:53:19 +0000
commitd53090ac5e4382f1aaad8ddeff0fce4b43824bad (patch)
tree34faa1b36615f0fdb017e5e317c35c85c5647611
parentc2d6461a4afb3701e7eb4991b3143751b802cd9f (diff)
downloadbcm5719-llvm-d53090ac5e4382f1aaad8ddeff0fce4b43824bad.tar.gz
bcm5719-llvm-d53090ac5e4382f1aaad8ddeff0fce4b43824bad.zip
Fix MachO arm64 delta32ToGOT reloc encoding in -r.
The fixup content we encode here should be the offset from the fixup location back to the last nonlocal label. We were only encoding the address of the fixup, and not taking in to account the base address of the atom we are in. Updated the test case here to have a text section which will come before the data section where the relocation lives. .data being at offset 0 had previously been hiding this bug. llvm-svn: 256974
-rw-r--r--lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp2
-rw-r--r--lld/test/mach-o/parse-data-relocs-arm64.yaml68
2 files changed, 46 insertions, 24 deletions
diff --git a/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp b/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
index 0ba590cc642..3f69cfa2547 100644
--- a/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
+++ b/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
@@ -697,7 +697,7 @@ void ArchHandler_arm64::applyFixupRelocatable(const Reference &ref,
*loc64 = 0;
return;
case delta32ToGOT:
- *loc32 = -fixupAddress;
+ *loc32 = inAtomAddress - fixupAddress;
return;
case addOffset12:
llvm_unreachable("lazy reference kind implies GOT pass was run");
diff --git a/lld/test/mach-o/parse-data-relocs-arm64.yaml b/lld/test/mach-o/parse-data-relocs-arm64.yaml
index d02422f6a6f..0edd64689b2 100644
--- a/lld/test/mach-o/parse-data-relocs-arm64.yaml
+++ b/lld/test/mach-o/parse-data-relocs-arm64.yaml
@@ -16,11 +16,18 @@ arch: arm64
file-type: MH_OBJECT
flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ]
sections:
+ - segment: __TEXT
+ section: __text
+ type: S_REGULAR
+ attributes: [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
+ alignment: 4
+ address: 0x0000000000000000
+ content: [ 0xC0, 0x03, 0x5F, 0xD6 ]
- segment: __DATA
section: __data
type: S_REGULAR
attributes: [ ]
- address: 0x0000000000000000
+ address: 0x0000000000000004
content: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -28,7 +35,7 @@ sections:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xDC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xC0, 0xFF, 0xFF, 0xFF, 0xBE, 0xFF, 0xFF, 0xFF,
0xB0, 0xFF, 0xFF, 0xFF ]
@@ -38,107 +45,114 @@ sections:
length: 2
pc-rel: true
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x0000004C
type: ARM64_RELOC_SUBTRACTOR
length: 2
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x0000004C
type: ARM64_RELOC_UNSIGNED
length: 2
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000048
type: ARM64_RELOC_SUBTRACTOR
length: 2
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000048
type: ARM64_RELOC_UNSIGNED
length: 2
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000040
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000038
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: false
- symbol: 1
+ symbol: 2
- offset: 0x00000030
type: ARM64_RELOC_SUBTRACTOR
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000030
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000028
type: ARM64_RELOC_SUBTRACTOR
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000028
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000020
type: ARM64_RELOC_SUBTRACTOR
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000020
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000018
type: ARM64_RELOC_POINTER_TO_GOT
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000010
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
- offset: 0x00000008
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
- symbol: 1
+ symbol: 2
local-symbols:
- name: _v1
type: N_SECT
+ sect: 2
+ value: 0x000000000000000C
+global-symbols:
+ - name: _bar
+ type: N_SECT
+ scope: [ N_EXT ]
sect: 1
- value: 0x0000000000000008
+ value: 0x0000000000000000
undefined-symbols:
- name: _foo
type: N_UNDF
scope: [ N_EXT ]
value: 0x0000000000000000
+page-size: 0x00000000
...
# CHECK: defined-atoms:
@@ -151,9 +165,9 @@ undefined-symbols:
# CHECK: 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
# CHECK: 00, 00, 00, 00, 00, 00, 00, 00, E0, FF, FF, FF,
# CHECK: FF, FF, FF, FF, DC, FF, FF, FF, FF, FF, FF, FF,
-# CHECK: 00, 00, 00, 00, 00, 00, 00, 00, 04, 00, 00, 00,
+# CHECK: {{..}}, {{..}}, 00, 00, 00, 00, 00, 00, 04, 00, 00, 00,
# CHECK: 00, 00, 00, 00, C0, FF, FF, FF, BE, FF, FF, FF,
-# CHECK: B0, FF, FF, FF ]
+# CHECK: {{B0|B8}}, {{..}}, FF, FF ]
# CHECK: references:
# CHECK: - kind: pointer64
# CHECK: offset: 0
@@ -199,11 +213,19 @@ undefined-symbols:
# CHECK: offset: 72
# CHECK: target: _foo
# CHECK-NOT: addend:
+# CHECK: - name: _bar
+# CHECK: scope: global
+# CHECK: content: [ C0, 03, 5F, D6 ]
+# CHECK: alignment: 4
# CHECK: undefined-atoms:
# CHECK: - name: _foo
-
-
+# .subsections_via_symbols
+# .text
+# .globl_foo
+# .align2
+# _foo:
+# ret
# .data
#Lanon:
# .quad 0
OpenPOWER on IntegriCloud