@@ -8,8 +8,6 @@ use rustc_middle::mir::InlineAsmOperand;
8
8
use rustc_middle:: ty;
9
9
use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf } ;
10
10
use rustc_middle:: ty:: { Instance , TyCtxt } ;
11
-
12
- use rustc_span:: sym;
13
11
use rustc_target:: asm:: InlineAsmArch ;
14
12
15
13
impl < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
@@ -133,12 +131,9 @@ fn prefix_and_suffix<'tcx>(
133
131
134
132
let asm_name = format ! ( "{}{}" , if mangle { "_" } else { "" } , tcx. symbol_name( instance) . name) ;
135
133
136
- let opt_section = tcx
137
- . get_attr ( instance. def . def_id ( ) , sym:: link_section)
138
- . and_then ( |attr| attr. value_str ( ) )
139
- . map ( |attr| attr. as_str ( ) . to_string ( ) ) ;
140
-
141
134
let attrs = tcx. codegen_fn_attrs ( instance. def_id ( ) ) ;
135
+ let link_section = attrs. link_section . map ( |symbol| symbol. as_str ( ) . to_string ( ) ) ;
136
+
142
137
let ( arch_prefix, arch_suffix) = if is_arm {
143
138
(
144
139
match attrs. instruction_set {
@@ -162,7 +157,7 @@ fn prefix_and_suffix<'tcx>(
162
157
let mut end = String :: new ( ) ;
163
158
match AsmBinaryFormat :: from_target ( & tcx. sess . target ) {
164
159
AsmBinaryFormat :: Elf => {
165
- let section = opt_section . unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
160
+ let section = link_section . unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
166
161
167
162
let progbits = match is_arm {
168
163
true => "%progbits" ,
@@ -199,7 +194,7 @@ fn prefix_and_suffix<'tcx>(
199
194
}
200
195
}
201
196
AsmBinaryFormat :: Macho => {
202
- let section = opt_section . unwrap_or ( "__TEXT,__text" . to_string ( ) ) ;
197
+ let section = link_section . unwrap_or ( "__TEXT,__text" . to_string ( ) ) ;
203
198
writeln ! ( begin, ".pushsection {},regular,pure_instructions" , section) . unwrap ( ) ;
204
199
writeln ! ( begin, ".balign 4" ) . unwrap ( ) ;
205
200
if let Some ( linkage) = linkage_directive ( item_data. linkage ) {
@@ -220,7 +215,7 @@ fn prefix_and_suffix<'tcx>(
220
215
}
221
216
}
222
217
AsmBinaryFormat :: Coff => {
223
- let section = opt_section . unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
218
+ let section = link_section . unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
224
219
writeln ! ( begin, ".pushsection {},\" xr\" " , section) . unwrap ( ) ;
225
220
writeln ! ( begin, ".balign 4" ) . unwrap ( ) ;
226
221
if let Some ( linkage) = linkage_directive ( item_data. linkage ) {
0 commit comments