mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
Add @feat.00
symbol to symbols.o for COFF
This commit is contained in:
parent
4f9acb2687
commit
0fce0db96f
@ -1700,6 +1700,29 @@ fn add_linked_symbol_object(
|
||||
// We handle the name decoration of COFF targets in `symbol_export.rs`, so disable the
|
||||
// default mangler in `object` crate.
|
||||
file.set_mangling(object::write::Mangling::None);
|
||||
|
||||
// Add feature flags to the object file. On MSVC this is optional but LLD will complain if
|
||||
// not present.
|
||||
let mut feature = 0;
|
||||
|
||||
if file.architecture() == object::Architecture::I386 {
|
||||
// Indicate that all SEH handlers are registered in .sxdata section.
|
||||
// We don't have generate any code, so we don't need .sxdata section but LLD still
|
||||
// expects us to set this bit (see #96498).
|
||||
// Reference: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
|
||||
feature |= 1;
|
||||
}
|
||||
|
||||
file.add_symbol(object::write::Symbol {
|
||||
name: "@feat.00".into(),
|
||||
value: feature,
|
||||
size: 0,
|
||||
kind: object::SymbolKind::Data,
|
||||
scope: object::SymbolScope::Compilation,
|
||||
weak: false,
|
||||
section: object::write::SymbolSection::Absolute,
|
||||
flags: object::SymbolFlags::None,
|
||||
});
|
||||
}
|
||||
|
||||
for (sym, kind) in symbols.iter() {
|
||||
|
8
src/test/run-make/issue-96498/Makefile
Normal file
8
src/test/run-make/issue-96498/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
# only-windows
|
||||
# needs-rust-lld
|
||||
|
||||
-include ../../run-make-fulldeps/tools.mk
|
||||
|
||||
# Ensure that LLD can link
|
||||
all:
|
||||
$(RUSTC) -C linker=rust-lld foo.rs
|
4
src/test/run-make/issue-96498/foo.rs
Normal file
4
src/test/run-make/issue-96498/foo.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#![crate_type = "cdylib"]
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn foo() {}
|
Loading…
Reference in New Issue
Block a user