Get rid of the .note interpretation of rustc dylib metadata.
This commit is contained in:
parent
02aec40dc9
commit
1bb1444516
@ -867,9 +867,8 @@ fn get_metadata_section_imp(target: &Target, flavor: CrateFlavor, filename: &Pat
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn meta_section_name(target: &Target) -> &'static str {
|
pub fn meta_section_name(target: &Target) -> &'static str {
|
||||||
if target.options.is_like_osx {
|
// Historical note:
|
||||||
"__DATA,__note.rustc"
|
//
|
||||||
} else if target.options.is_like_msvc {
|
|
||||||
// When using link.exe it was seen that the section name `.note.rustc`
|
// When using link.exe it was seen that the section name `.note.rustc`
|
||||||
// was getting shortened to `.note.ru`, and according to the PE and COFF
|
// was getting shortened to `.note.ru`, and according to the PE and COFF
|
||||||
// specification:
|
// specification:
|
||||||
@ -881,20 +880,16 @@ pub fn meta_section_name(target: &Target) -> &'static str {
|
|||||||
//
|
//
|
||||||
// As a result, we choose a slightly shorter name! As to why
|
// As a result, we choose a slightly shorter name! As to why
|
||||||
// `.note.rustc` works on MinGW, that's another good question...
|
// `.note.rustc` works on MinGW, that's another good question...
|
||||||
".rustc"
|
|
||||||
|
if target.options.is_like_osx {
|
||||||
|
"__DATA,.rustc"
|
||||||
} else {
|
} else {
|
||||||
".note.rustc"
|
".rustc"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_meta_section_name(target: &Target) -> &'static str {
|
pub fn read_meta_section_name(_target: &Target) -> &'static str {
|
||||||
if target.options.is_like_osx {
|
|
||||||
"__note.rustc"
|
|
||||||
} else if target.options.is_like_msvc {
|
|
||||||
".rustc"
|
".rustc"
|
||||||
} else {
|
|
||||||
".note.rustc"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A diagnostic function for dumping crate metadata to an output stream
|
// A diagnostic function for dumping crate metadata to an output stream
|
||||||
|
@ -2250,10 +2250,17 @@ fn write_metadata(cx: &SharedCrateContext,
|
|||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
llvm::LLVMSetInitializer(llglobal, llconst);
|
||||||
let name =
|
let section_name =
|
||||||
cx.tcx().sess.cstore.metadata_section_name(&cx.sess().target.target);
|
cx.tcx().sess.cstore.metadata_section_name(&cx.sess().target.target);
|
||||||
let name = CString::new(name).unwrap();
|
let name = CString::new(section_name).unwrap();
|
||||||
llvm::LLVMSetSection(llglobal, name.as_ptr())
|
llvm::LLVMSetSection(llglobal, name.as_ptr());
|
||||||
|
|
||||||
|
// Also generate a .section directive to force no
|
||||||
|
// flags, at least for ELF outputs, so that the
|
||||||
|
// metadata doesn't get loaded into memory.
|
||||||
|
let directive = format!(".section {}", section_name);
|
||||||
|
let directive = CString::new(directive).unwrap();
|
||||||
|
llvm::LLVMSetModuleInlineAsm(cx.metadata_llmod(), directive.as_ptr())
|
||||||
}
|
}
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user