llvm-project
70 строк · 2.6 Кб
1# REQUIRES: x86
2# RUN: rm -rf %t; split-file %s %t
3
4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %t/live.s -o %t/live.o
5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %t/dead.s -o %t/dead.o
6
7# RUN: not %lld -undefined bogus -o /dev/null %t/live.o 2>&1 | \
8# RUN: FileCheck %s -check-prefix=UNKNOWN
9# RUN: not %lld -undefined error -o /dev/null %t/live.o 2>&1 | \
10# RUN: FileCheck %s -check-prefix=ERROR
11
12# RUN: not %lld -undefined warning -o /dev/null %t/live.o 2>&1 | \
13# RUN: FileCheck %s -check-prefix=INVAL-WARNING
14# RUN: not %lld -undefined suppress -o /dev/null %t/live.o 2>&1 | \
15# RUN: FileCheck %s -check-prefix=INVAL-SUPPRESS
16# RUN: %lld -undefined dynamic_lookup -lSystem -o %t/live.out %t/live.o 2>&1 | count 0
17# RUN: llvm-objdump --macho --lazy-bind %t/live.out \
18# RUN: | FileCheck --check-prefix=BIND %s
19
20# RUN: %no-fatal-warnings-lld -lSystem -flat_namespace -undefined warning \
21# RUN: -o %t/live.out %t/live.o 2>&1 | \
22# RUN: FileCheck %s -check-prefix=WARNING
23# RUN: llvm-objdump --macho --lazy-bind %t/live.out \
24# RUN: | FileCheck --check-prefix=BIND %s
25# RUN: %lld -flat_namespace -lSystem -undefined suppress -o %t/live.out %t/live.o \
26# RUN: 2>&1 | count 0
27# RUN: llvm-objdump --macho --lazy-bind %t/live.out \
28# RUN: | FileCheck --check-prefix=BIND %s
29# RUN: %lld -flat_namespace -lSystem -undefined dynamic_lookup -o \
30# RUN: %t/live.out %t/live.o 2>&1 | count 0
31# RUN: llvm-objdump --macho --lazy-bind %t/live.out \
32# RUN: | FileCheck --check-prefix=BIND %s
33
34## Undefined symbols in dead code should not raise an error iff
35## -dead_strip is enabled.
36# RUN: not %lld -dylib -undefined error -o /dev/null %t/dead.o 2>&1 \
37# RUN: | FileCheck --check-prefix=ERROR %s
38# RUN: not %lld -dylib -dead_strip -undefined error -o /dev/null %t/live.o 2>&1\
39# RUN: | FileCheck --check-prefix=ERROR %s
40# RUN: %lld -dylib -dead_strip -undefined error -o /dev/null %t/dead.o
41
42# ERROR: error: undefined symbol: _bar
43# ERROR-NEXT: >>> referenced by
44
45# INVAL-WARNING: error: '-undefined warning' only valid with '-flat_namespace'
46# INVAL-WARNING-NOT: error: undefined symbol: _bar
47
48# INVAL-SUPPRESS: error: '-undefined suppress' only valid with '-flat_namespace'
49# INVAL-SUPPRESS-NOT: error: undefined symbol: _bar
50
51# WARNING: warning: undefined symbol: _bar
52# WARNING-NEXT: >>> referenced by
53
54# UNKNOWN: unknown -undefined TREATMENT 'bogus'
55# UNKNOWN-NEXT: error: undefined symbol: _bar
56# UNKNOWN-NEXT: >>> referenced by
57
58# BIND: Lazy bind table:
59# BIND: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} flat-namespace _bar
60
61#--- live.s
62.globl _main
63_main:
64callq _bar
65ret
66
67#--- dead.s
68_dead:
69callq _bar
70ret
71