forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mark
___asan_globals_registered
as an exported symbol for LTO
Fixes rust-lang#113404
- Loading branch information
1 parent
66b15fc
commit d9abc46
Showing
4 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tests/codegen/sanitizer/address-sanitizer-globals-tracking.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Verifies that AddressSanitizer symbols show up as expected in LLVM IR with -Zsanitizer. | ||
// | ||
// Notes about the `compile-flags` below: | ||
// | ||
// * The original issue only reproed with LTO - this is why this angle has | ||
// extra test coverage via different `revisions` | ||
// * To observe the failure/repro at LLVM-IR level we need to use `staticlib` | ||
// which necessitates `-C prefer-dynamic=false` - without the latter flag, | ||
// we would have run into "cannot prefer dynamic linking when performing LTO". | ||
// | ||
// The test is restricted to `only-linux`, because the sanitizer-related instrumentation | ||
// is target specific. In particular, `___asan_globals_registered` is only used in the | ||
// `InstrumentGlobalsELF` and `InstrumentGlobalsMachO` code paths. | ||
// | ||
// needs-sanitizer-address | ||
// only-linux | ||
// | ||
// revisions:ASAN ASAN-LTO | ||
//[ASAN] compile-flags: -Zsanitizer=address | ||
//[ASAN-LTO] compile-flags: -Zsanitizer=address -C prefer-dynamic=false -C lto | ||
|
||
#![crate_type="staticlib"] | ||
|
||
// The test below mimics `CACHED_POW10` from `library/core/src/num/flt2dec/strategy/grisu.rs` which | ||
// (because of incorrect handling of `___asan_globals_registered` during LTO) was incorrectly | ||
// reported as an ODR violation in https://crbug.com/1459233#c1. Before this bug was fixed, | ||
// `___asan_globals_registered` would show up as `internal global i64` rather than `common hidden | ||
// global i64`. (The test expectations ignore the exact type because on `arm-android` the type | ||
// is `i32` rather than `i64`.) | ||
// | ||
// See https://github.com/rust-lang/rust/issues/113404 for more discussion. | ||
// | ||
// CHECK: @___asan_globals_registered = common hidden global | ||
// CHECK: @__start_asan_globals = extern_weak hidden global | ||
// CHECK: @__stop_asan_globals = extern_weak hidden global | ||
#[no_mangle] | ||
pub static CACHED_POW10: [(u64, i16, i16); 4] = [ | ||
(0xe61acf033d1a45df, -1087, -308), | ||
(0xab70fe17c79ac6ca, -1060, -300), | ||
(0xff77b1fcbebcdc4f, -1034, -292), | ||
(0xbe5691ef416bd60c, -1007, -284), | ||
]; |