3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s \
4 # RUN: -o %t/libhello.o
5 # RUN: %lld -lSystem -dylib -install_name \
6 # RUN: @executable_path/libhello.dylib %t/libhello.o -o %t/libhello.dylib
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
9 # RUN: %lld -lSystem -o %t/test %t/test.o -L%t -lhello
10 # RUN: llvm-objdump --macho --full-contents --rebase --bind %t/test | FileCheck %s --check-prefixes=CHECK,PIE --match-full-lines
11 # RUN: %lld -no_pie -data_const -lSystem -o %t/test %t/test.o -L%t -lhello
12 # RUN: llvm-objdump --macho --full-contents --rebase --bind %t/test | FileCheck %s --check-prefixes=CHECK,NO-PIE --match-full-lines
14 ## Check that the GOT references the cstrings. --full-contents displays the
15 ## address offset and the contents at that address very similarly, so am using
16 ## --match-full-lines to make sure we match on the right thing.
17 # CHECK: Contents of section __TEXT,__cstring:
18 # CHECK-NEXT: 100000444 {{.*}}
20 ## 1st 8 bytes refer to the start of __cstring + 0xe, 2nd 8 bytes refer to the
22 # CHECK: Contents of section __DATA_CONST,__got:
23 # CHECK-NEXT: [[#%X,ADDR:]] 52040000 01000000 44040000 01000000 {{.*}}
24 # CHECK-NEXT: [[#ADDR + 16]] 00000000 00000000 {{.*}}
26 ## Check that the rebase table is empty.
27 # NO-PIE: Rebase table:
28 # NO-PIE-NEXT: segment section address type
31 # PIE-NEXT: segment section address type
32 # PIE-NEXT: __DATA_CONST __got 0x[[#%X,ADDR:]] pointer
33 # PIE-NEXT: __DATA_CONST __got 0x[[#ADDR + 8]] pointer
35 ## Check that a non-locally-defined symbol is still bound at the correct offset:
37 # CHECK-NEXT: Bind table:
38 # CHECK-NEXT: segment section address type addend dylib symbol
39 # CHECK-NEXT: __DATA_CONST __got 0x[[#ADDR+16]] pointer 0 libhello _hello_its_me
45 movl $
0x2000004, %eax
# write() syscall
47 movq _hello_its_me@GOTPCREL
(%rip
), %rsi
48 mov $
15, %rdx
# length of str
51 movl $
0x2000004, %eax
# write() syscall
53 ## We use pushq/popq here instead of movq in order to avoid relaxation.
54 pushq _hello_world@GOTPCREL
(%rip
)
56 mov $
13, %rdx
# length of str
59 movl $
0x2000004, %eax
# write() syscall
61 pushq _goodbye_world@GOTPCREL
(%rip
)
63 mov $
15, %rdx
# length of str
69 .section __TEXT,__cstring
71 .asciz "Hello world!\n"
74 .asciz "Goodbye world!\n"