about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2022-04-28 16:22:40 +0100
committerGary Guo <gary@garyguo.net>2022-04-28 21:33:23 +0100
commit0fce0db96f5d7f3b42d25412d3989014551852ac (patch)
tree42cc167583682c676b47470bc26a17312bd56209 /compiler
parent4f9acb268704a1c7f78c8c55da0d7614eac57ade (diff)
downloadrust-0fce0db96f5d7f3b42d25412d3989014551852ac.tar.gz
rust-0fce0db96f5d7f3b42d25412d3989014551852ac.zip
Add `@feat.00` symbol to symbols.o for COFF
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs23
1 files changed, 23 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() {