@@ -8,8 +8,6 @@ use rustc_middle::mir::InlineAsmOperand;
88use rustc_middle:: ty;
99use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf } ;
1010use rustc_middle:: ty:: { Instance , TyCtxt } ;
11-
12- use rustc_span:: sym;
1311use rustc_target:: asm:: InlineAsmArch ;
1412
1513impl < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
@@ -133,12 +131,9 @@ fn prefix_and_suffix<'tcx>(
133131
134132 let asm_name = format ! ( "{}{}" , if mangle { "_" } else { "" } , tcx. symbol_name( instance) . name) ;
135133
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-
141134 let attrs = tcx. codegen_fn_attrs ( instance. def_id ( ) ) ;
135+ let link_section = attrs. link_section . map ( |symbol| symbol. as_str ( ) . to_string ( ) ) ;
136+
142137 let ( arch_prefix, arch_suffix) = if is_arm {
143138 (
144139 match attrs. instruction_set {
@@ -162,7 +157,7 @@ fn prefix_and_suffix<'tcx>(
162157 let mut end = String :: new ( ) ;
163158 match AsmBinaryFormat :: from_target ( & tcx. sess . target ) {
164159 AsmBinaryFormat :: Elf => {
165- let section = opt_section . unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
160+ let section = link_section . unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
166161
167162 let progbits = match is_arm {
168163 true => "%progbits" ,
@@ -199,7 +194,7 @@ fn prefix_and_suffix<'tcx>(
199194 }
200195 }
201196 AsmBinaryFormat :: Macho => {
202- let section = opt_section . unwrap_or ( "__TEXT,__text" . to_string ( ) ) ;
197+ let section = link_section . unwrap_or ( "__TEXT,__text" . to_string ( ) ) ;
203198 writeln ! ( begin, ".pushsection {},regular,pure_instructions" , section) . unwrap ( ) ;
204199 writeln ! ( begin, ".balign 4" ) . unwrap ( ) ;
205200 if let Some ( linkage) = linkage_directive ( item_data. linkage ) {
@@ -220,7 +215,7 @@ fn prefix_and_suffix<'tcx>(
220215 }
221216 }
222217 AsmBinaryFormat :: Coff => {
223- let section = opt_section . unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
218+ let section = link_section . unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
224219 writeln ! ( begin, ".pushsection {},\" xr\" " , section) . unwrap ( ) ;
225220 writeln ! ( begin, ".balign 4" ) . unwrap ( ) ;
226221 if let Some ( linkage) = linkage_directive ( item_data. linkage ) {
0 commit comments