From 1d000cc8efeed064d0c01e85d27ca8d310d7dcd4 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 12 Apr 2020 18:45:43 +0800 Subject: [PATCH] libdyld: cleanup --- Cargo.lock | 2 +- libdyld/Cargo.toml | 2 +- libdyld/lib.rs | 13 ++++--------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6852bc3..822a0ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,7 +32,7 @@ checksum = "036b035e9ebcd705affece16319223d19f229e2358be6e3b7b094e57193312e6" [[package]] name = "dyld" -version = "0.0.0" +version = "0.1.0" [[package]] name = "libasync" diff --git a/libdyld/Cargo.toml b/libdyld/Cargo.toml index 64c97c0..c4ea0db 100644 --- a/libdyld/Cargo.toml +++ b/libdyld/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["M-Labs"] name = "dyld" -version = "0.0.0" +version = "0.1.0" [lib] name = "dyld" diff --git a/libdyld/lib.rs b/libdyld/lib.rs index bbf4f59..ae2e338 100644 --- a/libdyld/lib.rs +++ b/libdyld/lib.rs @@ -151,7 +151,7 @@ impl<'a> Library<'a> { Ok(()) } - fn resolve_rela(&self, rela: &Elf32_Rela, resolve: &Fn(&[u8]) -> Option) + fn resolve_rela(&self, rela: &Elf32_Rela, resolve: &dyn Fn(&[u8]) -> Option) -> Result<(), Error<'a>> { let sym; if ELF32_R_SYM(rela.r_info) == 0 { @@ -195,7 +195,7 @@ impl<'a> Library<'a> { self.update_rela(rela, value) } - pub fn load(data: &[u8], image: &'a mut [u8], resolve: &Fn(&[u8]) -> Option) + pub fn load(data: &[u8], image: &'a mut [u8], resolve: &dyn Fn(&[u8]) -> Option) -> Result, Error<'a>> { #![allow(unused_assignments)] @@ -208,13 +208,8 @@ impl<'a> Library<'a> { /* ABI version */ 0, /* padding */ 0, 0, 0, 0, 0, 0, 0 ]; - #[cfg(target_arch = "or1k")] - const ARCH: u16 = EM_OPENRISC; - #[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")? + if ehdr.e_ident != IDENT || ehdr.e_type != ET_DYN || ehdr.e_machine != EM_OPENRISC { + return Err("not a shared library for a supported architecture")? } let mut dyn_off = None;