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 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
|
// REQUIRES: x86-registered-target
// RUN: llvm-mc -n -cas-backend -triple x86_64-apple-darwin9 %s -filetype=obj -o - | llvm-readobj -r --expand-relocs - | FileCheck %s
// RUN: llvm-mc -n -cas-backend -triple x86_64-apple-darwin9 %s -mc-cas-reloc-encode-in=Section -filetype=obj -o - | llvm-readobj -r --expand-relocs - | FileCheck %s
// RUN: llvm-mc -n -cas-backend -triple x86_64-apple-darwin9 %s -mc-cas-reloc-encode-in=CompileUnit -filetype=obj -o - | llvm-readobj -r --expand-relocs - | FileCheck %s
// These examples are taken from <mach-o/x86_64/reloc.h>.
.data
.long 0
.text
_foo:
ret
_baz:
call _foo
call _foo+4
movq _foo@GOTPCREL(%rip), %rax
pushq _foo@GOTPCREL(%rip)
movl _foo(%rip), %eax
movl _foo+4(%rip), %eax
movb $0x12, _foo(%rip)
movl $0x12345678, _foo(%rip)
.quad _foo
_bar:
.quad _foo+4
.quad _foo - _bar
.quad _foo - _bar + 4
.long _foo - _bar
leaq L1(%rip), %rax
leaq L0(%rip), %rax
addl $6,L0(%rip)
addw $500,L0(%rip)
addl $500,L0(%rip)
_prev:
.space 12,0x90
.quad L1
L0:
.quad L0
L_pc:
.quad _foo - L_pc
.quad _foo - L1
L1:
.quad L1 - _prev
.data
.long _foobar@GOTPCREL+4
.long _foo@GOTPCREL+4
.section __DWARF,__debug_frame,regular,debug
.quad L1
.quad _ext_foo
// Make sure local label which overlaps with non-local one is assigned to the
// right atom.
.text
_f2:
L2_0:
addl $0, %eax
L2_1:
_f3:
addl L2_1 - L2_0, %eax
.data
L4:
.long 0
.text
movl L4(%rip), %eax
.section __TEXT,__literal8,8byte_literals
.quad 0
L5:
.quad 0
f6:
.quad 0
L6:
.quad 0
.text
movl L5(%rip), %eax
movl f6(%rip), %eax
movl L6(%rip), %eax
.data
.quad L5
.quad f6
.quad L6
.text
cmpq $0, _foo@GOTPCREL(%rip)
// CHECK: Relocations [
// CHECK-NEXT: Section __data {
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x20
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Section: __literal8
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x18
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Symbol: f6
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x10
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Section: __literal8
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x8
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_GOT (4)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x4
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_GOT (4)
// CHECK-NEXT: Symbol: _foobar
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: Section __text {
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0xDA
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_GOT (4)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0xD3
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED (1)
// CHECK-NEXT: Section: __literal8
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0xCD
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED (1)
// CHECK-NEXT: Symbol: f6
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0xC7
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED (1)
// CHECK-NEXT: Section: __literal8
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0xC1
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED (1)
// CHECK-NEXT: Section: __data
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0xA5
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_SUBTRACTOR (5)
// CHECK-NEXT: Symbol: _prev
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0xA5
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x95
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Symbol: _prev
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x8D
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Symbol: _prev
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x79
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED_4 (8)
// CHECK-NEXT: Symbol: _prev
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x71
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED_2 (7)
// CHECK-NEXT: Symbol: _prev
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x69
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED_1 (6)
// CHECK-NEXT: Symbol: _prev
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x63
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED (1)
// CHECK-NEXT: Symbol: _prev
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x5C
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED (1)
// CHECK-NEXT: Symbol: _prev
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x3D
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x35
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x2D
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED_4 (8)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x26
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED_1 (6)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x20
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED (1)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x1A
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_SIGNED (1)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x14
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_GOT (4)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0xE
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_GOT_LOAD (3)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x7
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_BRANCH (2)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x2
// CHECK-NEXT: PCRel: 1
// CHECK-NEXT: Length: 2
// CHECK-NEXT: Type: X86_64_RELOC_BRANCH (2)
// CHECK-NEXT: Symbol: _foo
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: Section __debug_frame {
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x8
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Symbol: _ext_foo
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x0
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: X86_64_RELOC_UNSIGNED (0)
// CHECK-NEXT: Section: __text
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: ]
|