|
| 1 | +// The information inside a .exe file contains a string of the PDB file name. |
| 2 | +// This could be a security concern if the full path was exposed, as it could |
| 3 | +// reveal information about the filesystem where the bin was first compiled. |
| 4 | +// This should only be overridden by `-Clink-arg=/PDBALTPATH:...` - this test |
| 5 | +// checks that no full file paths are exposed and that the override flag is respected. |
| 6 | +// See https://github.com/rust-lang/rust/pull/121297 |
| 7 | + |
| 8 | +//@ only-x86_64-pc-windows-msvc |
| 9 | + |
| 10 | +use run_make_support::{bin_name, invalid_utf8_contains, invalid_utf8_not_contains, run, rustc}; |
| 11 | + |
| 12 | +fn main() { |
| 13 | + // Test that we don't have the full path to the PDB file in the binary |
| 14 | + rustc() |
| 15 | + .input("main.rs") |
| 16 | + .arg("-g") |
| 17 | + .crate_name("my_crate_name") |
| 18 | + .crate_type("bin") |
| 19 | + .arg("-Cforce-frame-pointers") |
| 20 | + .run(); |
| 21 | + invalid_utf8_contains(bin_name("my_crate_name"), "my_crate_name.pdb"); |
| 22 | + invalid_utf8_not_contains(bin_name("my_crate_name"), r#"\my_crate_name.pdb"#); |
| 23 | + // Test that backtraces still can find debuginfo by checking that they contain symbol names and |
| 24 | + // source locations. |
| 25 | + let out = run(bin_name(my_crate_name)); |
| 26 | + out.assert_stdout_contains("my_crate_name::fn_in_backtrace"); |
| 27 | + out.assert_stdout_contains("main.rs:15"); |
| 28 | + // Test that explicitly passed `-Clink-arg=/PDBALTPATH:...` is respected |
| 29 | + rustc() |
| 30 | + .input("main.rs") |
| 31 | + .arg("-g") |
| 32 | + .crate_name("my_crate_name") |
| 33 | + .crate_type("bin") |
| 34 | + .link_arg("/PDBALTPATH:abcdefg.pdb") |
| 35 | + .arg("-Cforce-frame-pointers") |
| 36 | + .run(); |
| 37 | + invalid_utf8_contains(bin_name("my_crate_name"), "abcdefg.pdb"); |
| 38 | + invalid_utf8_not_contains(bin_name("my_crate_name"), "my_crate_name.pdb"); |
| 39 | +} |
0 commit comments