1*94d94551SNico Weber; REQUIRES: x86 2210e8984SNico Weber; RUN: rm -rf %t; split-file %s %t 3210e8984SNico Weber 4210e8984SNico Weber;; Test that a weak symbol in a direct .o file wins over 5210e8984SNico Weber;; a weak symbol in a .a file. 6210e8984SNico Weber;; Like weak-definition-in-main-file.s, but in bitcode. 7210e8984SNico Weber 8210e8984SNico Weber; RUN: llvm-as %t/test.ll -o %t/test.o 9210e8984SNico Weber; RUN: llvm-as %t/weakfoo.ll -o %t/weakfoo.o 10210e8984SNico Weber 11210e8984SNico Weber; RUN: llvm-ar --format=darwin rcs %t/weakfoo.a %t/weakfoo.o 12210e8984SNico Weber 13210e8984SNico Weber; PREFER-DIRECT-OBJECT-NOT: O __TEXT,weak _foo 14210e8984SNico Weber 15210e8984SNico Weber; RUN: %lld -lSystem -o %t/out %t/weakfoo.a %t/test.o 16210e8984SNico Weber; RUN: llvm-objdump --syms %t/out | FileCheck %s --check-prefix=PREFER-DIRECT-OBJECT 17210e8984SNico Weber 18210e8984SNico Weber;--- weakfoo.ll 19210e8984SNico Webertarget triple = "x86_64-apple-macosx10.15.0" 20210e8984SNico Webertarget datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 21210e8984SNico Weber 22210e8984SNico Weberdefine void @baz() noinline optnone { 23210e8984SNico Weber ret void 24210e8984SNico Weber} 25210e8984SNico Weber 26210e8984SNico Weberdefine weak void @foo() noinline optnone section "__TEXT,weak" { 27210e8984SNico Weber ret void 28210e8984SNico Weber} 29210e8984SNico Weber 30210e8984SNico Weber;--- test.ll 31210e8984SNico Webertarget triple = "x86_64-apple-macosx10.15.0" 32210e8984SNico Webertarget datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 33210e8984SNico Weber 34210e8984SNico Weberdeclare void @baz(); 35210e8984SNico Weber 36210e8984SNico Weberdefine weak void @foo() noinline optnone { 37210e8984SNico Weber ret void 38210e8984SNico Weber} 39210e8984SNico Weber 40210e8984SNico Weberdefine void @main() { 41210e8984SNico Weber ; This pulls in weakfoo.a due to the __baz undef, but __foo should 42210e8984SNico Weber ; still be resolved against the weak symbol in this file. 43210e8984SNico Weber call void @baz() 44210e8984SNico Weber call void @foo() 45210e8984SNico Weber ret void 46210e8984SNico Weber} 47