Skip to content

Commit 1610370

Browse files
authored
Rollup merge of rust-lang#140505 - petrochenkov:expquote, r=bjorn3
linker: Quote symbol names in .def files To support weird symbol names, including dots in particular. cc [rust-lang#134767](rust-lang#134767 (comment))
2 parents 16df570 + 8298004 commit 1610370

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,9 @@ impl<'a> Linker for GccLinker<'a> {
816816
writeln!(f, "EXPORTS")?;
817817
for symbol in symbols {
818818
debug!(" _{symbol}");
819-
writeln!(f, " {symbol}")?;
819+
// Quote the name in case it's reserved by linker in some way
820+
// (this accounts for names with dots in particular).
821+
writeln!(f, " \"{symbol}\"")?;
820822
}
821823
};
822824
if let Err(error) = res {
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ build-pass
2+
3+
#![crate_type = "cdylib"]
4+
5+
#[export_name = "foo.0123"]
6+
pub extern "C" fn foo() {}
7+
8+
#[export_name = "EXPORTS"]
9+
pub extern "C" fn bar() {}

0 commit comments

Comments
 (0)