Skip to content

Commit

Permalink
rewriting match on endianness
Browse files Browse the repository at this point in the history
  • Loading branch information
Charisee committed May 5, 2023
1 parent 1fc0442 commit 37f3e2f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ fn add_gnu_property_note(
Endianness::Big => v.to_be_bytes(),
})
});
/*
match endianness {
Endianness::Little => header_values.map(|v| data.extend_from_slice(&(v.to_le_bytes()))),
Endianness::Big => header_values.map(|v| data.extend_from_slice(&(v.to_be_bytes()))),
};*/
data.extend_from_slice(b"GNU\0"); // Owner of the program property note
let pr_type: u32 = match architecture {
Architecture::X86_64 => 0xc0000002,
Expand All @@ -138,10 +133,12 @@ fn add_gnu_property_note(
let pr_data: u32 = 3; //program property descriptor
let pr_padding: u32 = 0;
let property_values = [pr_type, pr_datasz, pr_data, pr_padding];
match endianness {
Endianness::Little => property_values.map(|v| data.extend_from_slice(&(v.to_le_bytes()))),
Endianness::Big => property_values.map(|v| data.extend_from_slice(&(v.to_be_bytes()))),
};
property_values.iter().for_each(|v| {
data.extend_from_slice(&match endianness {
Endianness::Little => v.to_le_bytes(),
Endianness::Big => v.to_be_bytes(),
})
});
file.append_section_data(section, &data, 8);
}

Expand Down

0 comments on commit 37f3e2f

Please sign in to comment.