From 654d65a6d5704530a821a695caf38ef543e1b602 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 25 Jun 2020 02:03:29 +0200 Subject: [PATCH] dyld: keep exidx p_vaddr as it is contained in LOAD sections already should fix Gitea issue #17 --- src/libdyld/src/lib.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libdyld/src/lib.rs b/src/libdyld/src/lib.rs index 785609b..188620d 100644 --- a/src/libdyld/src/lib.rs +++ b/src/libdyld/src/lib.rs @@ -3,7 +3,7 @@ extern crate alloc; extern crate log; -use core::{fmt, str, convert}; +use core::{ops::Range, convert, fmt, str}; use alloc::{borrow::ToOwned, string::String, vec::Vec}; use log::{debug, trace}; use elf::*; @@ -60,7 +60,7 @@ fn elf_hash(name: &[u8]) -> u32 { pub struct Library { pub image: Image, dyn_section: DynamicSection, - pub exidx: Vec, + exidx: Range, } impl Library { @@ -130,6 +130,10 @@ impl Library { Ok(self.strtab().get(offset..offset + size) .ok_or("cannot read symbol name")?) } + + pub fn exidx(&self) -> &[usize] { + self.image.get_ref_slice_unchecked(&self.exidx) + } } pub fn load( @@ -184,9 +188,8 @@ pub fn load( dst.copy_from_slice(src); } PT_ARM_EXIDX => { - let src = file.get(file_range) - .ok_or("program header requests an out of bounds load (in file)")?; - exidx = Some(src.to_owned()); + exidx = Some(phdr.p_vaddr as usize.. + (phdr.p_vaddr + phdr.p_filesz) as usize); } _ => {} }