@@ -6,6 +6,7 @@ use rustc_ast::expand::allocator::{
66use rustc_middle:: bug;
77use rustc_middle:: ty:: TyCtxt ;
88use rustc_session:: config:: { DebugInfo , OomStrategy } ;
9+ use rustc_symbol_mangling:: mangle_internal_symbol;
910
1011use crate :: common:: AsCCharPtr ;
1112use crate :: llvm:: { self , Context , False , Module , True , Type } ;
@@ -55,8 +56,8 @@ pub(crate) unsafe fn codegen(
5556 }
5657 } ;
5758
58- let from_name = global_fn_name ( method. name ) ;
59- let to_name = default_fn_name ( method. name ) ;
59+ let from_name = mangle_internal_symbol ( tcx , & global_fn_name ( method. name ) ) ;
60+ let to_name = mangle_internal_symbol ( tcx , & default_fn_name ( method. name ) ) ;
6061
6162 create_wrapper_function ( tcx, llcx, llmod, & from_name, & to_name, & args, output, false ) ;
6263 }
@@ -67,23 +68,23 @@ pub(crate) unsafe fn codegen(
6768 tcx,
6869 llcx,
6970 llmod,
70- "__rust_alloc_error_handler" ,
71- alloc_error_handler_name ( alloc_error_handler_kind) ,
71+ & mangle_internal_symbol ( tcx , "__rust_alloc_error_handler" ) ,
72+ & mangle_internal_symbol ( tcx , alloc_error_handler_name ( alloc_error_handler_kind) ) ,
7273 & [ usize, usize] , // size, align
7374 None ,
7475 true ,
7576 ) ;
7677
7778 unsafe {
7879 // __rust_alloc_error_handler_should_panic
79- let name = OomStrategy :: SYMBOL ;
80+ let name = mangle_internal_symbol ( tcx , OomStrategy :: SYMBOL ) ;
8081 let ll_g = llvm:: LLVMRustGetOrInsertGlobal ( llmod, name. as_c_char_ptr ( ) , name. len ( ) , i8) ;
8182 llvm:: set_visibility ( ll_g, llvm:: Visibility :: from_generic ( tcx. sess . default_visibility ( ) ) ) ;
8283 let val = tcx. sess . opts . unstable_opts . oom . should_panic ( ) ;
8384 let llval = llvm:: LLVMConstInt ( i8, val as u64 , False ) ;
8485 llvm:: LLVMSetInitializer ( ll_g, llval) ;
8586
86- let name = NO_ALLOC_SHIM_IS_UNSTABLE ;
87+ let name = mangle_internal_symbol ( tcx , NO_ALLOC_SHIM_IS_UNSTABLE ) ;
8788 let ll_g = llvm:: LLVMRustGetOrInsertGlobal ( llmod, name. as_c_char_ptr ( ) , name. len ( ) , i8) ;
8889 llvm:: set_visibility ( ll_g, llvm:: Visibility :: from_generic ( tcx. sess . default_visibility ( ) ) ) ;
8990 let llval = llvm:: LLVMConstInt ( i8, 0 , False ) ;
0 commit comments