Explicitly set no ELF flags for .rustc section
For a data section, the object crate will set the SHF_ALLOC by default, which is exactly what we don't want. Explicitly set sh_flags to zero to avoid this.
This commit is contained in:
parent
16d8a91d51
commit
79d5309604
1 changed files with 8 additions and 1 deletions
|
@ -259,8 +259,15 @@ pub fn create_compressed_metadata_file(
|
|||
let section = file.add_section(
|
||||
file.segment_name(StandardSegment::Data).to_vec(),
|
||||
b".rustc".to_vec(),
|
||||
SectionKind::Data,
|
||||
SectionKind::ReadOnlyData,
|
||||
);
|
||||
match file.format() {
|
||||
BinaryFormat::Elf => {
|
||||
// Explicitly set no flags to avoid SHF_ALLOC default for data section.
|
||||
file.section_mut(section).flags = SectionFlags::Elf { sh_flags: 0 };
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
let offset = file.append_section_data(section, &compressed, 1);
|
||||
|
||||
// For MachO and probably PE this is necessary to prevent the linker from throwing away the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue