Skip to content

Commit ddf98c1

Browse files
committed
Only enable no-plt when full relro is enabled
1 parent 3b08b13 commit ddf98c1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/librustc_codegen_llvm/attributes.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc::ty::layout::HasTyCtxt;
2020
use rustc::ty::query::Providers;
2121
use rustc_data_structures::sync::Lrc;
2222
use rustc_data_structures::fx::FxHashMap;
23-
use rustc_target::spec::PanicStrategy;
23+
use rustc_target::spec::{PanicStrategy, RelroLevel};
2424

2525
use attributes;
2626
use llvm::{self, Attribute};
@@ -173,7 +173,12 @@ pub fn from_fn_attrs(
173173

174174
set_frame_pointer_elimination(cx, llfn);
175175
set_probestack(cx, llfn);
176-
Attribute::NonLazyBind.apply_llfn(Function, llfn);
176+
177+
// Only enable this optimization if full relro is also enabled.
178+
// In this case, lazy binding was already unavailable, so nothing is lost.
179+
if let RelroLevel::Full = cx.sess().target.target.options.relro_level {
180+
Attribute::NonLazyBind.apply_llfn(Function, llfn);
181+
}
177182

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

0 commit comments

Comments
 (0)