Skip to content

Commit d4cc01c

Browse files
committed
Auto merge of rust-lang#126715 - Rejyr:migrate-readelf-rmake, r=jieyouxu
Migrate `relro-levels`, `static-pie` to `rmake` Part of rust-lang#121876. r? `@jieyouxu` try-job: aarch64-gnu try-job: arm-android try-job: armhf-gnu try-job: dist-i586-gnu-i586-i686-musl try-job: dist-various-1 try-job: test-various
2 parents acb6273 + a19077d commit d4cc01c

File tree

11 files changed

+126
-87
lines changed

11 files changed

+126
-87
lines changed

src/tools/run-make-support/src/command.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ impl Command {
3636
Self { cmd: StdCommand::new(program), stdin: None, drop_bomb: DropBomb::arm(program) }
3737
}
3838

39-
pub fn set_stdin(&mut self, stdin: Box<[u8]>) {
40-
self.stdin = Some(stdin);
39+
/// Specify a stdin input
40+
pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
41+
self.stdin = Some(input.as_ref().to_vec().into_boxed_slice());
42+
self
4143
}
4244

4345
/// Specify an environment variable.

src/tools/run-make-support/src/llvm.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,24 @@ impl LlvmReadobj {
102102
self
103103
}
104104

105+
/// Pass `--program-headers` to display program headers.
106+
pub fn program_headers(&mut self) -> &mut Self {
107+
self.cmd.arg("--program-headers");
108+
self
109+
}
110+
111+
/// Pass `--symbols` to display the symbol.
112+
pub fn symbols(&mut self) -> &mut Self {
113+
self.cmd.arg("--symbols");
114+
self
115+
}
116+
117+
/// Pass `--dynamic-table` to display the dynamic symbol table.
118+
pub fn dynamic_table(&mut self) -> &mut Self {
119+
self.cmd.arg("--dynamic-table");
120+
self
121+
}
122+
105123
/// Specify the section to display.
106124
pub fn section(&mut self, section: &str) -> &mut Self {
107125
self.cmd.arg("--string-dump");
@@ -153,7 +171,7 @@ impl LlvmFilecheck {
153171

154172
/// Pipe a read file into standard input containing patterns that will be matched against the .patterns(path) call.
155173
pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
156-
self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());
174+
self.cmd.stdin(input);
157175
self
158176
}
159177

src/tools/run-make-support/src/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl Rustc {
244244

245245
/// Specify a stdin input
246246
pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
247-
self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());
247+
self.cmd.stdin(input);
248248
self
249249
}
250250

src/tools/run-make-support/src/rustdoc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl Rustdoc {
9292

9393
/// Specify a stdin input
9494
pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
95-
self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());
95+
self.cmd.stdin(input);
9696
self
9797
}
9898

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ run-make/raw-dylib-inline-cross-dylib/Makefile
151151
run-make/raw-dylib-link-ordinal/Makefile
152152
run-make/raw-dylib-stdcall-ordinal/Makefile
153153
run-make/redundant-libs/Makefile
154-
run-make/relro-levels/Makefile
155154
run-make/remap-path-prefix-dwarf/Makefile
156155
run-make/remap-path-prefix/Makefile
157156
run-make/reproducible-build-2/Makefile
@@ -177,7 +176,6 @@ run-make/split-debuginfo/Makefile
177176
run-make/stable-symbol-names/Makefile
178177
run-make/static-dylib-by-default/Makefile
179178
run-make/static-extern-type/Makefile
180-
run-make/static-pie/Makefile
181179
run-make/staticlib-blank-lib/Makefile
182180
run-make/staticlib-dylib-linkage/Makefile
183181
run-make/std-core-cycle/Makefile

tests/run-make/relro-levels/Makefile

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/run-make/relro-levels/rmake.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This tests the different -Crelro-level values, and makes sure that they work properly.
2+
3+
//@ only-linux
4+
5+
use run_make_support::llvm_readobj;
6+
use run_make_support::rustc;
7+
8+
fn compile(relro_level: &str) {
9+
rustc().arg(format!("-Crelro-level={relro_level}")).input("hello.rs").run();
10+
}
11+
12+
fn main() {
13+
// Ensure that binaries built with the full relro level links them with both
14+
// RELRO and BIND_NOW for doing eager symbol resolving.
15+
16+
compile("full");
17+
llvm_readobj().program_headers().input("hello").run().assert_stdout_contains("GNU_RELRO");
18+
llvm_readobj().dynamic_table().input("hello").run().assert_stdout_contains("BIND_NOW");
19+
20+
compile("partial");
21+
llvm_readobj().program_headers().input("hello").run().assert_stdout_contains("GNU_RELRO");
22+
23+
// Ensure that we're *not* built with RELRO when setting it to off. We do
24+
// not want to check for BIND_NOW however, as the linker might have that
25+
// enabled by default.
26+
compile("off");
27+
llvm_readobj().program_headers().input("hello").run().assert_stdout_not_contains("GNU_RELRO");
28+
}

tests/run-make/static-pie/Makefile

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/run-make/static-pie/check_clang_version.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/run-make/static-pie/check_gcc_version.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)