tackle some clippy lints in ld_so

This commit is contained in:
auronandace
2026-03-14 14:20:22 +00:00
parent 693cf03519
commit a01313467e
4 changed files with 10 additions and 12 deletions
+3 -3
View File
@@ -37,7 +37,7 @@ use core::{
sync::atomic::{AtomicBool, Ordering},
};
pub const CHAR_BITS: usize = size_of::<c_char>() * 8;
pub const CHAR_BITS: usize = c_char::BITS as usize;
pub type Relr = usize;
#[cfg(target_pointer_width = "32")]
@@ -432,7 +432,7 @@ impl DSO {
let (_, sym) = self.dynamic.hash_table.find(
name,
None,
&self.dynamic.symbols,
self.dynamic.symbols,
self.dynamic.dynstrtab,
&VersionTable::default(),
)?;
@@ -777,7 +777,7 @@ impl DSO {
let dynstrtab = StringTable::new(
&*mmap,
strtab_offset as u64,
strtab_offset as u64 + strtab_size as u64,
strtab_offset as u64 + strtab_size,
);
let get_str = |entry: &Dyn| {
+2 -1
View File
@@ -754,7 +754,8 @@ impl Linker {
///
/// If a dependency has already been loaded, it is *not* added to the scope
/// nor to `new_objects`.
fn load_objects_recursive<'a>(
#[allow(clippy::too_many_arguments)]
fn load_objects_recursive(
&mut self,
name: &str,
parent_runpath: &Option<String>,
+2 -2
View File
@@ -101,11 +101,11 @@ pub fn static_init(
let page_size = Sys::getpagesize();
let voff = p_vaddr % page_size;
// let vaddr = ph.p_vaddr as usize - voff;
let vsize = ((p_memsz + voff + page_size - 1) / page_size) * page_size;
let vsize = (p_memsz + voff).div_ceil(page_size) * page_size;
if p_type == elf::PT_TLS {
let valign = if p_align > 0 {
((p_memsz + (p_align - 1)) / p_align) * p_align
p_memsz.div_ceil(p_align) * p_align
} else {
p_memsz
};
+3 -6
View File
@@ -206,7 +206,7 @@ pub unsafe extern "C" fn relibc_ld_so_start(
} else {
let ph = phdrs
.iter()
.find(|ph| ph.p_type(NativeEndian) == PT_DYNAMIC as u32)
.find(|ph| ph.p_type(NativeEndian) == PT_DYNAMIC)
.unwrap();
unsafe { dynamic.byte_sub(ph.p_vaddr(NativeEndian) as usize) as usize }
};
@@ -266,11 +266,8 @@ pub unsafe extern "C" fn relibc_ld_so_start(
for reloc in relocs {
let reloc: Relocation = reloc.into();
let ptr = (reloc.offset + self_base) as *mut usize;
match reloc.kind {
RelocationKind::RELATIVE => {
unsafe { *ptr = self_base + reloc.addend.unwrap_or_default() };
}
_ => {}
if reloc.kind == RelocationKind::RELATIVE {
unsafe { *ptr = self_base + reloc.addend.unwrap_or_default() };
}
}
}