Improve code generating inline ASM
This commit is contained in:
parent
5484c131a5
commit
f150ab3277
17
src/asm.rs
17
src/asm.rs
@ -706,7 +706,10 @@ fn codegen_global_asm(&self, template: &[InlineAsmTemplatePiece], operands: &[Gl
|
||||
&& options.contains(InlineAsmOptions::ATT_SYNTAX);
|
||||
|
||||
// Build the template string
|
||||
let mut template_str = String::new();
|
||||
let mut template_str = ".pushsection .text\n".to_owned();
|
||||
if att_dialect {
|
||||
template_str.push_str(".att_syntax\n");
|
||||
}
|
||||
for piece in template {
|
||||
match *piece {
|
||||
InlineAsmTemplatePiece::String(ref string) => {
|
||||
@ -754,15 +757,11 @@ fn codegen_global_asm(&self, template: &[InlineAsmTemplatePiece], operands: &[Gl
|
||||
}
|
||||
}
|
||||
|
||||
let template_str =
|
||||
if att_dialect {
|
||||
format!(".att_syntax\n\t{}\n\t.intel_syntax noprefix", template_str)
|
||||
}
|
||||
else {
|
||||
template_str
|
||||
};
|
||||
if att_dialect {
|
||||
template_str.push_str("\n\t.intel_syntax noprefix");
|
||||
}
|
||||
// NOTE: seems like gcc will put the asm in the wrong section, so set it to .text manually.
|
||||
let template_str = format!(".pushsection .text\n{}\n.popsection", template_str);
|
||||
template_str.push_str("\n.popsection");
|
||||
self.context.add_top_level_asm(None, &template_str);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user