xref: /llvm-project/lld/test/MachO/function-starts.s (revision 0ab09a9009b6e65b4ed5b982eb4291244857bc11)
1# REQUIRES: x86
2
3# RUN: rm -rf %t; split-file %s %t
4
5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/basic.s -o %t/basic.o
6# RUN: %lld -lSystem %t/basic.o -o %t/basic
7# RUN: llvm-objdump --syms %t/basic > %t/objdump
8# RUN: llvm-objdump --macho --function-starts %t/basic >> %t/objdump
9# RUN: FileCheck %s --check-prefix=BASIC < %t/objdump
10
11# BASIC-LABEL: SYMBOL TABLE:
12# BASIC-NEXT:  [[#%x,MAIN:]] g F __TEXT,__text _main
13# BASIC-NEXT:  [[#%x,F1:]] g F __TEXT,__text _f1
14# BASIC-NEXT:  [[#%x,F2:]] g F __TEXT,__text _f2
15# BASIC-LABEL: basic:
16# BASIC:       [[#F1]]
17# BASIC:       [[#F2]]
18# BASIC:       [[#MAIN]]
19
20# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/alias.s -o %t/alias.o
21# RUN: %lld -lSystem %t/alias.o -o %t/alias
22# RUN: llvm-objdump --syms  %t/alias > %t/objdump
23# RUN: llvm-objdump --macho --function-starts %t/alias >> %t/objdump
24# RUN: FileCheck %s --check-prefix=ALIAS < %t/objdump
25
26# ALIAS-LABEL: SYMBOL TABLE:
27# ALIAS-NEXT:  [[#%x,F2:]] l F __TEXT,__text _f2
28# ALIAS-NEXT:  [[#%x,MAIN:]] g F __TEXT,__text _main
29# ALIAS-NEXT:  [[#%x,F1:]] g F __TEXT,__text _f1
30# ALIAS-LABEL: alias:
31# ALIAS:       [[#F1]]
32# ALIAS:       [[#MAIN]]
33
34# RUN: %lld %t/basic.o -no_function_starts -o %t/basic-no-function-starts
35# RUN: llvm-objdump --macho --function-starts %t/basic-no-function-starts | FileCheck %s --check-prefix=NO-FUNCTION-STARTS
36# NO-FUNCTION-STARTS: basic-no-function-starts:
37# NO-FUNCTION-STARTS-EMPTY:
38
39# RUN: %lld -lSystem %t/basic.o -no_function_starts -function_starts -o %t/basic-explicit
40# RUN: llvm-objdump --syms %t/basic > %t/objdump
41# RUN: llvm-objdump --macho --function-starts %t/basic >> %t/objdump
42# RUN: FileCheck %s --check-prefix=BASIC < %t/objdump
43
44# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/local.s -o %t/local.o
45# RUN: %lld -lSystem %t/local.o -o %t/local
46# RUN: llvm-objdump --syms %t/local > %t/objdump
47# RUN: llvm-objdump --macho --function-starts %t/local >> %t/objdump
48# RUN: FileCheck %s --check-prefix=LOCAL < %t/objdump
49
50# LOCAL-LABEL: SYMBOL TABLE:
51# LOCAL-NEXT:  [[#%x,F1:]] l F __TEXT,__text +[Foo bar]
52# LOCAL-NEXT:  [[#%x,F2:]] l F __TEXT,__text _foo
53# LOCAL:       [[#%x,F3:]] g F __TEXT,__text _main
54# LOCAL-LABEL: local:
55# LOCAL:       [[#F1]]
56# LOCAL:       [[#F2]]
57# LOCAL:       [[#F3]]
58
59#--- basic.s
60.section  __TEXT,__text,regular,pure_instructions
61.globl  _f1
62.globl  _f2
63.globl  _main
64_f1:
65  retq
66_f2:
67  retq
68_main:
69  retq
70
71#--- alias.s
72.section  __TEXT,__text,regular,pure_instructions
73.globl  _f1
74.equiv  _f2, _f1
75.globl  _main
76_f1:
77  retq
78_main:
79  retq
80
81#--- local.s
82.section __TEXT,__text
83"+[Foo bar]":
84  retq
85
86_foo:
87  retq
88
89.globl _main
90_main:
91  retq
92