1# REQUIRES: x86 2# RUN: mkdir -p %t 3 4## This test demonstrates that when an archive file is fetched, its symbols 5## always override any conflicting dylib symbols, regardless of any weak 6## definition flags. 7 8# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o 9# RUN: echo ".globl _foo; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/libfoo.o 10# RUN: %lld -dylib -install_name \ 11# RUN: @executable_path/libfoo.dylib %t/libfoo.o -o %t/libfoo.dylib 12 13# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o 14# RUN: echo ".globl _foo, _bar; .section __TEXT,nonweak; _bar: _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/foo.o 15# RUN: echo ".globl _foo, _bar; .weak_definition _foo; .section __TEXT,weak; _bar: _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/weakfoo.o 16 17# RUN: rm -f %t/foo.a 18# RUN: llvm-ar --format=darwin rcs %t/foo.a %t/foo.o 19# RUN: rm -f %t/weakfoo.a 20# RUN: llvm-ar --format=darwin rcs %t/weakfoo.a %t/weakfoo.o 21 22# PREFER-WEAK-OBJECT: O __TEXT,weak _foo 23# PREFER-NONWEAK-OBJECT: O __TEXT,nonweak _foo 24 25# RUN: %lld -lSystem -o %t/nonweak-dylib-weak-ar -L%t -lfoo %t/weakfoo.a %t/test.o 26# RUN: llvm-objdump --macho --lazy-bind --syms %t/nonweak-dylib-weak-ar | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT 27# RUN: %lld -lSystem -o %t/weak-ar-nonweak-dylib -L%t %t/weakfoo.a -lfoo %t/test.o 28# RUN: llvm-objdump --macho --lazy-bind --syms %t/weak-ar-nonweak-dylib | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT 29 30# RUN: %lld -lSystem -o %t/weak-obj-nonweak-dylib -L%t %t/weakfoo.o -lfoo %t/test.o 31# RUN: llvm-objdump --macho --lazy-bind --syms %t/weak-obj-nonweak-dylib | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT 32# RUN: %lld -lSystem -o %t/nonweak-dylib-weak-obj -L%t -lfoo %t/weakfoo.o %t/test.o 33# RUN: llvm-objdump --macho --lazy-bind --syms %t/nonweak-dylib-weak-obj | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT 34 35.globl _main 36_main: 37 callq _foo 38 callq _bar 39 ret 40