Skip to content

Commit e2fdb84

Browse files
committed
Conditionally export msan symbols only if they are defined
* `__msan_keep_going` is defined when `-Zsanitizer-recover=memory`. * `__msan_track_origins` is defined when `-Zsanitizer-memory-track-origins`.
1 parent c475117 commit e2fdb84

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,18 @@ fn exported_symbols_provider_local<'tcx>(
241241
}
242242

243243
if tcx.sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::MEMORY) {
244+
let mut msan_weak_symbols = Vec::new();
245+
244246
// Similar to profiling, preserve weak msan symbol during LTO.
245-
const MSAN_WEAK_SYMBOLS: [&str; 2] = ["__msan_track_origins", "__msan_keep_going"];
247+
if tcx.sess.opts.debugging_opts.sanitizer_recover.contains(SanitizerSet::MEMORY) {
248+
msan_weak_symbols.push("__msan_keep_going");
249+
}
250+
251+
if tcx.sess.opts.debugging_opts.sanitizer_memory_track_origins != 0 {
252+
msan_weak_symbols.push("__msan_track_origins");
253+
}
246254

247-
symbols.extend(MSAN_WEAK_SYMBOLS.iter().map(|sym| {
255+
symbols.extend(msan_weak_symbols.into_iter().map(|sym| {
248256
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, sym));
249257
(
250258
exported_symbol,

0 commit comments

Comments
 (0)