Skip to content

Commit 855f630

Browse files
authored
Rollup merge of #92107 - nikic:rmeta-lnk-remove, r=nagisa
Actually set IMAGE_SCN_LNK_REMOVE for .rmeta The code intended to set the IMAGE_SCN_LNK_REMOVE flag for the .rmeta section, however the value of this flag was set to zero. Instead use the actual value provided by the object crate. This dates back to the original introduction of this code in PR #84449, so we were never setting this flag. As I'm not on Windows, I'm not sure whether that means we were embedding .rmeta into executables, or whether the section ended up getting stripped for some other reason.
2 parents c7125ba + 6eb5072 commit 855f630

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler/rustc_codegen_ssa/src/back/metadata.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::path::Path;
66

77
use object::write::{self, StandardSegment, Symbol, SymbolSection};
88
use object::{
9-
elf, Architecture, BinaryFormat, Endianness, FileFlags, Object, ObjectSection, SectionFlags,
10-
SectionKind, SymbolFlags, SymbolKind, SymbolScope,
9+
elf, pe, Architecture, BinaryFormat, Endianness, FileFlags, Object, ObjectSection,
10+
SectionFlags, SectionKind, SymbolFlags, SymbolKind, SymbolScope,
1111
};
1212

1313
use snap::write::FrameEncoder;
@@ -216,13 +216,12 @@ pub fn create_rmeta_file(sess: &Session, metadata: &[u8]) -> Vec<u8> {
216216
);
217217
match file.format() {
218218
BinaryFormat::Coff => {
219-
const IMAGE_SCN_LNK_REMOVE: u32 = 0;
220219
file.section_mut(section).flags =
221-
SectionFlags::Coff { characteristics: IMAGE_SCN_LNK_REMOVE };
220+
SectionFlags::Coff { characteristics: pe::IMAGE_SCN_LNK_REMOVE };
222221
}
223222
BinaryFormat::Elf => {
224-
const SHF_EXCLUDE: u64 = 0x80000000;
225-
file.section_mut(section).flags = SectionFlags::Elf { sh_flags: SHF_EXCLUDE };
223+
file.section_mut(section).flags =
224+
SectionFlags::Elf { sh_flags: elf::SHF_EXCLUDE as u64 };
226225
}
227226
_ => {}
228227
};

0 commit comments

Comments
 (0)