mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
Prevent name collisions with internal implementation details
The implementation of the linkage attribute inside extern blocks defines symbols starting with _rust_extern_with_linkage_. If someone tries to also define this symbol you will get a symbol conflict or even an ICE. By adding an unpredictable component to the symbol name, this becomes less of an issue.
This commit is contained in:
+4
-1
@@ -310,7 +310,10 @@ fn data_id_for_static(
|
||||
// `extern_with_linkage_foo` will instead be initialized to
|
||||
// zero.
|
||||
|
||||
let ref_name = format!("_rust_extern_with_linkage_{}", symbol_name);
|
||||
let ref_name = format!(
|
||||
"_rust_extern_with_linkage_{:016x}_{symbol_name}",
|
||||
tcx.stable_crate_id(LOCAL_CRATE)
|
||||
);
|
||||
let ref_data_id = module.declare_data(&ref_name, Linkage::Local, false, false).unwrap();
|
||||
let mut data = DataDescription::new();
|
||||
data.set_align(align);
|
||||
|
||||
Reference in New Issue
Block a user