Migrate relro-levels to rmake

This commit is contained in:
Jerry Wang 2024-06-19 16:30:41 -04:00
parent 5a66a796fc
commit e16f492e42
No known key found for this signature in database
GPG Key ID: B9657729C5192EDC
3 changed files with 29 additions and 23 deletions

View File

@ -151,7 +151,6 @@ run-make/raw-dylib-inline-cross-dylib/Makefile
run-make/raw-dylib-link-ordinal/Makefile
run-make/raw-dylib-stdcall-ordinal/Makefile
run-make/redundant-libs/Makefile
run-make/relro-levels/Makefile
run-make/remap-path-prefix-dwarf/Makefile
run-make/remap-path-prefix/Makefile
run-make/reproducible-build-2/Makefile

View File

@ -1,22 +0,0 @@
# ignore-cross-compile
include ../tools.mk
# only-linux
#
# This tests the different -Crelro-level values, and makes sure that they work properly.
all:
# Ensure that binaries built with the full relro level links them with both
# RELRO and BIND_NOW for doing eager symbol resolving.
$(RUSTC) -Crelro-level=full hello.rs
readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO
readelf -d $(TMPDIR)/hello | grep -q BIND_NOW
$(RUSTC) -Crelro-level=partial hello.rs
readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO
# Ensure that we're *not* built with RELRO when setting it to off. We do
# not want to check for BIND_NOW however, as the linker might have that
# enabled by default.
$(RUSTC) -Crelro-level=off hello.rs
! readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO

View File

@ -0,0 +1,29 @@
// This tests the different -Crelro-level values, and makes sure that they work properly.
//@ ignore-cross-compile
//@ only-linux
use run_make_support::llvm_readobj;
use run_make_support::rustc;
fn compile(relro_level: &str) {
rustc().arg(format!("-Crelro-level={relro_level}")).input("hello.rs").run();
}
fn main() {
// Ensure that binaries built with the full relro level links them with both
// RELRO and BIND_NOW for doing eager symbol resolving.
compile("full");
llvm_readobj().program_headers().input("hello").run().assert_stdout_contains("GNU_RELRO");
llvm_readobj().dynamic_table().input("hello").run().assert_stdout_contains("BIND_NOW");
compile("partial");
llvm_readobj().program_headers().input("hello").run().assert_stdout_contains("GNU_RELRO");
// Ensure that we're *not* built with RELRO when setting it to off. We do
// not want to check for BIND_NOW however, as the linker might have that
// enabled by default.
compile("off");
llvm_readobj().program_headers().input("hello").run().assert_stdout_not_contains("GNU_RELRO");
}