Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,15 @@ fn codegen_global_asm_inner<'tcx>(
}

let symbol = tcx.symbol_name(instance);
let symbol_name = if tcx.sess.target.is_like_darwin {
format!("_{}", symbol.name)
} else {
symbol.name.to_owned()
};

// FIXME handle the case where the function was made private to the
// current codegen unit
global_asm.push_str(&escape_symbol_name(tcx, symbol.name, span));
global_asm.push_str(&escape_symbol_name(tcx, &symbol_name, span));
}
GlobalAsmOperandRef::SymStatic { def_id } => {
if cfg!(not(feature = "inline_asm_sym")) {
Expand All @@ -134,7 +140,13 @@ fn codegen_global_asm_inner<'tcx>(

let instance = Instance::mono(tcx, def_id);
let symbol = tcx.symbol_name(instance);
global_asm.push_str(&escape_symbol_name(tcx, symbol.name, span));
let symbol_name = if tcx.sess.target.is_like_darwin {
format!("_{}", symbol.name)
} else {
symbol.name.to_owned()
};

global_asm.push_str(&escape_symbol_name(tcx, &symbol_name, span));
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/inline_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,13 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
CInlineAsmOperand::Const { ref value } => {
generated_asm.push_str(value);
}
CInlineAsmOperand::Symbol { ref symbol } => generated_asm.push_str(symbol),
CInlineAsmOperand::Symbol { ref symbol } => {
if binary_format == BinaryFormat::Macho {
generated_asm.push('_');
}

generated_asm.push_str(symbol);
}
}
}
}
Expand Down
Loading