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
commit ca67f4da76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -816,7 +816,9 @@ impl<'a> Linker for GccLinker<'a> {
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 {

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() {}