12b920ae7SKellie Medlin# REQUIRES: x86 2a817594dSJez Ng# RUN: rm -rf %t; split-file %s %t 3a817594dSJez Ng# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/2.s -o %t/2.o 4a817594dSJez Ng# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/3.s -o %t/3.o 5a817594dSJez Ng# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/4.s -o %t/4.o 6a817594dSJez Ng# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o 72b920ae7SKellie Medlin 82b920ae7SKellie Medlin# RUN: llvm-ar rcs %t/test.a %t/2.o %t/3.o %t/4.o 9643ec67aSJez Ng# RUN: %lld %t/main.o %t/test.a -o %t/test.out 102b920ae7SKellie Medlin 112b920ae7SKellie Medlin## TODO: Run llvm-nm -p to validate symbol order 122b920ae7SKellie Medlin# RUN: llvm-nm %t/test.out | FileCheck %s 132b920ae7SKellie Medlin# CHECK: T _bar 142b920ae7SKellie Medlin# CHECK: T _boo 152b920ae7SKellie Medlin# CHECK: T _main 162b920ae7SKellie Medlin 172b920ae7SKellie Medlin## Linking with the archive first in the command line shouldn't change anything 18643ec67aSJez Ng# RUN: %lld %t/test.a %t/main.o -o %t/test.out 192b920ae7SKellie Medlin# RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST 202b920ae7SKellie Medlin# ARCHIVE-FIRST: T _bar 212b920ae7SKellie Medlin# ARCHIVE-FIRST: T _boo 222b920ae7SKellie Medlin# ARCHIVE-FIRST: T _main 232b920ae7SKellie Medlin 242b920ae7SKellie Medlin# RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix VISIBLE 252b920ae7SKellie Medlin# VISIBLE-NOT: T _undefined 262b920ae7SKellie Medlin# VISIBLE-NOT: T _unused 272b920ae7SKellie Medlin 28*67090e34SKeith Smiley# RUN: %lld %t/test.a %t/main.o -o %t/all-load -noall_load -all_load 2962b39b3aSJez Ng# RUN: llvm-nm %t/all-load | FileCheck %s --check-prefix ALL-LOAD 3062b39b3aSJez Ng# ALL-LOAD: T _bar 3162b39b3aSJez Ng# ALL-LOAD: T _boo 3262b39b3aSJez Ng# ALL-LOAD: T _main 3362b39b3aSJez Ng# ALL-LOAD: T _unused 3462b39b3aSJez Ng 35*67090e34SKeith Smiley# RUN: %lld %t/test.a %t/main.o -o %t/no-all-load -all_load -noall_load 36*67090e34SKeith Smiley# RUN: llvm-nm %t/no-all-load | FileCheck %s --check-prefix NO-ALL-LOAD 37*67090e34SKeith Smiley# RUN: %lld %t/test.a %t/main.o -o %t/no-all-load-only -noall_load 38*67090e34SKeith Smiley# RUN: llvm-nm %t/no-all-load-only | FileCheck %s --check-prefix NO-ALL-LOAD 39*67090e34SKeith Smiley# NO-ALL-LOAD-NOT: T _unused 40*67090e34SKeith Smiley 414507f641SJez Ng## Multiple archives defining the same symbols aren't an issue, due to lazy 424507f641SJez Ng## loading 434507f641SJez Ng# RUN: cp %t/test.a %t/test2.a 444507f641SJez Ng# RUN: %lld %t/test.a %t/test2.a %t/main.o -o /dev/null 454507f641SJez Ng 46a817594dSJez Ng#--- 2.s 47a817594dSJez Ng.globl _boo 48a817594dSJez Ng_boo: 49a817594dSJez Ng ret 50a817594dSJez Ng 51a817594dSJez Ng#--- 3.s 52a817594dSJez Ng.globl _bar 53a817594dSJez Ng_bar: 54a817594dSJez Ng ret 55a817594dSJez Ng 56a817594dSJez Ng#--- 4.s 57a817594dSJez Ng.globl _undefined, _unused 58a817594dSJez Ng_unused: 59a817594dSJez Ng ret 60a817594dSJez Ng 61a817594dSJez Ng#--- main.s 62a817594dSJez Ng.globl _main 632b920ae7SKellie Medlin_main: 642b920ae7SKellie Medlin callq _boo 652b920ae7SKellie Medlin callq _bar 662b920ae7SKellie Medlin ret 67