Skip to content

Use u64, even on 32-bit to support reading elf-64 files. #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/elf_sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ impl ElfSection {
str::from_utf8(unsafe { slice::from_raw_parts(name_ptr, strlen) }).unwrap()
}

pub fn start_address(&self) -> usize {
pub fn start_address(&self) -> u64 {
self.get().addr()
}

pub fn end_address(&self) -> usize {
pub fn end_address(&self) -> u64 {
self.get().addr() + self.get().size()
}

pub fn size(&self) -> usize {
pub fn size(&self) -> u64 {
self.get().size()
}

Expand Down Expand Up @@ -198,11 +198,11 @@ trait ElfSectionInner {

fn typ(&self) -> u32;

fn flags(&self) -> u32;
fn flags(&self) -> u64;

fn addr(&self) -> usize;
fn addr(&self) -> u64;

fn size(&self) -> usize;
fn size(&self) -> u64;
}

impl ElfSectionInner for ElfSectionInner32 {
Expand All @@ -214,16 +214,16 @@ impl ElfSectionInner for ElfSectionInner32 {
self.typ
}

fn flags(&self) -> u32 {
self.flags
fn flags(&self) -> u64 {
self.flags.into()
}

fn addr(&self) -> usize {
self.addr as usize
fn addr(&self) -> u64 {
self.addr.into()
}

fn size(&self) -> usize {
self.size as usize
fn size(&self) -> u64 {
self.size.into()
}
}

Expand All @@ -236,16 +236,16 @@ impl ElfSectionInner for ElfSectionInner64 {
self.typ
}

fn flags(&self) -> u32 {
self.flags as u32
fn flags(&self) -> u64 {
self.flags
}

fn addr(&self) -> usize {
self.addr as usize
fn addr(&self) -> u64 {
self.addr
}

fn size(&self) -> usize {
self.size as usize
fn size(&self) -> u64 {
self.size
}
}

Expand All @@ -269,7 +269,7 @@ pub enum ElfSectionType {
}

bitflags! {
pub struct ElfSectionFlags: u32 {
pub struct ElfSectionFlags: u64 {
const WRITABLE = 0x1;
const ALLOCATED = 0x2;
const EXECUTABLE = 0x4;
Expand Down