Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / builtin-rename.s
blob22b2479c0204810acc5b535a07f5c7295f345300
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin \
5 # RUN: %t/main.s -o %t/main.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin \
7 # RUN: %t/renames.s -o %t/renames.o
9 ## Check that section and segment renames happen as expected
10 # RUN: %lld -o %t/ydata %t/main.o %t/renames.o -lSystem
11 # RUN: %lld -no_data_const -o %t/ndata %t/main.o %t/renames.o -lSystem
12 # RUN: %lld -no_pie -o %t/nopie %t/main.o %t/renames.o -lSystem
13 # RUN: %lld -platform_version macos 10.14 11.0 -o %t/old %t/main.o %t/renames.o -lSystem
15 # RUN: llvm-objdump --syms %t/ydata | \
16 # RUN: FileCheck %s --check-prefixes=CHECK,YDATA
17 # RUN: llvm-objdump --syms %t/ndata | \
18 # RUN: FileCheck %s --check-prefixes=CHECK,NDATA
19 # RUN: llvm-objdump --syms %t/nopie | \
20 # RUN: FileCheck %s --check-prefixes=CHECK,NDATA
21 # RUN: llvm-objdump --syms %t/old | \
22 # RUN: FileCheck %s --check-prefixes=CHECK,NDATA
24 # CHECK-LABEL: {{^}}SYMBOL TABLE:
26 # CHECK-DAG: __TEXT,__text __TEXT__StaticInit
28 # NDATA-DAG: __DATA,__auth_got __DATA__auth_got
29 # NDATA-DAG: __DATA,__auth_ptr __DATA__auth_ptr
30 # NDATA-DAG: __DATA,__nl_symbol_ptr __DATA__nl_symbol_ptr
31 # NDATA-DAG: __DATA,__const __DATA__const
32 # NDATA-DAG: __DATA,__cfstring __DATA__cfstring
33 # NDATA-DAG: __DATA,__mod_init_func __DATA__mod_init_func
34 # NDATA-DAG: __DATA,__mod_term_func __DATA__mod_term_func
35 # NDATA-DAG: __DATA,__objc_classlist __DATA__objc_classlist
36 # NDATA-DAG: __DATA,__objc_nlclslist __DATA__objc_nlclslist
37 # NDATA-DAG: __DATA,__objc_catlist __DATA__objc_catlist
38 # NDATA-DAG: __DATA,__objc_nlcatlist __DATA__objc_nlcatlist
39 # NDATA-DAG: __DATA,__objc_protolist __DATA__objc_protolist
40 # NDATA-DAG: __DATA,__nl_symbol_ptr __IMPORT__pointers
42 # YDATA-DAG: __DATA_CONST,__auth_got __DATA__auth_got
43 # YDATA-DAG: __DATA_CONST,__auth_ptr __DATA__auth_ptr
44 # YDATA-DAG: __DATA_CONST,__nl_symbol_ptr __DATA__nl_symbol_ptr
45 # YDATA-DAG: __DATA_CONST,__const __DATA__const
46 # YDATA-DAG: __DATA_CONST,__cfstring __DATA__cfstring
47 # YDATA-DAG: __DATA_CONST,__mod_init_func __DATA__mod_init_func
48 # YDATA-DAG: __DATA_CONST,__mod_term_func __DATA__mod_term_func
49 # YDATA-DAG: __DATA_CONST,__objc_classlist __DATA__objc_classlist
50 # YDATA-DAG: __DATA_CONST,__objc_nlclslist __DATA__objc_nlclslist
51 # YDATA-DAG: __DATA_CONST,__objc_catlist __DATA__objc_catlist
52 # YDATA-DAG: __DATA_CONST,__objc_nlcatlist __DATA__objc_nlcatlist
53 # YDATA-DAG: __DATA_CONST,__objc_protolist __DATA__objc_protolist
54 # YDATA-DAG: __DATA_CONST,__nl_symbol_ptr __IMPORT__pointers
56 ## Check that the SG_READ_ONLY flag is set on __DATA_CONST.
57 # RUN: llvm-otool -v -l %t/ydata | \
58 # RUN: FileCheck %s --check-prefix=FLAGS
60 # FLAGS-LABEL: Load command 2
61 # FLAGS-NEXT: cmd LC_SEGMENT_64
62 # FLAGS-NEXT: cmdsize
63 # FLAGS-NEXT: segname __DATA_CONST
64 # FLAGS-NEXT: vmaddr
65 # FLAGS-NEXT: vmsize
66 # FLAGS-NEXT: fileoff
67 # FLAGS-NEXT: filesize
68 # FLAGS-NEXT: maxprot rw-
69 # FLAGS-NEXT: initprot rw-
70 # FLAGS-NEXT: nsects 13
71 # FLAGS-NEXT: flags SG_READ_ONLY
73 ## LLD doesn't support defining symbols in synthetic sections, so we test them
74 ## via this slightly more awkward route.
75 # RUN: llvm-readobj --section-headers %t/ydata | \
76 # RUN: FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA_CONST
77 # RUN: llvm-readobj --section-headers %t/ndata | \
78 # RUN: FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA
79 # RUN: llvm-readobj --section-headers %t/nopie | \
80 # RUN: FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA
81 # RUN: llvm-readobj --section-headers %t/old | \
82 # RUN: FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA
84 # SYNTH: Name: __got
85 # SYNTH-NEXT: Segment: [[SEGNAME]] ({{.*}})
86 ## Note that __la_symbol_ptr always remains in the non-const data segment.
87 # SYNTH: Name: __la_symbol_ptr
88 # SYNTH-NEXT: Segment: __DATA ({{.*}})
90 #--- renames.s
91 .section __DATA,__auth_got
92 .global __DATA__auth_got
93 __DATA__auth_got:
94 .space 8
96 .section __DATA,__auth_ptr
97 .global __DATA__auth_ptr
98 __DATA__auth_ptr:
99 .space 8
101 .section __DATA,__nl_symbol_ptr
102 .global __DATA__nl_symbol_ptr
103 __DATA__nl_symbol_ptr:
104 .space 8
106 .section __DATA,__const
107 .global __DATA__const
108 __DATA__const:
109 .space 8
111 .section __DATA,__cfstring
112 .global __DATA__cfstring
113 __DATA__cfstring:
114 .space 8
116 .section __DATA,__mod_init_func,mod_init_funcs
117 .global __DATA__mod_init_func
118 __DATA__mod_init_func:
119 .space 8
121 .section __DATA,__mod_term_func,mod_term_funcs
122 .global __DATA__mod_term_func
123 __DATA__mod_term_func:
124 .space 8
126 .section __DATA,__objc_classlist
127 .global __DATA__objc_classlist
128 __DATA__objc_classlist:
129 .space 8
131 .section __DATA,__objc_nlclslist
132 .global __DATA__objc_nlclslist
133 __DATA__objc_nlclslist:
134 .space 8
136 .section __DATA,__objc_catlist
137 .global __DATA__objc_catlist
138 __DATA__objc_catlist:
139 .space 8
141 .section __DATA,__objc_nlcatlist
142 .global __DATA__objc_nlcatlist
143 __DATA__objc_nlcatlist:
144 .space 8
146 .section __DATA,__objc_protolist
147 .global __DATA__objc_protolist
148 __DATA__objc_protolist:
149 .space 8
151 ## __objc_imageinfo should get moved under __DATA_CONST as well, but symbols
152 ## within __objc_imageinfo get dropped during link, so we are cannot test this
153 ## case using the output of `llvm-objdump --syms`. TODO: rewrite test to use
154 ## `llvm-readobj --section-headers`, which will avoid this issue.
155 # .section __DATA,__objc_imageinfo
156 # .global __DATA__objc_imageinfo
157 # __DATA__objc_imageinfo:
158 # .space 8
160 .section __IMPORT,__pointers,non_lazy_symbol_pointers
161 .global __IMPORT__pointers
162 __IMPORT__pointers:
163 .space 8
165 .section __TEXT,__StaticInit
166 .section __TEXT,__StaticInit
167 .global __TEXT__StaticInit
168 __TEXT__StaticInit:
169 .space 8
171 #--- main.s
172 .text
173 .global _main
174 _main:
175 mov ___nan@GOTPCREL(%rip), %rax ## ensure the __got section is created
176 callq ___isnan ## ensure the __la_symbol_ptr section is created