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
63 # FLAGS-NEXT: segname __DATA_CONST
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
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 ({{.*}})
91 .section __DATA,__auth_got
92 .global __DATA__auth_got
96 .section __DATA,__auth_ptr
97 .global __DATA__auth_ptr
101 .section __DATA,__nl_symbol_ptr
102 .global __DATA__nl_symbol_ptr
103 __DATA__nl_symbol_ptr
:
106 .section __DATA,__const
107 .global __DATA__const
111 .section __DATA,__cfstring
112 .global __DATA__cfstring
116 .section __DATA,__mod_init_func,mod_init_funcs
117 .global __DATA__mod_init_func
118 __DATA__mod_init_func
:
121 .section __DATA,__mod_term_func,mod_term_funcs
122 .global __DATA__mod_term_func
123 __DATA__mod_term_func
:
126 .section __DATA,__objc_classlist
127 .global __DATA__objc_classlist
128 __DATA__objc_classlist
:
131 .section __DATA,__objc_nlclslist
132 .global __DATA__objc_nlclslist
133 __DATA__objc_nlclslist
:
136 .section __DATA,__objc_catlist
137 .global __DATA__objc_catlist
138 __DATA__objc_catlist
:
141 .section __DATA,__objc_nlcatlist
142 .global __DATA__objc_nlcatlist
143 __DATA__objc_nlcatlist
:
146 .section __DATA,__objc_protolist
147 .global __DATA__objc_protolist
148 __DATA__objc_protolist
:
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:
160 .section __IMPORT,__pointers,non_lazy_symbol_pointers
161 .global __IMPORT__pointers
165 .section __TEXT,__StaticInit
166 .section __TEXT,__StaticInit
167 .global __TEXT__StaticInit
175 mov ___nan@GOTPCREL
(%rip
), %rax
## ensure the __got section is created
176 callq ___isnan
## ensure the __la_symbol_ptr section is created