1
Fork 0

Make relro-level=off explicitly disable RELRO

Previously relro-level=off would just not tell the linker to use RELRO,
but when you want to disable RELRO you most likely want to entirely
prevent.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
This commit is contained in:
Johannes Löthberg 2018-02-22 21:28:20 +01:00
parent 2789b067da
commit f0c459ebd2
2 changed files with 21 additions and 6 deletions

View file

@ -1014,7 +1014,9 @@ fn link_args(cmd: &mut Linker,
RelroLevel::Partial => {
cmd.partial_relro();
},
RelroLevel::Off => {},
RelroLevel::Off => {
cmd.no_relro();
},
}
// Pass optimization flags down to the linker.

View file

@ -113,8 +113,9 @@ pub trait Linker {
fn gc_sections(&mut self, keep_metadata: bool);
fn position_independent_executable(&mut self);
fn no_position_independent_executable(&mut self);
fn partial_relro(&mut self);
fn full_relro(&mut self);
fn partial_relro(&mut self);
fn no_relro(&mut self);
fn optimize(&mut self);
fn debuginfo(&mut self);
fn no_default_libraries(&mut self);
@ -188,8 +189,9 @@ impl<'a> Linker for GccLinker<'a> {
fn add_object(&mut self, path: &Path) { self.cmd.arg(path); }
fn position_independent_executable(&mut self) { self.cmd.arg("-pie"); }
fn no_position_independent_executable(&mut self) { self.cmd.arg("-no-pie"); }
fn partial_relro(&mut self) { self.linker_arg("-z,relro"); }
fn full_relro(&mut self) { self.linker_arg("-z,relro,-z,now"); }
fn partial_relro(&mut self) { self.linker_arg("-z,relro"); }
fn no_relro(&mut self) { self.linker_arg("-z,norelro"); }
fn build_static_executable(&mut self) { self.cmd.arg("-static"); }
fn args(&mut self, args: &[String]) { self.cmd.args(args); }
@ -452,11 +454,15 @@ impl<'a> Linker for MsvcLinker<'a> {
// noop
}
fn full_relro(&mut self) {
// noop
}
fn partial_relro(&mut self) {
// noop
}
fn full_relro(&mut self) {
fn no_relro(&mut self) {
// noop
}
@ -664,11 +670,15 @@ impl<'a> Linker for EmLinker<'a> {
// noop
}
fn full_relro(&mut self) {
// noop
}
fn partial_relro(&mut self) {
// noop
}
fn full_relro(&mut self) {
fn no_relro(&mut self) {
// noop
}
@ -829,10 +839,13 @@ impl Linker for WasmLd {
fn position_independent_executable(&mut self) {
}
fn full_relro(&mut self) {
}
fn partial_relro(&mut self) {
}
fn full_relro(&mut self) {
fn no_relro(&mut self) {
}
fn build_static_executable(&mut self) {