Skip to content

Commit

Permalink
Only enable no-plt when full relro is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielMajeri committed Sep 26, 2018
1 parent 3b08b13 commit ddf98c1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc::ty::layout::HasTyCtxt;
use rustc::ty::query::Providers;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::fx::FxHashMap;
use rustc_target::spec::PanicStrategy;
use rustc_target::spec::{PanicStrategy, RelroLevel};

use attributes;
use llvm::{self, Attribute};
Expand Down Expand Up @@ -173,7 +173,12 @@ pub fn from_fn_attrs(

set_frame_pointer_elimination(cx, llfn);
set_probestack(cx, llfn);
Attribute::NonLazyBind.apply_llfn(Function, llfn);

// Only enable this optimization if full relro is also enabled.
// In this case, lazy binding was already unavailable, so nothing is lost.
if let RelroLevel::Full = cx.sess().target.target.options.relro_level {
Attribute::NonLazyBind.apply_llfn(Function, llfn);
}

if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
Attribute::Cold.apply_llfn(Function, llfn);
Expand Down

0 comments on commit ddf98c1

Please sign in to comment.