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:
commit
ca67f4da76
2 changed files with 13 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
10
tests/ui/linking/weird-export-names.rs
Normal file
10
tests/ui/linking/weird-export-names.rs
Normal 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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue