|
| 1 | +// Verifies that AddressSanitizer symbols show up as expected in LLVM IR |
| 2 | +// with -Zsanitizer (DO NOT SUBMIT: add ASAN (no LTO) and ASAN-LTO2 (lto=fat) tests). |
| 3 | +// |
| 4 | +// Notes about the `compile-flags` below: |
| 5 | +// |
| 6 | +// * The original issue only reproed with LTO - this is why this angle has |
| 7 | +// extra test coverage via different `revisions` |
| 8 | +// * To observe the failure/repro at LLVM-IR level we need to use `staticlib` |
| 9 | +// which necessitates `-C prefer-dynamic=false` - without the latter flag, |
| 10 | +// we would have run into "cannot prefer dynamic linking when performing LTO". |
| 11 | +// |
| 12 | +// needs-sanitizer-address |
| 13 | +// |
| 14 | +// revisions:ASAN ASAN-LTO |
| 15 | +//[ASAN] compile-flags: -Zsanitizer=address |
| 16 | +//[ASAN-LTO] compile-flags: -Zsanitizer=address -C prefer-dynamic=false -C lto |
| 17 | + |
| 18 | +#![crate_type="staticlib"] |
| 19 | + |
| 20 | +// The test below mimics `CACHED_POW10` from `library/core/src/num/flt2dec/strategy/grisu.rs` which |
| 21 | +// (because of incorrect handling of `___asan_globals_registered` during LTO) was incorrectly |
| 22 | +// reported as an ODR violation in https://crbug.com/1459233#c1. Before this bug was fixed, |
| 23 | +// `___asan_globals_registered` would show up as `internal global i64`. |
| 24 | +// |
| 25 | +// See https://github.com/rust-lang/rust/issues/113404 for more discussion. |
| 26 | +// |
| 27 | +// CHECK: @___asan_globals_registered = common hidden global i64 0 |
| 28 | +// CHECK: @__start_asan_globals = extern_weak hidden global i64 |
| 29 | +// CHECK: @__stop_asan_globals = extern_weak hidden global i64 |
| 30 | +#[no_mangle] |
| 31 | +pub static CACHED_POW10: [(u64, i16, i16); 4] = [ |
| 32 | + (0xe61acf033d1a45df, -1087, -308), |
| 33 | + (0xab70fe17c79ac6ca, -1060, -300), |
| 34 | + (0xff77b1fcbebcdc4f, -1034, -292), |
| 35 | + (0xbe5691ef416bd60c, -1007, -284), |
| 36 | +]; |
0 commit comments