@@ -785,17 +785,19 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
785
785
tcx. sess . cstore . metadata_section_name ( & tcx. sess . target . target ) ;
786
786
let name = CString :: new ( section_name) . unwrap ( ) ;
787
787
llvm:: LLVMSetSection ( llglobal, name. as_ptr ( ) ) ;
788
-
789
- // Also generate a .section directive to force no
790
- // flags, at least for ELF outputs, so that the
791
- // metadata doesn't get loaded into memory.
792
- let directive = format ! ( ".section {}" , section_name) ;
793
- let directive = CString :: new ( directive) . unwrap ( ) ;
794
- llvm:: LLVMSetModuleInlineAsm ( metadata_llmod, directive. as_ptr ( ) )
788
+ make_section_non_loadable ( metadata_llmod, section_name) ;
795
789
}
796
790
return ( metadata_llcx, metadata_llmod, metadata) ;
797
791
}
798
792
793
+ /// Generate a .section directive to force no flags (e.g. for ELF outputs)
794
+ /// so that the contents of that section don't get loaded into memory.
795
+ pub unsafe fn make_section_non_loadable ( llmod : ModuleRef , section : & str ) {
796
+ let directive = format ! ( ".section {}" , section) ;
797
+ let directive = CString :: new ( directive) . unwrap ( ) ;
798
+ llvm:: LLVMSetModuleInlineAsm ( llmod, directive. as_ptr ( ) )
799
+ }
800
+
799
801
/// Find any symbols that are defined in one compilation unit, but not declared
800
802
/// in any other compilation unit. Give these symbols internal linkage.
801
803
fn internalize_symbols < ' a , ' tcx > ( sess : & Session ,
0 commit comments