rewrite pdb-alt-path to rmake

This commit is contained in:
Oneirical 2024-06-21 15:30:51 -04:00
parent 5ced3dad57
commit 790c238ef4
3 changed files with 37 additions and 21 deletions

View File

@ -131,7 +131,6 @@ run-make/pass-linker-flags-flavor/Makefile
run-make/pass-linker-flags-from-dep/Makefile
run-make/pass-linker-flags/Makefile
run-make/pass-non-c-like-enum-to-c/Makefile
run-make/pdb-alt-path/Makefile
run-make/pdb-buildinfo-cl-cmd/Makefile
run-make/pgo-gen-lto/Makefile
run-make/pgo-gen-no-imp-symbols/Makefile

View File

@ -1,20 +0,0 @@
include ../tools.mk
# only-windows-msvc
all:
# Test that we don't have the full path to the PDB file in the binary
$(RUSTC) main.rs -g --crate-name my_crate_name --crate-type bin -Cforce-frame-pointers
$(CGREP) "my_crate_name.pdb" < $(TMPDIR)/my_crate_name.exe
$(CGREP) -v "\\my_crate_name.pdb" < $(TMPDIR)/my_crate_name.exe
# Test that backtraces still can find debuginfo by checking that they contain symbol names and
# source locations.
$(TMPDIR)/my_crate_name.exe &> $(TMPDIR)/backtrace.txt
$(CGREP) "my_crate_name::fn_in_backtrace" < $(TMPDIR)/backtrace.txt
$(CGREP) "main.rs:15" < $(TMPDIR)/backtrace.txt
# Test that explicitly passed `-Clink-arg=/PDBALTPATH:...` is respected
$(RUSTC) main.rs -g --crate-name my_crate_name --crate-type bin -Clink-arg=/PDBALTPATH:abcdefg.pdb -Cforce-frame-pointers
$(CGREP) "abcdefg.pdb" < $(TMPDIR)/my_crate_name.exe
$(CGREP) -v "my_crate_name.pdb" < $(TMPDIR)/my_crate_name.exe

View File

@ -0,0 +1,37 @@
// The information inside a .exe file contains a string of the PDB file name.
// This could be a security concern if the full path was exposed, as it could
// reveal information about the filesystem where the bin was first compiled.
// This should only be overridden by `-Clink-arg=/PDBALTPATH:...` - this test
// checks that no full file paths are exposed and that the override flag is respected.
// See https://github.com/rust-lang/rust/pull/121297
//@ only-windows-msvc
fn main() {
// Test that we don't have the full path to the PDB file in the binary
rustc()
.input("main.rs")
.arg("-g")
.crate_name("my_crate_name")
.crate_type("bin")
.arg("-Cforce-frame-pointers")
.run();
invalid_utf8_contains(bin_name("my_crate_name"), "my_crate_name.pdb");
invalid_utf8_not_contains(bin_name("my_crate_name"), r#"\my_crate_name.pdb"#);
// Test that backtraces still can find debuginfo by checking that they contain symbol names and
// source locations.
let out = run(bin_name(my_crate_name));
out.assert_stdout_contains("my_crate_name::fn_in_backtrace");
out.assert_stdout_contains("main.rs:15");
// Test that explicitly passed `-Clink-arg=/PDBALTPATH:...` is respected
rustc()
.input("main.rs")
.arg("-g")
.crate_name("my_crate_name")
.crate_type("bin")
.link_arg("/PDBALTPATH:abcdefg.pdb")
.arg("-Cforce-frame-pointers")
.run();
invalid_utf8_contains(bin_name("my_crate_name"), "abcdefg.pdb");
invalid_utf8_not_contains(bin_name("my_crate_name"), "my_crate_name.pdb");
}