summaryrefslogtreecommitdiffstats
path: root/lld/test/mach-o/parse-data-relocs-x86_64.yaml
blob: 6ba2e48d28504676a0a2b4f4517392a61e7f55ca (plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# 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.
#
# 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.
#
#_foo:
#  ret
#
#_bar:
#  ret
#  
#  .section __DATA,__custom
#L1:
#  .quad 0
#  
#  .data
#_d:
#  .quad   _foo
#  .quad   _foo+4
#  .quad   _foo - .
#  .quad   L1
#  .quad   L1 + 2
#  .quad   _foo - .
#  .quad   _foo + 4 - .
#  .quad   L1 - .
#  .long   _foo - .
#  .long   _foo + 4 - .
#  .long   L1 - .
#

--- !mach-o
arch:            x86_64
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:         [ 0xC3, 0xC3 ]
  - segment:         __DATA
    section:         __custom
    type:            S_REGULAR
    attributes:      [  ]
    address:         0x0000000000000002
    content:         [ 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, 
                       0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
                       0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
                       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 ]
    relocations:     
      - offset:          0x00000040
        type:            X86_64_RELOC_SUBTRACTOR
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000040
        type:            X86_64_RELOC_UNSIGNED
        length:          2
        pc-rel:          false
        extern:          false
        symbol:          2
      - offset:          0x0000003C
        type:            X86_64_RELOC_SUBTRACTOR
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x0000003C
        type:            X86_64_RELOC_UNSIGNED
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          0
      - offset:          0x00000038
        type:            X86_64_RELOC_SUBTRACTOR
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000038
        type:            X86_64_RELOC_UNSIGNED
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          0
      - offset:          0x00000030
        type:            X86_64_RELOC_SUBTRACTOR
        length:          3
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000030
        type:            X86_64_RELOC_UNSIGNED
        length:          3
        pc-rel:          false
        extern:          false
        symbol:          2
      - offset:          0x00000028
        type:            X86_64_RELOC_SUBTRACTOR
        length:          3
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000028
        type:            X86_64_RELOC_UNSIGNED
        length:          3
        pc-rel:          false
        extern:          true
        symbol:          0
      - offset:          0x00000020
        type:            X86_64_RELOC_SUBTRACTOR
        length:          3
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000020
        type:            X86_64_RELOC_UNSIGNED
        length:          3
        pc-rel:          false
        extern:          true
        symbol:          0
      - offset:          0x00000018
        type:            X86_64_RELOC_UNSIGNED
        length:          3
        pc-rel:          false
        extern:          false
        symbol:          2
      - offset:          0x00000010
        type:            X86_64_RELOC_UNSIGNED
        length:          3
        pc-rel:          false
        extern:          false
        symbol:          2
      - offset:          0x00000008
        type:            X86_64_RELOC_UNSIGNED
        length:          3
        pc-rel:          false
        extern:          true
        symbol:          0
      - offset:          0x00000000
        type:            X86_64_RELOC_UNSIGNED
        length:          3
        pc-rel:          false
        extern:          true
        symbol:          0
local-symbols:   
  - name:            _foo
    type:            N_SECT
    sect:            1
    value:           0x0000000000000000
  - name:            _bar
    type:            N_SECT
    sect:            1
    value:           0x0000000000000001
  - name:            _d
    type:            N_SECT
    sect:            3
    value:           0x0000000000000008
...


# CHECK: defined-atoms:
# CHECK:  - name:            _d
# CHECK:    type:            data
# CHECK:    references:      
# CHECK:      - kind:            pointer64
# CHECK:        offset:          0
# CHECK:        target:          _foo
# CHECK:      - kind:            pointer64
# CHECK:        offset:          8
# CHECK:        target:          _foo
# CHECK:        addend:          4
# CHECK:      - kind:            pointer64Anon
# CHECK:        offset:          16
# CHECK:        target:          L003
# CHECK:      - kind:            pointer64Anon
# CHECK:        offset:          24
# CHECK:        target:          L003
# CHECK:        addend:          2
# CHECK:      - kind:            delta64
# CHECK:        offset:          32
# CHECK:        target:          _foo
# CHECK:      - kind:            delta64
# CHECK:        offset:          40
# CHECK:        target:          _foo
# CHECK:        addend:          4
# CHECK:      - kind:            delta64Anon
# CHECK:        offset:          48
# CHECK:        target:          L003
# CHECK:      - kind:            delta32
# CHECK:        offset:          56
# CHECK:        target:          _foo
# CHECK:      - kind:            delta32
# CHECK:        offset:          60
# CHECK:        target:          _foo
# CHECK:        addend:          4
# CHECK:      - kind:            delta32Anon
# CHECK:        offset:          64
# CHECK:        target:          L003
# CHECK:  - name:            _foo
# CHECK:    content:         [ C3 ]
# CHECK:  - name:            _bar
# CHECK:    content:         [ C3 ]
# CHECK:  - ref-name:        L003
# CHECK:    type:            unknown
# CHECK:    content:         [ 00, 00, 00, 00 ]
# CHECK:    section-choice:  custom-required
# CHECK:    section-name:    __DATA/__custom
OpenPOWER on IntegriCloud