1# REQUIRES: x86 2# RUN: mkdir -p %t 3# RUN: echo ".global f, g; .section __TEXT,test_g; g: callq f" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/g.o 4# RUN: echo ".global f; .section __TEXT,test_f1; f: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/f1.o 5# RUN: echo ".global f; .section __TEXT,test_f2; f: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/f2.o 6# RUN: echo ".global f, g; .section __TEXT,test_fg; f: ret; g: callq f" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/fg.o 7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o 8# RUN: %lld -dylib -o %t/libf1.dylib %t/f1.o -lSystem 9 10# RUN: rm -f %t/libf2_g.a 11# RUN: llvm-ar rcs %t/libf2_g.a %t/f2.o %t/g.o 12 13# RUN: rm -f %t/libfg.a 14# RUN: llvm-ar rcs %t/libfg.a %t/fg.o 15 16# RUN: %lld %t/libf1.dylib %t/libf2_g.a %t/test.o -o %t/test.out -lSystem 17# RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix DYLIB-FIRST 18# DYLIB-FIRST: SYMBOL TABLE: 19# DYLIB-FIRST-DAG: __TEXT,test_g g 20# DYLIB-FIRST: Lazy bind table: 21# DYLIB-FIRST-NEXT: segment section address dylib symbol 22# DYLIB-FIRST-NEXT: __DATA __la_symbol_ptr {{[0-9a-z]+}} libf1 f 23 24# RUN: %lld %t/libf2_g.a %t/libf1.dylib %t/test.o -o %t/test.out -lSystem 25# RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST 26# ARCHIVE-FIRST: SYMBOL TABLE: 27# ARCHIVE-FIRST-DAG: __TEXT,test_f2 f 28# ARCHIVE-FIRST-DAG: __TEXT,test_g g 29# ARCHIVE-FIRST: Lazy bind table: 30# ARCHIVE-FIRST-NEXT: segment section address dylib symbol 31# ARCHIVE-FIRST-EMPTY: 32 33# RUN: %lld %t/libf1.dylib %t/libfg.a %t/test.o -o %t/test.out -lSystem 34# RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-PRIORITY 35# ARCHIVE-PRIORITY: SYMBOL TABLE: 36# ARCHIVE-PRIORITY-DAG: __TEXT,test_fg f 37# ARCHIVE-PRIORITY-DAG: __TEXT,test_fg g 38# ARCHIVE-PRIORITY: Lazy bind table: 39# ARCHIVE-PRIORITY-NEXT: segment section address dylib symbol 40# ARCHIVE-PRIORITY-EMPTY: 41 42.global g 43.global _main 44_main: 45 callq g 46 ret 47