File: rebase-opcodes.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (85 lines) | stat: -rw-r--r-- 2,722 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# REQUIRES: x86

# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: %lld -dylib %t.o -o %t.dylib
# RUN: obj2yaml %t.dylib | FileCheck %s

.text
.globl _foo
_foo:

.data
# CHECK: RebaseOpcodes:
# CHECK-NEXT: Opcode:          REBASE_OPCODE_SET_TYPE_IMM
# CHECK-NEXT: Imm:             1
# CHECK-NEXT: Opcode:          REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
# CHECK-NEXT: Imm:             1
# CHECK-NEXT: ExtraData:       [ 0x0 ]

## 1/ Single rebases with a gap after them are encoded as REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB.
.quad _foo
.space 16
# CHECK-NEXT: Opcode:          REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB
# CHECK-NEXT: Imm:             0
# CHECK-NEXT: ExtraData:       [ 0x10 ]

## 2/ Consecutive rebases are encoded as REBASE_OPCODE_DO_REBASE_IMM_TIMES.
.quad _foo
.quad _foo
.quad _foo
# CHECK-NEXT: Opcode:          REBASE_OPCODE_DO_REBASE_IMM_TIMES
# CHECK-NEXT: Imm:             3

## 3/ Gaps smaller than 16 words are encoded as REBASE_OPCODE_ADD_ADDR_IMM_SCALED.
.space 120
# CHECK-NEXT: Opcode:          REBASE_OPCODE_ADD_ADDR_IMM_SCALED
# CHECK-NEXT: Imm:             15

## 4/ Rebases with equal gaps betwen them are encoded as REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB.
.quad _foo
.space 16
.quad _foo
.space 16
# CHECK-NEXT: Opcode:          REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB
# CHECK-NEXT: Imm:             0
# CHECK-NEXT: ExtraData:       [ 0x2, 0x10 ]

## 5/ Rebase does not become a part of DO_REBASE_ULEB_TIMES_SKIPPING_ULEB if the next rebase is closer than the gap.
.quad _foo
.space 8
# CHECK-NEXT: Opcode:          REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB
# CHECK-NEXT: Imm:             0
# CHECK-NEXT: ExtraData:       [ 0x8 ]

.quad _foo
.quad _foo
# CHECK-NEXT: Opcode:          REBASE_OPCODE_DO_REBASE_IMM_TIMES
# CHECK-NEXT: Imm:             2

## 6/ Large gaps are encoded as REBASE_OPCODE_ADD_ADDR_ULEB.
.space 128
# CHECK-NEXT: Opcode:          REBASE_OPCODE_ADD_ADDR_ULEB
# CHECK-NEXT: Imm:             0
# CHECK-NEXT: ExtraData:       [ 0x80 ]

.quad _foo
.space 8
.quad _foo
.space 8
.quad _foo
# CHECK-NEXT: Opcode:          REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB
# CHECK-NEXT: Imm:             0
# CHECK-NEXT: ExtraData:       [ 0x3, 0x8 ]


## 7/ An add opcode is emitted if the next relocation is farther away than the DO_REBASE_ULEB_TIMES_SKIPPING_ULEB gap.
.space 16
.quad _foo
# CHECK-NEXT: Opcode:          REBASE_OPCODE_ADD_ADDR_IMM_SCALED
# CHECK-NEXT: Imm:             1
# CHECK-NEXT: Opcode:          REBASE_OPCODE_DO_REBASE_IMM_TIMES
# CHECK-NEXT: Imm:             1

## 8/ The rebase section is terminated by REBASE_OPCODE_DONE.
# CHECK-NEXT: Opcode:          REBASE_OPCODE_DONE
# CHECK-NEXT: Imm:             0