3 ;; This checks a case when an archive contains a bitcode and a regular object
4 ;; files, and a comdat symbol is defined and used in both of them. Previously,
5 ;; lld could lose the flag that the symbol is used in a regular object file
6 ;; which led to the LTO backend internalizing the symbol and the linker
7 ;; reporting an "undefined symbol" error.
9 ;; In this test, group "foo" in "obj.o" is rejected in favor of "bc.bc" but we
10 ;; need to prevent LTO from internalizing "foo" as there is still a reference
11 ;; from outside the group in "obj.o".
14 RUN: split-file %s %t.dir
17 RUN: llvm-mc -filetype=obj -triple=x86_64 start.s -o start.o
18 RUN: llvm-mc -filetype=obj -triple=x86_64 obj.s -o obj.o
19 RUN: llvm-as bc.ll -o bc.bc
20 RUN: llvm-nm bc.bc --no-sort | FileCheck %s --check-prefix=BCSYM
21 RUN: llvm-ar rc lib.a obj.o bc.bc
22 RUN: ld.lld start.o lib.a -y foo -y bar -o /dev/null | FileCheck %s --check-prefix=TRACE
24 ;; "bar" should be encountered before "foo" so that it triggers the loading of
25 ;; "obj.o" while "foo" is still lazy.
29 ;; Check that the symbols are handled in the expected order.
30 TRACE: lib.a(obj.o): lazy definition of foo
31 TRACE-NEXT: lib.a(obj.o): lazy definition of bar
32 TRACE-NEXT: lib.a(bc.bc): definition of foo
33 TRACE-NEXT: lib.a(bc.bc): reference to bar
34 TRACE-NEXT: lib.a(obj.o): definition of bar
35 TRACE-NEXT: lib.a(obj.o): reference to foo
36 TRACE-NEXT: <internal>: reference to foo
37 ;; The definition of "foo" is visible outside the LTO result.
38 TRACE-NEXT: {{.*}}.lto.o: definition of foo
39 TRACE-NEXT: {{.*}}.lto.o: reference to bar
50 .section .text.foo,"axG",@progbits,foo,comdat
54 .section .text.bar,"ax",@progbits
59 target triple = "x86_64-unknown-linux-gnu"
60 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
66 define linkonce_odr void @foo() comdat {