2014-11-18 08:30:17 +08:00
|
|
|
# RUN: lld -flavor darwin -arch arm64 -r -print_atoms %s -o %t | FileCheck %s
|
|
|
|
# RUN: lld -flavor darwin -arch arm64 -r -print_atoms %t -o %t2 | FileCheck %s
|
2014-09-10 07:52:59 +08:00
|
|
|
#
|
|
|
|
# Test parsing and writing of arm64 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
|
|
|
|
# by writing to a new .o file, then parsing that file which should result in
|
|
|
|
# the same references.
|
|
|
|
#
|
|
|
|
#_test:
|
|
|
|
|
|
|
|
|
|
|
|
--- !mach-o
|
|
|
|
arch: arm64
|
|
|
|
file-type: MH_OBJECT
|
2014-11-18 08:30:17 +08:00
|
|
|
flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ]
|
2014-09-10 07:52:59 +08:00
|
|
|
sections:
|
|
|
|
- segment: __DATA
|
|
|
|
section: __data
|
|
|
|
type: S_REGULAR
|
|
|
|
attributes: [ ]
|
|
|
|
address: 0x0000000000000000
|
|
|
|
content: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
2014-11-18 08:30:17 +08:00
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
2014-09-10 07:52:59 +08:00
|
|
|
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xDC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
2014-11-18 08:30:17 +08:00
|
|
|
0x00, 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 ]
|
2014-09-10 07:52:59 +08:00
|
|
|
relocations:
|
2014-11-18 08:30:17 +08:00
|
|
|
- offset: 0x00000050
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_POINTER_TO_GOT
|
|
|
|
length: 2
|
|
|
|
pc-rel: true
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x0000004C
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_SUBTRACTOR
|
|
|
|
length: 2
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x0000004C
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_UNSIGNED
|
|
|
|
length: 2
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000048
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_SUBTRACTOR
|
|
|
|
length: 2
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000048
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_UNSIGNED
|
|
|
|
length: 2
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000040
|
|
|
|
type: ARM64_RELOC_UNSIGNED
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000038
|
|
|
|
type: ARM64_RELOC_UNSIGNED
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: false
|
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000030
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_SUBTRACTOR
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000030
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_UNSIGNED
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000028
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_SUBTRACTOR
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000028
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_UNSIGNED
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000020
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_SUBTRACTOR
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000020
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_UNSIGNED
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000018
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_POINTER_TO_GOT
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000010
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_UNSIGNED
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
|
|
|
- offset: 0x00000008
|
2014-09-10 07:52:59 +08:00
|
|
|
type: ARM64_RELOC_UNSIGNED
|
|
|
|
length: 3
|
|
|
|
pc-rel: false
|
|
|
|
extern: true
|
2014-11-18 08:30:17 +08:00
|
|
|
symbol: 1
|
2014-09-10 07:52:59 +08:00
|
|
|
local-symbols:
|
|
|
|
- name: _v1
|
|
|
|
type: N_SECT
|
2014-11-18 08:30:17 +08:00
|
|
|
sect: 1
|
|
|
|
value: 0x0000000000000008
|
2014-09-10 07:52:59 +08:00
|
|
|
undefined-symbols:
|
|
|
|
- name: _foo
|
|
|
|
type: N_UNDF
|
|
|
|
scope: [ N_EXT ]
|
|
|
|
value: 0x0000000000000000
|
|
|
|
...
|
|
|
|
|
|
|
|
# CHECK: defined-atoms:
|
2014-11-18 08:30:17 +08:00
|
|
|
# CHECK: - ref-name: L000
|
|
|
|
# CHECK: type: data
|
|
|
|
# CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
|
2014-09-10 07:52:59 +08:00
|
|
|
# CHECK: - name: _v1
|
|
|
|
# CHECK: type: data
|
|
|
|
# CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00, 08, 00, 00, 00,
|
|
|
|
# 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,
|
2014-11-18 08:30:17 +08:00
|
|
|
# CHECK: 00, 00, 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 ]
|
2014-09-10 07:52:59 +08:00
|
|
|
# CHECK: references:
|
|
|
|
# CHECK: - kind: pointer64
|
|
|
|
# CHECK: offset: 0
|
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK-NOT: addend:
|
|
|
|
# CHECK: - kind: pointer64
|
|
|
|
# CHECK: offset: 8
|
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK: addend: 8
|
|
|
|
# CHECK: - kind: pointer64ToGOT
|
|
|
|
# CHECK: offset: 16
|
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK-NOT: addend:
|
|
|
|
# CHECK: - kind: delta64
|
|
|
|
# CHECK: offset: 24
|
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK: addend: 24
|
|
|
|
# CHECK: - kind: delta64
|
|
|
|
# CHECK: offset: 32
|
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK-NOT: addend:
|
|
|
|
# CHECK: - kind: delta64
|
|
|
|
# CHECK: offset: 40
|
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK: addend: 4
|
2014-11-18 08:30:17 +08:00
|
|
|
# CHECK: - kind: pointer64
|
2014-09-10 07:52:59 +08:00
|
|
|
# CHECK: offset: 48
|
2014-11-18 08:30:17 +08:00
|
|
|
# CHECK: target: L000
|
|
|
|
# CHECK-NOT: addend:
|
|
|
|
# CHECK: - kind: pointer64
|
|
|
|
# CHECK: offset: 56
|
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK: addend: 4
|
|
|
|
# CHECK: - kind: delta32
|
|
|
|
# CHECK: offset: 64
|
2014-09-10 07:52:59 +08:00
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK-NOT: addend:
|
|
|
|
# CHECK: - kind: delta32
|
2014-11-18 08:30:17 +08:00
|
|
|
# CHECK: offset: 68
|
2014-09-10 07:52:59 +08:00
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK: addend: 2
|
|
|
|
# CHECK: - kind: delta32ToGOT
|
2014-11-18 08:30:17 +08:00
|
|
|
# CHECK: offset: 72
|
2014-09-10 07:52:59 +08:00
|
|
|
# CHECK: target: _foo
|
|
|
|
# CHECK-NOT: addend:
|
|
|
|
# CHECK: undefined-atoms:
|
|
|
|
# CHECK: - name: _foo
|
2014-11-18 08:30:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# .data
|
|
|
|
#Lanon:
|
|
|
|
# .quad 0
|
|
|
|
#_v1:
|
|
|
|
# .quad _foo
|
|
|
|
# .quad _foo + 8
|
|
|
|
# .quad _foo@GOT
|
|
|
|
# .quad _foo + 24 - .
|
|
|
|
# .quad _foo - .
|
|
|
|
# .quad _foo + 4 - .
|
|
|
|
# .quad Lanon
|
|
|
|
# .quad Lanon + 4
|
|
|
|
# .long _foo - .
|
|
|
|
# .long _foo +2 - .
|
|
|
|
# .long _foo@GOT - .
|
|
|
|
|