llvm-project
46 строк · 1.2 Кб
1; REQUIRES: x86
2; RUN: rm -rf %t; split-file %s %t
3
4;; Test that a weak symbol in a direct .o file wins over
5;; a weak symbol in a .a file.
6;; Like weak-definition-in-main-file.s, but in bitcode.
7
8; RUN: llvm-as %t/test.ll -o %t/test.o
9; RUN: llvm-as %t/weakfoo.ll -o %t/weakfoo.o
10
11; RUN: llvm-ar --format=darwin rcs %t/weakfoo.a %t/weakfoo.o
12
13; PREFER-DIRECT-OBJECT-NOT: O __TEXT,weak _foo
14
15; RUN: %lld -lSystem -o %t/out %t/weakfoo.a %t/test.o
16; RUN: llvm-objdump --syms %t/out | FileCheck %s --check-prefix=PREFER-DIRECT-OBJECT
17
18;--- weakfoo.ll
19target triple = "x86_64-apple-macosx10.15.0"
20target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
21
22define void @baz() noinline optnone {
23ret void
24}
25
26define weak void @foo() noinline optnone section "__TEXT,weak" {
27ret void
28}
29
30;--- test.ll
31target triple = "x86_64-apple-macosx10.15.0"
32target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
33
34declare void @baz();
35
36define weak void @foo() noinline optnone {
37ret void
38}
39
40define void @main() {
41; This pulls in weakfoo.a due to the __baz undef, but __foo should
42; still be resolved against the weak symbol in this file.
43call void @baz()
44call void @foo()
45ret void
46}
47