libdyld: cleanup

This commit is contained in:
Sebastien Bourdeauducq 2020-04-12 18:45:43 +08:00
parent 064e114a0b
commit 1d000cc8ef
3 changed files with 6 additions and 11 deletions

2
Cargo.lock generated
View File

@ -32,7 +32,7 @@ checksum = "036b035e9ebcd705affece16319223d19f229e2358be6e3b7b094e57193312e6"
[[package]] [[package]]
name = "dyld" name = "dyld"
version = "0.0.0" version = "0.1.0"
[[package]] [[package]]
name = "libasync" name = "libasync"

View File

@ -1,7 +1,7 @@
[package] [package]
authors = ["M-Labs"] authors = ["M-Labs"]
name = "dyld" name = "dyld"
version = "0.0.0" version = "0.1.0"
[lib] [lib]
name = "dyld" name = "dyld"

View File

@ -151,7 +151,7 @@ impl<'a> Library<'a> {
Ok(()) Ok(())
} }
fn resolve_rela(&self, rela: &Elf32_Rela, resolve: &Fn(&[u8]) -> Option<Elf32_Word>) fn resolve_rela(&self, rela: &Elf32_Rela, resolve: &dyn Fn(&[u8]) -> Option<Elf32_Word>)
-> Result<(), Error<'a>> { -> Result<(), Error<'a>> {
let sym; let sym;
if ELF32_R_SYM(rela.r_info) == 0 { if ELF32_R_SYM(rela.r_info) == 0 {
@ -195,7 +195,7 @@ impl<'a> Library<'a> {
self.update_rela(rela, value) self.update_rela(rela, value)
} }
pub fn load(data: &[u8], image: &'a mut [u8], resolve: &Fn(&[u8]) -> Option<Elf32_Word>) pub fn load(data: &[u8], image: &'a mut [u8], resolve: &dyn Fn(&[u8]) -> Option<Elf32_Word>)
-> Result<Library<'a>, Error<'a>> { -> Result<Library<'a>, Error<'a>> {
#![allow(unused_assignments)] #![allow(unused_assignments)]
@ -208,13 +208,8 @@ impl<'a> Library<'a> {
/* ABI version */ 0, /* padding */ 0, 0, 0, 0, 0, 0, 0 /* ABI version */ 0, /* padding */ 0, 0, 0, 0, 0, 0, 0
]; ];
#[cfg(target_arch = "or1k")] if ehdr.e_ident != IDENT || ehdr.e_type != ET_DYN || ehdr.e_machine != EM_OPENRISC {
const ARCH: u16 = EM_OPENRISC; return Err("not a shared library for a supported architecture")?
#[cfg(not(target_arch = "or1k"))]
const ARCH: u16 = EM_NONE;
if ehdr.e_ident != IDENT || ehdr.e_type != ET_DYN || ehdr.e_machine != ARCH {
return Err("not a shared library for current architecture")?
} }
let mut dyn_off = None; let mut dyn_off = None;