brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 88e294e Raw
75 lines · plain
1REQUIRES: x862 3;; This checks a case when an archive contains a bitcode and a regular object4;; 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 file6;; which led to the LTO backend internalizing the symbol and the linker7;; reporting an "undefined symbol" error.8 9;; In this test, group "foo" in "obj.o" is rejected in favor of "bc.bc" but we10;; need to prevent LTO from internalizing "foo" as there is still a reference11;; from outside the group in "obj.o".12 13RUN: rm -rf %t.dir14RUN: split-file %s %t.dir15RUN: cd %t.dir16 17RUN: llvm-mc -filetype=obj -triple=x86_64 start.s -o start.o18RUN: llvm-mc -filetype=obj -triple=x86_64 obj.s -o obj.o19RUN: llvm-as bc.ll -o bc.bc20RUN: llvm-nm bc.bc --no-sort | FileCheck %s --check-prefix=BCSYM21RUN: llvm-ar rc lib.a obj.o bc.bc22RUN: ld.lld start.o lib.a -y foo -y bar -o /dev/null | FileCheck %s --check-prefix=TRACE23 24;; "bar" should be encountered before "foo" so that it triggers the loading of25;; "obj.o" while "foo" is still lazy.26BCSYM:      U bar27BCSYM-NEXT: W foo28 29;; Check that the symbols are handled in the expected order.30TRACE:      lib.a(obj.o): lazy definition of foo31TRACE-NEXT: lib.a(obj.o): lazy definition of bar32TRACE-NEXT: lib.a(bc.bc): definition of foo33TRACE-NEXT: lib.a(bc.bc): reference to bar34TRACE-NEXT: lib.a(obj.o): definition of bar35TRACE-NEXT: lib.a(obj.o): reference to foo36TRACE-NEXT: <internal>: reference to foo37;; The definition of "foo" is visible outside the LTO result.38TRACE-NEXT: {{.*}}.lto.o: definition of foo39TRACE-NEXT: {{.*}}.lto.o: reference to bar40 41;--- start.s42  .global _start, baz43_start:44  call baz45 46;--- obj.s47  .weak foo48  .global bar49 50  .section .text.foo,"axG",@progbits,foo,comdat51foo:52  ret53 54  .section .text.bar,"ax",@progbits55bar:56  call foo57 58;--- bc.ll59target triple = "x86_64-unknown-linux-gnu"60target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"61 62$foo = comdat any63 64declare void @bar()65 66define linkonce_odr void @foo() comdat {67  ret void68}69 70define void @baz() {71  call void @foo()72  call void @bar()73  ret void74}75