134 lines · plain
1# REQUIRES: x862 3# RUN: rm -rf %t; split-file %s %t4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/calls-foo.s -o %t/calls-foo.o6# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/1.s -o %t/1.o7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/2.s -o %t/2.o8# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/common.s -o %t/common.o9 10# RUN: echo "%t/1.o" > %t/filelist11# RUN: echo "%t/2.o" >> %t/filelist12 13# RUN: llvm-as %t/1.ll -o %t/1.bc14# RUN: llvm-as %t/2.ll -o %t/2.bc15 16## Neither 1.o nor 2.o is loaded.17# RUN: %lld %t/main.o -o %t/out --start-lib %t/1.o %t/2.o --end-lib -why_load | count 018# RUN: %lld %t/main.o -o %t/out --start-lib -filelist %t/filelist --end-lib -why_load | count 019# RUN: llvm-readobj -s %t/out | FileCheck %s20# CHECK-NOT: Name: _foo21# CHECK-NOT: Name: _bar22 23## _bar loads 2.o. The last --end-lib can be omitted.24# RUN: %lld %t/main.o -o %t/out -u _bar --start-lib %t/1.o %t/2.o -t -why_load | FileCheck %s --check-prefix=CHECK2WHY25# RUN: %lld %t/main.o -o %t/out -u _bar --start-lib -filelist %t/filelist -t -why_load | FileCheck %s --check-prefix=CHECK2WHY26# RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=CHECK2 %s27# CHECK2WHY: {{.*}}main.o28# CHECK2WHY-NEXT: {{.*}}2.o29# CHECK2WHY-NEXT: _bar forced load of {{.*}}2.o30# CHECK2WHY-EMPTY:31# CHECK2-NOT: Name: _foo32# CHECK2: Name: _bar33# CHECK2-NOT: Name: _foo34 35## _foo loads 1.o. 1.o loads 2.o.36# RUN: %lld %t/main.o -o %t/out -u _foo --start-lib %t/1.o %t/2.o -why_load | FileCheck %s --check-prefix=CHECK3WHY37# RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=CHECK3 %s38# RUN: %lld %t/main.o -o %t/out -u _foo --start-lib %t/2.o --end-lib --start-lib %t/1.o -why_load | FileCheck %s --check-prefix=CHECK3WHY39# RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=CHECK3 %s40# CHECK3WHY: _foo forced load of {{.*}}1.o41# CHECK3WHY-NEXT: _bar forced load of {{.*}}2.o42# CHECK3WHY-EMPTY:43# CHECK3-DAG: Name: _foo44# CHECK3-DAG: Name: _bar45 46## Don't treat undefined _bar in 1.o as a lazy definition.47# RUN: not %lld %t/main.o -u _bar --start-lib %t/1.o 2>&1 | FileCheck %s --check-prefix=CHECK448# CHECK4: error: undefined symbol: _bar49 50# RUN: %lld %t/main.o -o %t/out -u _common --start-lib %t/common.o51# RUN: llvm-readobj -s %t/out | FileCheck %s --check-prefix=COMMON152# COMMON1: Name: _common53 54# RUN: %lld %t/main.o -o %t/out --start-lib %t/common.o55# RUN: llvm-readobj -s %t/out | FileCheck %s --check-prefix=COMMON256# COMMON2-NOT: Name: _common57 58## Neither 1.bc nor 2.bc is loaded.59# RUN: %lld %t/main.o -o %t/out --start-lib %t/1.bc %t/2.bc -why_load | count 060# RUN: llvm-readobj -s %t/out | FileCheck %s --check-prefix=BITCODE61# BITCODE-NOT: Name: _foo62# BITCODE-NOT: Name: _bar63 64## _bar loads 2.bc.65# RUN: %lld %t/main.o -o %t/out -u _bar --start-lib %t/1.bc %t/2.bc -why_load | FileCheck %s --check-prefix=BITCODE2WHY66# RUN: llvm-readobj -s %t/out | FileCheck %s --check-prefix=BITCODE267# BITCODE2WHY: _bar forced load of {{.*}}2.bc68# BITCODE2WHY-EMPTY:69# BITCODE2-NOT: Name: _foo70# BITCODE2: Name: _bar71# BITCODE2-NOT: Name: _foo72 73## calls-foo.o loads 1.bc. 1.bc loads 2.bc.74# RUN: %lld %t/calls-foo.o -o %t/out --start-lib %t/1.bc %t/2.bc -why_load | FileCheck %s --check-prefix=BITCODE3WHY75# RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=BITCODE3 %s76# RUN: %lld %t/calls-foo.o -o %t/out --start-lib %t/2.bc --end-lib --start-lib %t/1.bc -why_load | FileCheck %s --check-prefix=BITCODE3WHY77# RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=BITCODE3 %s78# BITCODE3WHY: _foo forced load of {{.*}}1.bc79# BITCODE3WHY-NEXT: _bar forced load of {{.*}}2.bc80# BITCODE3WHY-EMPTY:81# BITCODE3-DAG: Name: _foo82 83# RUN: not %lld %t/main.o --start-lib --start-lib 2>&1 | FileCheck -check-prefix=NESTED-LIB %s84# NESTED-LIB: error: nested --start-lib85 86# RUN: not %lld --end-lib 2>&1 | FileCheck %s --check-prefix=STRAY87# STRAY: error: stray --end-lib88 89# RUN: %lld -dylib --start-lib %t/1.bc %t/2.o --end-lib -all_load -o %t/out90# RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=ALL-LOAD %s91# ALL-LOAD-DAG: _foo92# ALL-LOAD-DAG: _bar93 94#--- main.s95.globl _main96_main:97 98#--- calls-foo.s99.globl _main100_main:101 call _foo102 103#--- 1.s104.globl _foo105_foo:106 call _bar107 108#--- 2.s109.globl _bar110_bar:111 ret112 113#--- common.s114.comm _common, 1115 116#--- 1.ll117target triple = "x86_64-apple-macosx10.15.0"118target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"119 120define void @foo() {121 tail call void () @bar()122 ret void123}124 125declare void @bar()126 127#--- 2.ll128target triple = "x86_64-apple-macosx10.15.0"129target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"130 131define void @bar() {132 ret void133}134