Skip to content

linker: Quote symbol names in .def files #140505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/linking/weird-export-names.rs
Original file line number Diff line number Diff line change
@@ -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