zig/deps/lld/test/mach-o/parse-text-relocs-arm64.yaml

238 lines
8.3 KiB
YAML

# 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
#
# Test parsing and writing of arm64 text 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
flags: [ ]
has-UUID: false
OS: unknown
sections:
- segment: __TEXT
section: __text
type: S_REGULAR
attributes: [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
address: 0x0000000000000000
content: [ 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x94,
0x01, 0x00, 0x00, 0x90, 0x20, 0x00, 0x40, 0x39,
0x20, 0x00, 0x40, 0x79, 0x20, 0x00, 0x40, 0xB9,
0x20, 0x00, 0x40, 0xF9, 0x20, 0x00, 0xC0, 0x3D,
0x01, 0x00, 0x00, 0x90, 0x20, 0x00, 0x40, 0xB9,
0x01, 0x00, 0x00, 0x90, 0x20, 0x00, 0x40, 0xF9,
0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x40, 0xF9 ]
relocations:
- offset: 0x00000034
type: ARM64_RELOC_TLVP_LOAD_PAGEOFF12
length: 2
pc-rel: false
extern: true
symbol: 5
- offset: 0x00000030
type: ARM64_RELOC_TLVP_LOAD_PAGE21
length: 2
pc-rel: true
extern: true
symbol: 5
- offset: 0x0000002C
type: ARM64_RELOC_GOT_LOAD_PAGEOFF12
length: 2
pc-rel: false
extern: true
symbol: 6
- offset: 0x00000028
type: ARM64_RELOC_GOT_LOAD_PAGE21
length: 2
pc-rel: true
extern: true
symbol: 6
- offset: 0x00000024
type: ARM64_RELOC_ADDEND
length: 2
pc-rel: false
extern: false
symbol: 16
- offset: 0x00000024
type: ARM64_RELOC_PAGEOFF12
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000020
type: ARM64_RELOC_ADDEND
length: 2
pc-rel: false
extern: false
symbol: 16
- offset: 0x00000020
type: ARM64_RELOC_PAGE21
length: 2
pc-rel: true
extern: true
symbol: 2
- offset: 0x0000001C
type: ARM64_RELOC_PAGEOFF12
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000018
type: ARM64_RELOC_PAGEOFF12
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000014
type: ARM64_RELOC_PAGEOFF12
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000010
type: ARM64_RELOC_PAGEOFF12
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x0000000C
type: ARM64_RELOC_PAGEOFF12
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000008
type: ARM64_RELOC_PAGE21
length: 2
pc-rel: true
extern: true
symbol: 2
- offset: 0x00000004
type: ARM64_RELOC_ADDEND
length: 2
pc-rel: false
extern: false
symbol: 8
- offset: 0x00000004
type: ARM64_RELOC_BRANCH26
length: 2
pc-rel: true
extern: true
symbol: 4
- offset: 0x00000000
type: ARM64_RELOC_BRANCH26
length: 2
pc-rel: true
extern: true
symbol: 4
- segment: __DATA
section: __data
type: S_REGULAR
attributes: [ ]
alignment: 2
address: 0x0000000000000038
content: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]
local-symbols:
- name: ltmp0
type: N_SECT
sect: 1
value: 0x0000000000000000
- name: _func
type: N_SECT
sect: 1
value: 0x0000000000000000
- name: _v1
type: N_SECT
sect: 2
value: 0x0000000000000038
- name: ltmp1
type: N_SECT
sect: 2
value: 0x0000000000000038
undefined-symbols:
- name: _foo
type: N_UNDF
scope: [ N_EXT ]
value: 0x0000000000000000
- name: _tlv
type: N_UNDF
scope: [ N_EXT ]
value: 0x0000000000000000
- name: _v2
type: N_UNDF
scope: [ N_EXT ]
value: 0x0000000000000000
...
# CHECK: defined-atoms:
# CHECK: - name: _v1
# CHECK: type: data
# CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
# CHECK: 00, 00, 00, 00 ]
# CHECK: - name: _func
# CHECK: content: [ 00, 00, 00, 94, 00, 00, 00, 94, 01, 00, 00, 90,
# CHECK: 20, 00, 40, 39, 20, 00, 40, 79, 20, 00, 40, B9,
# CHECK: 20, 00, 40, F9, 20, 00, C0, 3D, 01, 00, 00, 90,
# CHECK: 20, 00, 40, B9, 01, 00, 00, 90, 20, 00, 40, F9,
# CHECK: 00, 00, 00, 90, 00, 00, 40, F9 ]
# CHECK: references:
# CHECK: - kind: branch26
# CHECK: offset: 0
# CHECK: target: _foo
# CHECK: - kind: branch26
# CHECK: offset: 4
# CHECK: target: _foo
# CHECK: addend: 8
# CHECK: - kind: page21
# CHECK: offset: 8
# CHECK: target: _v1
# CHECK: - kind: offset12
# CHECK: offset: 12
# CHECK: target: _v1
# CHECK: - kind: offset12scale2
# CHECK: offset: 16
# CHECK: target: _v1
# CHECK: - kind: offset12scale4
# CHECK: offset: 20
# CHECK: target: _v1
# CHECK: - kind: offset12scale8
# CHECK: offset: 24
# CHECK: target: _v1
# CHECK: - kind: offset12scale16
# CHECK: offset: 28
# CHECK: target: _v1
# CHECK: - kind: page21
# CHECK: offset: 32
# CHECK: target: _v1
# CHECK: addend: 16
# CHECK: - kind: offset12scale4
# CHECK: offset: 36
# CHECK: target: _v1
# CHECK: addend: 16
# CHECK: - kind: gotPage21
# CHECK: offset: 40
# CHECK: target: _v2
# CHECK: - kind: gotOffset12
# CHECK: offset: 44
# CHECK: target: _v2
# CHECK: - kind: tlvPage21
# CHECK: offset: 48
# CHECK: target: _tlv
# CHECK: - kind: tlvOffset12
# CHECK: offset: 52
# CHECK: target: _tlv
# CHECK: undefined-atoms:
# CHECK: - name: _foo
# CHECK: - name: _tlv
# CHECK: - name: _v2