llvm-project
66 строк · 1.8 Кб
1# REQUIRES: x86
2# RUN: rm -rf %t; split-file %s %t
3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/2.s -o %t/2.o
4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/3.s -o %t/3.o
5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/4.s -o %t/4.o
6# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o
7
8# RUN: llvm-ar rcs %t/test.a %t/2.o %t/3.o %t/4.o
9# RUN: %lld %t/main.o %t/test.a -o %t/test.out
10
11## TODO: Run llvm-nm -p to validate symbol order
12# RUN: llvm-nm %t/test.out | FileCheck %s
13# CHECK: T _bar
14# CHECK: T _boo
15# CHECK: T _main
16
17## Linking with the archive first in the command line shouldn't change anything
18# RUN: %lld %t/test.a %t/main.o -o %t/test.out
19# RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST
20# ARCHIVE-FIRST: T _bar
21# ARCHIVE-FIRST: T _boo
22# ARCHIVE-FIRST: T _main
23
24# RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix VISIBLE
25# VISIBLE-NOT: T _undefined
26# VISIBLE-NOT: T _unused
27
28# RUN: %lld %t/test.a %t/main.o -o %t/all-load -noall_load -all_load
29# RUN: llvm-nm %t/all-load | FileCheck %s --check-prefix ALL-LOAD
30# ALL-LOAD: T _bar
31# ALL-LOAD: T _boo
32# ALL-LOAD: T _main
33# ALL-LOAD: T _unused
34
35# RUN: %lld %t/test.a %t/main.o -o %t/no-all-load -all_load -noall_load
36# RUN: llvm-nm %t/no-all-load | FileCheck %s --check-prefix NO-ALL-LOAD
37# RUN: %lld %t/test.a %t/main.o -o %t/no-all-load-only -noall_load
38# RUN: llvm-nm %t/no-all-load-only | FileCheck %s --check-prefix NO-ALL-LOAD
39# NO-ALL-LOAD-NOT: T _unused
40
41## Multiple archives defining the same symbols aren't an issue, due to lazy
42## loading
43# RUN: cp %t/test.a %t/test2.a
44# RUN: %lld %t/test.a %t/test2.a %t/main.o -o /dev/null
45
46#--- 2.s
47.globl _boo
48_boo:
49ret
50
51#--- 3.s
52.globl _bar
53_bar:
54ret
55
56#--- 4.s
57.globl _undefined, _unused
58_unused:
59ret
60
61#--- main.s
62.globl _main
63_main:
64callq _boo
65callq _bar
66ret
67