refactor loadable to be generic

master
Ales Katona 4 years ago
parent 3b3f834a2f
commit 0b5f013323
Signed by: almindor
GPG Key ID: 2F773149BF38B48F

@ -1,10 +1,12 @@
mod lazy;
mod loadable;
mod output;
mod relocatable;
mod section;
mod symbol;
pub use lazy::*;
pub use loadable::*;
pub use output::*;
pub use relocatable::*;
pub use section::*;

@ -4,8 +4,6 @@ use crate::common::SectionInfo;
use crate::common::{Relocatable, Section};
use crate::error::Error;
use super::ElfObject;
pub enum SegmentType {
Text,
Data,
@ -43,9 +41,9 @@ impl Loadable {
text.chain(rodata).chain(data).chain(bss)
}
pub fn program_bytes<'l>(
pub fn program_bytes<'l, R: Relocatable>(
&'l self,
objects: &'l [ElfObject],
objects: &'l [R],
) -> impl Iterator<Item = Result<&'l [u8], Error>> {
let text_iter = self.text.iter();
let rodata_iter = self.rodata.iter();
@ -62,9 +60,9 @@ impl Loadable {
data1.chain(data2)
}
pub fn data_bytes<'l>(
pub fn data_bytes<'l, R: Relocatable>(
&'l self,
objects: &'l [ElfObject],
objects: &'l [R],
) -> impl Iterator<Item = Result<&'l [u8], Error>> {
let iter = self.data.iter().filter_map(move |si| match si.data_index {
None => None,

@ -6,7 +6,6 @@ use crate::linker::Linker;
mod object;
mod output;
mod loadable;
use elf_utilities::file::ELF64;
pub use object::*;

@ -14,12 +14,8 @@ use elf_utilities::{
segment::{Phdr64, Segment64, Type as SeType, PF_R, PF_W, PF_X},
};
use crate::{
common::{Output, Section},
error::Error,
};
use crate::{common::{Loadable, Output, Section, SegmentType}, error::Error};
use super::loadable::*;
use super::ElfObject;
pub struct ElfOutput {

Loading…
Cancel
Save