File: x86-64-relocs.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 (52 lines) | stat: -rw-r--r-- 1,589 bytes parent folder | download | duplicates (14)
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
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: %lld -lSystem -o %t %t.o
# RUN: llvm-objdump --no-print-imm-hex --section-headers --syms -d %t | FileCheck %s

# CHECK-LABEL: Sections:
# CHECK:       __data {{[0-9a-z]+}} [[#%x, DATA_ADDR:]]

# CHECK-LABEL: SYMBOL TABLE:
# CHECK:       [[#%x, F_ADDR:]] {{.*}} _f

# CHECK-LABEL: <_main>:
## Test X86_64_RELOC_BRANCH
# CHECK:       callq 0x[[#%x, F_ADDR]] <_f>
## Test extern (symbol) X86_64_RELOC_SIGNED
# CHECK:       leaq [[#%u, LOCAL_OFF:]](%rip), %rsi
# CHECK-NEXT:  [[#%x, DATA_ADDR - LOCAL_OFF]]
## Test non-extern (section) X86_64_RELOC_SIGNED
# CHECK:       leaq [[#%u, PRIVATE_OFF:]](%rip), %rsi
# CHECK-NEXT:  [[#%x, DATA_ADDR + 8 - PRIVATE_OFF]]

# RUN: llvm-objdump --section=__const --full-contents %t | FileCheck %s --check-prefix=NONPCREL
# NONPCREL:      Contents of section __DATA_CONST,__const:
# NONPCREL-NEXT: 100001000 08200000 01000000 08200000 01000000

.section __TEXT,__text
.globl _main, _f
_main:
  callq _f # X86_64_RELOC_BRANCH
  mov $0, %rax
  ret

_f:
  leaq _local(%rip), %rsi # Generates a X86_64_RELOC_SIGNED pcrel symbol relocation
  leaq L_.private(%rip), %rsi # Generates a X86_64_RELOC_SIGNED pcrel section relocation
  movq L_.ptr_1(%rip), %rsi
  ret

.data
## References to this generate a symbol relocation
_local:
  .quad 123
## References to this generate a section relocation
L_.private:
  .quad 123

.section __DATA,__const
## These generate X86_64_RELOC_UNSIGNED non-pcrel section relocations
L_.ptr_1:
  .quad L_.private
L_.ptr_2:
  .quad L_.private