Skip to content
Open
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: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,8 @@ impl<'a> Linker for GccLinker<'a> {
if !symbols.is_empty() {
writeln!(f, " global:")?;
for sym in symbols {
debug!(" {};", sym.name);
writeln!(f, " {};", sym.name)?;
debug!(" \"{}\";", sym.name);
writeln!(f, " \"{}\";", sym.name)?;
}
}
writeln!(f, "\n local:\n *;\n}};")?;
Expand Down
4 changes: 4 additions & 0 deletions tests/run-make/export-quoted-symbols-version-script/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![crate_type = "cdylib"]

#[unsafe(export_name = "some$foo::bar$thing/path.rs:42")]
pub extern "C" fn exported_symbol_with_version_script_special_characters() {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a function with bad_∢ as symbol name as test for #38238? It is possible that a linker does support arbitrary printable ascii characters, but not unicode characters.

19 changes: 19 additions & 0 deletions tests/run-make/export-quoted-symbols-version-script/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ only-linux
//@ needs-crate-type: cdylib

extern crate run_make_support;

use run_make_support::object::Object;
use run_make_support::{dynamic_lib_name, object, rfs, rustc};

const EXPORTED_SYMBOL: &[u8] = b"some$foo::bar$thing/path.rs:42";

fn main() {
rustc().input("lib.rs").run();

let contents = rfs::read(dynamic_lib_name("lib"));
let object = object::File::parse(contents.as_slice()).unwrap();
let matching_exports =
object.exports().unwrap().iter().filter(|x| x.name() == EXPORTED_SYMBOL).count();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Instead of .filter().count() this could also be .any(). No need to assert there is exactly one symbol with this name. There can't be multiple exported symbols with the same name anyway.

assert_eq!(matching_exports, 1);
}
Loading