File: builtin-rename.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (177 lines) | stat: -rw-r--r-- 5,810 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# REQUIRES: x86
# RUN: rm -rf %t; split-file %s %t

# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin \
# RUN:     %t/main.s -o %t/main.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin \
# RUN:     %t/renames.s -o %t/renames.o

## Check that section and segment renames happen as expected
# RUN: %lld                -o %t/ydata %t/main.o %t/renames.o -lSystem
# RUN: %lld -no_data_const -o %t/ndata %t/main.o %t/renames.o -lSystem
# RUN: %lld -no_pie        -o %t/nopie %t/main.o %t/renames.o -lSystem
# RUN: %lld -platform_version macos 10.14 11.0 -o %t/old %t/main.o %t/renames.o -lSystem

# RUN: llvm-objdump --syms %t/ydata | \
# RUN:     FileCheck %s --check-prefixes=CHECK,YDATA
# RUN: llvm-objdump --syms %t/ndata | \
# RUN:     FileCheck %s --check-prefixes=CHECK,NDATA
# RUN: llvm-objdump --syms %t/nopie | \
# RUN:     FileCheck %s --check-prefixes=CHECK,NDATA
# RUN: llvm-objdump --syms %t/old | \
# RUN:     FileCheck %s --check-prefixes=CHECK,NDATA

# CHECK-LABEL: {{^}}SYMBOL TABLE:

# CHECK-DAG: __TEXT,__text __TEXT__StaticInit

# NDATA-DAG: __DATA,__auth_got __DATA__auth_got
# NDATA-DAG: __DATA,__auth_ptr __DATA__auth_ptr
# NDATA-DAG: __DATA,__nl_symbol_ptr __DATA__nl_symbol_ptr
# NDATA-DAG: __DATA,__const __DATA__const
# NDATA-DAG: __DATA,__cfstring __DATA__cfstring
# NDATA-DAG: __DATA,__mod_init_func __DATA__mod_init_func
# NDATA-DAG: __DATA,__mod_term_func __DATA__mod_term_func
# NDATA-DAG: __DATA,__objc_classlist __DATA__objc_classlist
# NDATA-DAG: __DATA,__objc_nlclslist __DATA__objc_nlclslist
# NDATA-DAG: __DATA,__objc_catlist __DATA__objc_catlist
# NDATA-DAG: __DATA,__objc_nlcatlist __DATA__objc_nlcatlist
# NDATA-DAG: __DATA,__objc_protolist __DATA__objc_protolist
# NDATA-DAG: __DATA,__nl_symbol_ptr __IMPORT__pointers

# YDATA-DAG: __DATA_CONST,__auth_got __DATA__auth_got
# YDATA-DAG: __DATA_CONST,__auth_ptr __DATA__auth_ptr
# YDATA-DAG: __DATA_CONST,__nl_symbol_ptr __DATA__nl_symbol_ptr
# YDATA-DAG: __DATA_CONST,__const __DATA__const
# YDATA-DAG: __DATA_CONST,__cfstring __DATA__cfstring
# YDATA-DAG: __DATA_CONST,__mod_init_func __DATA__mod_init_func
# YDATA-DAG: __DATA_CONST,__mod_term_func __DATA__mod_term_func
# YDATA-DAG: __DATA_CONST,__objc_classlist __DATA__objc_classlist
# YDATA-DAG: __DATA_CONST,__objc_nlclslist __DATA__objc_nlclslist
# YDATA-DAG: __DATA_CONST,__objc_catlist __DATA__objc_catlist
# YDATA-DAG: __DATA_CONST,__objc_nlcatlist __DATA__objc_nlcatlist
# YDATA-DAG: __DATA_CONST,__objc_protolist __DATA__objc_protolist
# YDATA-DAG: __DATA_CONST,__nl_symbol_ptr __IMPORT__pointers

## Check that the SG_READ_ONLY flag is set on __DATA_CONST.
# RUN: llvm-otool -v -l %t/ydata | \
# RUN:     FileCheck %s --check-prefix=FLAGS

