Skip to content

Commit

Permalink
elf: add is_mips64el parameter to Rela64::r_info (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc authored Jul 25, 2021
1 parent daf8cdc commit 1929ca9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,13 +1178,7 @@ impl<E: Endian> Rela64<E> {
}

/// Calculate the `r_info` field given the `r_sym` and `r_type` components.
// TODO: add is_mips64el parameter
pub fn r_info(endian: E, r_sym: u32, r_type: u32) -> U64<E> {
U64::new(endian, (u64::from(r_sym) << 32) | u64::from(r_type))
}

#[allow(dead_code)]
pub(crate) fn r_info2(endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) -> U64<E> {
pub fn r_info(endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) -> U64<E> {
let mut t = (u64::from(r_sym) << 32) | u64::from(r_type);
if is_mips64el {
t = (t >> 32)
Expand All @@ -1197,9 +1191,8 @@ impl<E: Endian> Rela64<E> {
}

/// Set the `r_info` field given the `r_sym` and `r_type` components.
// TODO: add is_mips64el parameter
pub fn set_r_info(&mut self, endian: E, r_sym: u32, r_type: u32) {
self.r_info = Self::r_info(endian, r_sym, r_type);
pub fn set_r_info(&mut self, endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) {
self.r_info = Self::r_info(endian, is_mips64el, r_sym, r_type);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/write/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ impl<E: Endian> Elf for Elf64<E> {
if is_rela {
let rel = elf::Rela64 {
r_offset: U64::new(endian, rel.r_offset),
r_info: elf::Rela64::r_info2(endian, is_mips64el, rel.r_sym, rel.r_type),
r_info: elf::Rela64::r_info(endian, is_mips64el, rel.r_sym, rel.r_type),
r_addend: I64::new(endian, rel.r_addend),
};
buffer.write(&rel);
Expand Down

0 comments on commit 1929ca9

Please sign in to comment.