llvm-project
55 строк · 2.5 Кб
1# REQUIRES: x86
2# RUN: rm -rf %t && mkdir -p %t
3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
4# RUN: %lld -o %t/executable %t/test.o
5# RUN: %lld -execute -o %t/explicit-executable %t/test.o
6# RUN: %lld -bundle -o %t/bundle %t/test.o
7# RUN: %lld -dylib -o %t/dylib %t/test.o
8
9## These load commands should be in every final output binary.
10# COMMON-DAG: cmd LC_DYLD_INFO_ONLY
11# COMMON-DAG: cmd LC_SYMTAB
12# COMMON-DAG: cmd LC_DYSYMTAB
13# COMMON-DAG: cmd LC_UUID
14
15## Check for the presence of load commands that are essential for a working
16## executable. Also check that it has the right filetype.
17# RUN: llvm-objdump --macho --all-headers %t/executable | FileCheck %s --check-prefix=COMMON
18# RUN: llvm-objdump --macho --all-headers %t/executable | FileCheck %s --check-prefix=EXEC
19# RUN: llvm-objdump --macho --all-headers %t/explicit-executable | FileCheck %s --check-prefix=COMMON
20# RUN: llvm-objdump --macho --all-headers %t/explicit-executable | FileCheck %s --check-prefix=EXEC
21# EXEC: magic cputype cpusubtype caps filetype
22# EXEC-NEXT: MH_MAGIC_64 X86_64 ALL {{.*}} EXECUTE
23# EXEC-DAG: cmd LC_MAIN
24# EXEC-DAG: cmd LC_LOAD_DYLINKER
25
26## Check for the absence of load commands that should not be in an executable.
27# RUN: llvm-objdump --macho --all-headers %t/executable | FileCheck %s --check-prefix=NEXEC
28# NEXEC-NOT: cmd: LC_ID_DYLIB
29
30## Check for the presence / absence of load commands for the dylib.
31# RUN: llvm-objdump --macho --all-headers %t/dylib | FileCheck %s --check-prefix=COMMON
32# RUN: llvm-objdump --macho --all-headers %t/dylib | FileCheck %s --check-prefix=DYLIB
33# DYLIB: magic cputype cpusubtype caps filetype
34# DYLIB-NEXT: MH_MAGIC_64 X86_64 ALL {{.*}} DYLIB
35# DYLIB: cmd LC_ID_DYLIB
36
37# RUN: llvm-objdump --macho --all-headers %t/bundle | FileCheck %s --check-prefix=NDYLIB
38# NDYLIB-NOT: cmd: LC_MAIN
39# NDYLIB-NOT: cmd: LC_LOAD_DYLINKER
40
41## Check for the presence / absence of load commands for the bundle.
42# RUN: llvm-objdump --macho --all-headers %t/bundle | FileCheck %s --check-prefix=COMMON
43# RUN: llvm-objdump --macho --all-headers %t/bundle | FileCheck %s --check-prefix=BUNDLE
44# BUNDLE: magic cputype cpusubtype caps filetype
45# BUNDLE-NEXT: MH_MAGIC_64 X86_64 ALL {{.*}} BUNDLE
46
47# RUN: llvm-objdump --macho --all-headers %t/bundle | FileCheck %s --check-prefix=NBUNDLE
48# NBUNDLE-NOT: cmd: LC_MAIN
49# NBUNDLE-NOT: cmd: LC_LOAD_DYLINKER
50
51.text
52.global _main
53_main:
54mov $0, %rax
55ret
56