Skip to content

Commit 842858f

Browse files
committed
linker: Quote symbol names in .def files
To support weird symbol names, including dots in particular.
1 parent db074a0 commit 842858f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-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 {
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ build-pass
2+
//@ needs-crate-type: cdylib
3+
4+
#![crate_type = "cdylib"]
5+
6+
#[export_name = "foo.0123"]
7+
pub extern "C" fn foo() {}
8+
9+
#[export_name = "EXPORTS"]
10+
pub extern "C" fn bar() {}

0 commit comments

Comments
 (0)