diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-29 11:23:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-29 11:23:16 +0200 |
| commit | 48199e0e3fb3f77bfa5befc2bc485280ad922f53 (patch) | |
| tree | d9254072c3b95525f649b1b8c9da49250d758e64 | |
| parent | 109008a1c104ac672c4852ee3dee55a8f2bda789 (diff) | |
| parent | 0fce0db96f5d7f3b42d25412d3989014551852ac (diff) | |
| download | rust-48199e0e3fb3f77bfa5befc2bc485280ad922f53.tar.gz rust-48199e0e3fb3f77bfa5befc2bc485280ad922f53.zip | |
Rollup merge of #96523 - nbdd0121:windows, r=petrochenkov
Add `@feat.00` symbol to symbols.o for COFF Fix #96498 This is based on top of #96444. r? ``@petrochenkov``
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 23 | ||||
| -rw-r--r-- | src/test/run-make/issue-96498/Makefile | 8 | ||||
| -rw-r--r-- | src/test/run-make/issue-96498/foo.rs | 4 |
3 files changed, 35 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 54a69fcf681..886ca9681e2 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -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() { diff --git a/src/test/run-make/issue-96498/Makefile b/src/test/run-make/issue-96498/Makefile new file mode 100644 index 00000000000..eae6400aee4 --- /dev/null +++ b/src/test/run-make/issue-96498/Makefile @@ -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 diff --git a/src/test/run-make/issue-96498/foo.rs b/src/test/run-make/issue-96498/foo.rs new file mode 100644 index 00000000000..93ac3641b09 --- /dev/null +++ b/src/test/run-make/issue-96498/foo.rs @@ -0,0 +1,4 @@ +#![crate_type = "cdylib"] + +#[no_mangle] +extern "C" fn foo() {} |
