Rollup merge of #92029 - nikic:section-flags-fix, r=davidtwco
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. I checked with `objdump -h` that this produces the right flags for ELF. Fixes #92013.
This commit is contained in:
commit
9415c67ae5
@ -259,8 +259,15 @@ pub fn create_compressed_metadata_file(
|
|||||||
let section = file.add_section(
|
let section = file.add_section(
|
||||||
file.segment_name(StandardSegment::Data).to_vec(),
|
file.segment_name(StandardSegment::Data).to_vec(),
|
||||||
b".rustc".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);
|
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
|
// For MachO and probably PE this is necessary to prevent the linker from throwing away the
|
||||||
|
Loading…
Reference in New Issue
Block a user