llvm-project

Форк
0
/
x86-64-reloc-signed.s 
88 строк · 2.6 Кб
1
# REQUIRES: x86
2
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
3
# RUN: echo _t > %t.order
4
# RUN: %lld -o %t -order_file %t.order %t.o
5
# RUN: llvm-objdump --section-headers --syms -D %t | FileCheck %s
6

7
# CHECK-LABEL: Sections:
8
# CHECK:       __foo         {{[0-9a-f]+}}  [[#%x,FOO:]]  DATA
9

10
# CHECK-LABEL: SYMBOL TABLE:
11
# CHECK:       [[#%x,S:]]  g     O __DATA,__data _s
12

13
# CHECK-LABEL: Disassembly of section
14
# CHECK:      <_main>:
15
# CHECK-NEXT:   movl {{.*}}  ## imm =
16
# CHECK-NEXT:                ## 0x[[#S]]
17
# CHECK-NEXT:   callq {{.*}}
18
# CHECK-NEXT:   movl {{.*}}  ## 0x[[#S + 2]]
19
# CHECK-NEXT:   callq {{.*}}
20
# CHECK-NEXT:   movb {{.*}}  ## 0x[[#S]]
21
# CHECK-NEXT:   callq {{.*}}
22
# CHECK:      <__not_text>:
23
# CHECK-NEXT:   movl {{.*}}  ## imm =
24
# CHECK-NEXT:                ## 0x[[#FOO + 8]]
25
# CHECK-NEXT:   callq {{.*}}
26
# CHECK-NEXT:   movl {{.*}}  ## 0x[[#FOO + 8 + 2]]
27
# CHECK-NEXT:   callq {{.*}}
28
# CHECK-NEXT:   movb {{.*}}  ## 0x[[#FOO + 8]]
29
# CHECK-NEXT:   callq {{.*}}
30

31
.section __TEXT,__text
32
.globl _main
33
_main:
34
  ## Symbol relocations
35
  movl $0x434241, _s(%rip)  # X86_64_RELOC_SIGNED_4
36
  callq _f
37
  movl $0x44, _s+2(%rip)    # X86_64_RELOC_SIGNED_2
38
  callq _f
39
  movb $0x45, _s(%rip)      # X86_64_RELOC_SIGNED_1
40
  callq _f
41
  xorq %rax, %rax
42
  ret
43

44
_f:
45
  movl $0x2000004, %eax # write() syscall
46
  mov $1, %rdi # stdout
47
  leaq _s(%rip), %rsi
48
  mov $3, %rdx # length
49
  syscall
50
  ret
51

52
.section __TEXT,__not_text
53
  ## Section relocations. We intentionally put them in a separate section since
54
  ## the __text section typically starts at an address of zero in object files,
55
  ## and so does not fully exercise the relocation logic.
56
  movl $0x434241, L._s(%rip)  # X86_64_RELOC_SIGNED_4
57
  callq _f
58
  movl $0x44, L._s+2(%rip)    # X86_64_RELOC_SIGNED_2
59
  callq _f
60
  movb $0x45, L._s(%rip)      # X86_64_RELOC_SIGNED_1
61
  callq _f
62
  ret
63

64
.section __DATA,__data
65
.globl _s
66
_s:
67
  .space 5
68

69
## Create a new section to force the assembler to use a section relocation for
70
## the private symbol L._s. Otherwise, it will instead use a nearby non-private
71
## symbol to create a symbol relocation plus an addend.
72
.section __DATA,__foo
73
L._s:
74
  .space 1
75

76
## This symbol exists in order to split __foo into two subsections, thereby
77
## testing that our code matches the relocations with the right target
78
## subsection. In particular, although L._s+2 points to an address within _t's
79
## subsection, it's defined relative to L._s, and should therefore be associated
80
## with L._s' subsection.
81
##
82
## We furthermore use an order file to rearrange these subsections so that a
83
## mistake here will be obvious.
84
.globl _t
85
_t:
86
  .quad 123
87

88
.subsections_via_symbols
89

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.