Skip to content

Commit 1929ca9

Browse files
authored
elf: add is_mips64el parameter to Rela64::r_info (#337)
1 parent daf8cdc commit 1929ca9

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

src/elf.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,13 +1178,7 @@ impl<E: Endian> Rela64<E> {
11781178
}
11791179

11801180
/// Calculate the `r_info` field given the `r_sym` and `r_type` components.
1181-
// TODO: add is_mips64el parameter
1182-
pub fn r_info(endian: E, r_sym: u32, r_type: u32) -> U64<E> {
1183-
U64::new(endian, (u64::from(r_sym) << 32) | u64::from(r_type))
1184-
}
1185-
1186-
#[allow(dead_code)]
1187-
pub(crate) fn r_info2(endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) -> U64<E> {
1181+
pub fn r_info(endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) -> U64<E> {
11881182
let mut t = (u64::from(r_sym) << 32) | u64::from(r_type);
11891183
if is_mips64el {
11901184
t = (t >> 32)
@@ -1197,9 +1191,8 @@ impl<E: Endian> Rela64<E> {
11971191
}
11981192

11991193
/// Set the `r_info` field given the `r_sym` and `r_type` components.
1200-
// TODO: add is_mips64el parameter
1201-
pub fn set_r_info(&mut self, endian: E, r_sym: u32, r_type: u32) {
1202-
self.r_info = Self::r_info(endian, r_sym, r_type);
1194+
pub fn set_r_info(&mut self, endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) {
1195+
self.r_info = Self::r_info(endian, is_mips64el, r_sym, r_type);
12031196
}
12041197
}
12051198

src/write/elf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ impl<E: Endian> Elf for Elf64<E> {
12991299
if is_rela {
13001300
let rel = elf::Rela64 {
13011301
r_offset: U64::new(endian, rel.r_offset),
1302-
r_info: elf::Rela64::r_info2(endian, is_mips64el, rel.r_sym, rel.r_type),
1302+
r_info: elf::Rela64::r_info(endian, is_mips64el, rel.r_sym, rel.r_type),
13031303
r_addend: I64::new(endian, rel.r_addend),
13041304
};
13051305
buffer.write(&rel);

0 commit comments

Comments
 (0)