File: rmake.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 893,176 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (27 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// This tests the different -Crelro-level values, and makes sure that they work properly.

//@ only-linux

use run_make_support::{llvm_readobj, 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");
}