Skip to content

Commit c883510

Browse files
committed
auto merge of #16588 : thestinger/rust/aslr, r=pcwalton
Closes #16514
2 parents ef0d49d + 96f5eba commit c883510

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustc/middle/trans/base.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ use std::cell::{Cell, RefCell};
8787
use std::rc::Rc;
8888
use std::{i8, i16, i32, i64};
8989
use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel, Rust, RustCall};
90-
use syntax::abi::{RustIntrinsic, Abi};
90+
use syntax::abi::{RustIntrinsic, Abi, OsWindows};
9191
use syntax::ast_util::{local_def, is_local};
9292
use syntax::attr::AttrMetaMethods;
9393
use syntax::attr;
@@ -2446,6 +2446,13 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
24462446
&ccx.int_type);
24472447

24482448
let llfn = decl_cdecl_fn(ccx, "main", llfty, ty::mk_nil());
2449+
2450+
// FIXME: #16581: Marking a symbol in the executable with `dllexport`
2451+
// linkage forces MinGW's linker to output a `.reloc` section for ASLR
2452+
if ccx.sess().targ_cfg.os == OsWindows {
2453+
unsafe { llvm::LLVMRustSetDLLExportStorageClass(llfn) }
2454+
}
2455+
24492456
let llbb = "top".with_c_str(|buf| {
24502457
unsafe {
24512458
llvm::LLVMAppendBasicBlockInContext(ccx.llcx, llfn, buf)

0 commit comments

Comments
 (0)