brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 1d415e3 Raw
75 lines · plain
1# REQUIRES: x862# RUN: mkdir -p %t3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s \4# RUN:   -o %t/libhello.o5# RUN: %lld -lSystem -dylib -install_name \6# RUN:   @executable_path/libhello.dylib %t/libhello.o -o %t/libhello.dylib7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o8 9# RUN: %lld -lSystem -o %t/test %t/test.o -L%t -lhello10# RUN: llvm-objdump --macho --full-contents --rebase --bind %t/test | FileCheck %s --check-prefixes=CHECK,PIE --match-full-lines11# RUN: %lld -no_pie -data_const -lSystem -o %t/test %t/test.o -L%t -lhello12# RUN: llvm-objdump --macho --full-contents --rebase --bind %t/test | FileCheck %s --check-prefixes=CHECK,NO-PIE --match-full-lines13 14## Check that the GOT references the cstrings. --full-contents displays the15## address offset and the contents at that address very similarly, so am using16## --match-full-lines to make sure we match on the right thing.17# CHECK:      Contents of section __TEXT,__cstring:18# CHECK-NEXT: 100000444 {{.*}}19 20## 1st 8 bytes refer to the start of __cstring + 0xe, 2nd 8 bytes refer to the21## start of __cstring22# CHECK:      Contents of section __DATA_CONST,__got:23# CHECK-NEXT: [[#%X,ADDR:]]  52040000 01000000 44040000 01000000 {{.*}}24# CHECK-NEXT: [[#ADDR + 16]] 00000000 00000000 {{.*}}25 26## Check that the rebase table is empty.27# NO-PIE:      Rebase table:28# NO-PIE-NEXT: segment      section  address         type29 30# PIE:      Rebase table:31# PIE-NEXT: segment      section  address          type32# PIE-NEXT: __DATA_CONST __got    0x[[#%X,ADDR:]]  pointer33# PIE-NEXT: __DATA_CONST __got    0x[[#ADDR + 8]]  pointer34 35## Check that a non-locally-defined symbol is still bound at the correct offset:36# CHECK-EMPTY:37# CHECK-NEXT: Bind table:38# CHECK-NEXT: segment      section  address         type     addend  dylib     symbol39# CHECK-NEXT: __DATA_CONST __got    0x[[#ADDR+16]]  pointer  0       libhello  _hello_its_me40 41.globl _main42 43.text44_main:45  movl $0x2000004, %eax # write() syscall46  mov $1, %rdi # stdout47  movq _hello_its_me@GOTPCREL(%rip), %rsi48  mov $15, %rdx # length of str49  syscall50 51  movl $0x2000004, %eax # write() syscall52  mov $1, %rdi # stdout53## We use pushq/popq here instead of movq in order to avoid relaxation.54  pushq _hello_world@GOTPCREL(%rip)55  popq %rsi56  mov $13, %rdx # length of str57  syscall58 59  movl $0x2000004, %eax # write() syscall60  mov $1, %rdi # stdout61  pushq _goodbye_world@GOTPCREL(%rip)62  popq %rsi63  mov $15, %rdx # length of str64  syscall65 66  mov $0, %rax67  ret68 69.section __TEXT,__cstring70_hello_world:71  .asciz "Hello world!\n"72 73_goodbye_world:74  .asciz "Goodbye world!\n"75