llvm-project

Форк
0
/
x86-64-stubs.s 
78 строк · 3.4 Кб
1
# REQUIRES: x86
2
# RUN: rm -rf %t; mkdir -p %t
3
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s \
4
# RUN:   -o %t/libhello.o
5
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libgoodbye.s \
6
# RUN:   -o %t/libgoodbye.o
7
# RUN: %lld -dylib \
8
# RUN:   -install_name @executable_path/libhello.dylib %t/libhello.o \
9
# RUN:   -o %t/libhello.dylib
10
# RUN: %lld -dylib \
11
# RUN:   -install_name @executable_path/libgoodbye.dylib %t/libgoodbye.o \
12
# RUN:   -o %t/libgoodbye.dylib
13

14
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/dylink-lazy.o
15
# RUN: %lld -no_pie -data_const -o %t/dylink-lazy-no-pie \
16
# RUN:   -L%t -lhello -lgoodbye %t/dylink-lazy.o -lSystem
17

18
## When looking at the __stubs section alone, we are unable to easily tell which
19
## symbol each entry points to. So we call objdump twice in order to get the
20
## disassembly of __text and the bind tables first, which allow us to check for
21
## matching entries in __stubs.
22
# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --syms --rebase --bind --lazy-bind %t/dylink-lazy-no-pie > %t/objdump-no-pie
23
# RUN: llvm-objdump --no-print-imm-hex -D --no-show-raw-insn %t/dylink-lazy-no-pie >> %t/objdump-no-pie
24
# RUN: FileCheck %s --check-prefixes=CHECK,NO-PIE < %t/objdump-no-pie
25

26
# RUN: %lld -o %t/dylink-lazy -L%t -lhello -lgoodbye %t/dylink-lazy.o -lSystem
27
# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --syms --rebase --bind --lazy-bind %t/dylink-lazy > %t/objdump
28
# RUN: llvm-objdump --no-print-imm-hex -D --no-show-raw-insn %t/dylink-lazy >> %t/objdump
29
# RUN: FileCheck %s --check-prefixes=CHECK,PIE < %t/objdump
30

31
# CHECK-LABEL: SYMBOL TABLE:
32
# CHECK:       {{0*}}[[#%x, IMGLOADER:]] l {{.*}} __DATA,__data __dyld_private
33

34
# CHECK-LABEL: Disassembly of section __TEXT,__text:
35
# CHECK:         callq 0x[[#%x, HELLO_STUB:]]
36
# CHECK-NEXT:    callq 0x[[#%x, GOODBYE_STUB:]]
37

38
## Check that the rebase table is empty.
39
# NO-PIE-LABEL: Rebase table:
40
# NO-PIE-NEXT:  segment section address type
41

42
# PIE-LABEL:   Rebase table:
43
# PIE-NEXT:    segment  section            address           type
44
# PIE-NEXT:    __DATA   __la_symbol_ptr    0x[[#%X, ADDR:]]  pointer
45
# PIE-NEXT:    __DATA   __la_symbol_ptr    0x[[#ADDR + 8]]   pointer
46

47
# CHECK-EMPTY:
48
# CHECK-NEXT:  Bind table:
49
# CHECK:       __DATA_CONST __got 0x[[#%x, BINDER:]] pointer 0 libSystem dyld_stub_binder
50

51
# CHECK-LABEL: Lazy bind table:
52
# CHECK-DAG:   __DATA __la_symbol_ptr 0x{{0*}}[[#%x, HELLO_LAZY_PTR:]] libhello _print_hello
53
# CHECK-DAG:   __DATA __la_symbol_ptr 0x{{0*}}[[#%x, GOODBYE_LAZY_PTR:]] libgoodbye _print_goodbye
54

55
# CHECK-LABEL: Disassembly of section __TEXT,__stubs:
56
# CHECK-DAG:     [[#%x, HELLO_STUB]]:   jmpq *[[#%u, HELLO_LAZY_PTR - HELLO_STUB - 6]](%rip)
57
# CHECK-DAG:     [[#%x, GOODBYE_STUB]]: jmpq *[[#%u, GOODBYE_LAZY_PTR - GOODBYE_STUB - 6]](%rip)
58

59
# CHECK-LABEL: Disassembly of section __TEXT,__stub_helper:
60
# CHECK:         {{0*}}[[#%x, STUB_HELPER_ENTRY:]] <__stub_helper>:
61
# CHECK-NEXT:    leaq [[#%u, IMGLOADER - STUB_HELPER_ENTRY - 7]](%rip), %r11
62
# CHECK-NEXT:    pushq %r11
63
# CHECK-NEXT:    jmpq *[[#%u, BINDER_OFF:]](%rip)
64
# CHECK-NEXT:    [[#%x, BINDER - BINDER_OFF]]: nop
65
# CHECK-NEXT:    pushq $0
66
# CHECK-NEXT:    jmp 0x[[#STUB_HELPER_ENTRY]]
67
# CHECK-NEXT:    pushq $21
68
# CHECK-NEXT:    jmp 0x[[#STUB_HELPER_ENTRY]]
69

70
.text
71
.globl _main
72

73
_main:
74
  sub $8, %rsp # 16-byte-align the stack; dyld checks for this
75
  callq _print_hello
76
  callq _print_goodbye
77
  add $8, %rsp
78
  ret
79

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

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

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

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