File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
librustc_codegen_ssa/back Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use std::sync::Arc;
33
44use rustc:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
55use rustc:: middle:: exported_symbols:: { metadata_symbol_name, ExportedSymbol , SymbolExportLevel } ;
6- use rustc:: session:: config;
6+ use rustc:: session:: config:: { self , Sanitizer } ;
77use rustc:: ty:: query:: Providers ;
88use rustc:: ty:: subst:: SubstsRef ;
99use rustc:: ty:: Instance ;
@@ -206,6 +206,12 @@ fn exported_symbols_provider_local(
206206 } ) ) ;
207207 }
208208
209+ if let Some ( Sanitizer :: Memory ) = tcx. sess . opts . debugging_opts . sanitizer {
210+ // Similar to profiling, preserve weak msan symbol during LTO.
211+ let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( "__msan_track_origins" ) ) ;
212+ symbols. push ( ( exported_symbol, SymbolExportLevel :: C ) ) ;
213+ }
214+
209215 if tcx. sess . crate_types . borrow ( ) . contains ( & config:: CrateType :: Dylib ) {
210216 let symbol_name = metadata_symbol_name ( tcx) ;
211217 let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( & symbol_name) ) ;
Original file line number Diff line number Diff line change 44// needs-sanitizer-support
55// only-linux
66// only-x86_64
7- // revisions:MSAN-0 MSAN-1 MSAN-2
7+ // revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO
88//
99//[MSAN-0] compile-flags: -Zsanitizer=memory
1010//[MSAN-1] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1
1111//[MSAN-2] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins
12+ //[MSAN-1-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1 -C lto=fat
13+ //[MSAN-2-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins -C lto=fat
1214
1315#![ crate_type="lib" ]
1416
1517// MSAN-0-NOT: @__msan_track_origins
1618// MSAN-1: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 1
1719// MSAN-2: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 2
20+ // MSAN-1-LTO: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 1
21+ // MSAN-2-LTO: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 2
1822//
1923// MSAN-0-LABEL: define void @copy(
2024// MSAN-1-LABEL: define void @copy(
You can’t perform that action at this time.
0 commit comments