Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elf: add is_mips64el parameter to Rela64::r_info #337

Merged
merged 1 commit into from
Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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