46 lines · plain
1# REQUIRES: x862 3## This tests that we can link against these synthetic symbols even4## if they are not in the symbol table.5 6# RUN: rm -rf %t; split-file %s %t7 8## Test that in a dylib, we can link against __mh_dylib_header9## (but not in other types of files)10 11# RUN: llvm-mc %t/dylib.s -triple=x86_64-apple-macos10.15 -filetype=obj -o %t/dylib.o12# RUN: %lld -dylib -dead_strip %t/dylib.o -o %t/dylib.out13# RUN: llvm-objdump -m --syms %t/dylib.out | FileCheck %s --check-prefix DYLIB14 15# RUN: not %lld -o /dev/null %t/dylib.o 2>&1 | FileCheck %s --check-prefix ERR-DYLIB16 17# DYLIB: SYMBOL TABLE:18# DYLIB-NEXT: {{[0-9a-f]+}} g F __TEXT,__text _main19# DYLIB-NEXT-EMPTY:20# ERR-DYLIB: error: undefined symbol: __mh_dylib_header21 22## Test that in an executable, we can link against __mh_execute_header23# RUN: llvm-mc %t/main.s -triple=x86_64-apple-macos10.15 -filetype=obj -o %t/exec.o24# RUN: %lld -dead_strip -lSystem %t/exec.o -o %t/exec.out25 26## But it would be an error trying to reference __mh_execute_header in a dylib27# RUN: not %lld -o /dev/null -dylib %t/exec.o 2>&1 | FileCheck %s --check-prefix ERR-EXEC28 29# ERR-EXEC: error: undefined symbol: __mh_execute_header30 31#--- main.s32.text33.globl _main34_main:35 mov __mh_execute_header@GOTPCREL(%rip), %rax36 ret37.subsections_via_symbols38 39#--- dylib.s40.text41.globl _main42_main:43 mov __mh_dylib_header@GOTPCREL(%rip), %rax44 ret45.subsections_via_symbols46