Rollup merge of #140505 - petrochenkov:expquote, r=bjorn3

linker: Quote symbol names in .def files

To support weird symbol names, including dots in particular.

cc [#134767](https://github.com/rust-lang/rust/pull/134767#issuecomment-2839397610)
This commit is contained in:
Matthias Krüger
2025-05-03 08:45:02 +02:00
committed by GitHub
2 changed files with 13 additions and 1 deletions
@@ -816,7 +816,9 @@ fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[St
writeln!(f, "EXPORTS")?;
for symbol in symbols {
debug!(" _{symbol}");
writeln!(f, " {symbol}")?;
// Quote the name in case it's reserved by linker in some way
// (this accounts for names with dots in particular).
writeln!(f, " \"{symbol}\"")?;
}
};
if let Err(error) = res {
+10
View File
@@ -0,0 +1,10 @@
//@ build-pass
//@ needs-crate-type: cdylib
#![crate_type = "cdylib"]
#[export_name = "foo.0123"]
pub extern "C" fn foo() {}
#[export_name = "EXPORTS"]
pub extern "C" fn bar() {}