# FLAGS-LABEL: Load command 2
# FLAGS-NEXT:      cmd LC_SEGMENT_64
# FLAGS-NEXT:  cmdsize
# FLAGS-NEXT:  segname __DATA_CONST
# FLAGS-NEXT:   vmaddr
# FLAGS-NEXT:   vmsize
# FLAGS-NEXT:  fileoff
# FLAGS-NEXT: filesize
# FLAGS-NEXT:  maxprot rw-
# FLAGS-NEXT: initprot rw-
# FLAGS-NEXT:   nsects 13
# FLAGS-NEXT:    flags SG_READ_ONLY

## LLD doesn't support defining symbols in synthetic sections, so we test them
## via this slightly more awkward route.
# RUN: llvm-readobj --section-headers %t/ydata | \
# RUN:     FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA_CONST
# RUN: llvm-readobj --section-headers %t/ndata | \
# RUN:     FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA
# RUN: llvm-readobj --section-headers %t/nopie | \
# RUN:     FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA
# RUN: llvm-readobj --section-headers %t/old | \
# RUN:     FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA

# SYNTH:      Name: __got
# SYNTH-NEXT: Segment: [[SEGNAME]] ({{.*}})
## Note that __la_symbol_ptr always remains in the non-const data segment.
# SYNTH:      Name: __la_symbol_ptr
# SYNTH-NEXT: Segment: __DATA ({{.*}})

#--- renames.s
.section __DATA,__auth_got
.global __DATA__auth_got
__DATA__auth_got:
  .space 8

.section __DATA,__auth_ptr
.global __DATA__auth_ptr
__DATA__auth_ptr:
  .space 8

.section __DATA,__nl_symbol_ptr
.global __DATA__nl_symbol_ptr
__DATA__nl_symbol_ptr:
  .space 8

.section __DATA,__const
.global __DATA__const
__DATA__const:
  .space 8

.section __DATA,__cfstring
.global __DATA__cfstring
__DATA__cfstring:
  .space 8

.section __DATA,__mod_init_func,mod_init_funcs
.global __DATA__mod_init_func
__DATA__mod_init_func:
  .space 8

.section __DATA,__mod_term_func,mod_term_funcs
.global __DATA__mod_term_func
__DATA__mod_term_func:
  .space 8

.section __DATA,__objc_classlist
.global __DATA__objc_classlist
__DATA__objc_classlist:
  .space 8

.section __DATA,__objc_nlclslist
.global __DATA__objc_nlclslist
__DATA__objc_nlclslist:
  .space 8

.section __DATA,__objc_catlist
.global __DATA__objc_catlist
__DATA__objc_catlist:
  .space 8

.section __DATA,__objc_nlcatlist
.global __DATA__objc_nlcatlist
__DATA__objc_nlcatlist:
  .space 8

.section __DATA,__objc_protolist
.global __DATA__objc_protolist
__DATA__objc_protolist:
  .space 8

## __objc_imageinfo should get moved under __DATA_CONST as well, but symbols
## within __objc_imageinfo get dropped during link, so we are cannot test this
## case using the output of `llvm-objdump --syms`. TODO: rewrite test to use
## `llvm-readobj --section-headers`, which will avoid this issue.
# .section __DATA,__objc_imageinfo
# .global __DATA__objc_imageinfo
# __DATA__objc_imageinfo:
#   .space 8

.section __IMPORT,__pointers,non_lazy_symbol_pointers
.global __IMPORT__pointers
__IMPORT__pointers:
  .space 8

.section __TEXT,__StaticInit
.section __TEXT,__StaticInit
.global __TEXT__StaticInit
__TEXT__StaticInit:
  .space 8

#--- main.s
.text
.global _main
_main:
  mov ___nan@GOTPCREL(%rip), %rax ## ensure the __got section is created
  callq ___isnan ## ensure the __la_symbol_ptr section is created
  ret