Lots of changes
This commit is contained in:
parent
80d346ae03
commit
f56400d124
|
|
@ -7,3 +7,4 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
iced-x86 = "1.18.0"
|
||||
|
|
|
|||
64
src/elf.rs
64
src/elf.rs
|
|
@ -12,7 +12,7 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub const MAGIC_NUMBER: &[u8] = &[0x7F,0x45,0x4C,0x46];
|
||||
pub const ARCH_OFFSET: u8 = 0x04; // x86 or x64 indiicator; 1 byte
|
||||
pub const ARCH_OFFSET: u8 = 0x04; // x86 or x64 indicator; 1 byte
|
||||
pub const ENDIAN_OFFSET: u8 = 0x05; // Endian offset (1 - little, 2 - big); 1 byte
|
||||
pub const ABI_OFFSET: u8 = 0x07; // ABI identifier; 1 byte
|
||||
pub const TYPE_OFFSET: u8 = 0x10; // Object type identifier; 2 bytes
|
||||
|
|
@ -32,7 +32,7 @@ pub const ENTRYPOINT_OFFSET: u8 = 0x18;
|
|||
pub const PHOFF_OFFSET: [u8; 2] = [0x1C, 0x20]; // Program header table pointer; 2 bytes
|
||||
pub const SHOFF_OFFSET: [u8; 2] = [0x20, 0x28]; // Section table pointer; 2 bytes
|
||||
pub const EHSIZE_OFFSET: [u8; 2] = [0x28, 0x34]; // Program header table entry size pointer; 2 bytes
|
||||
pub const PHENTSIZE_OFFSET: [u8; 2] = [0x28, 0x34]; // Section table pointer; 2 bytes
|
||||
pub const PHENTSIZE_OFFSET: [u8; 2] = [0x2A, 0x36]; // Section table pointer; 2 bytes
|
||||
pub const PHNUM_OFFSET: [u8; 2] = [0x2C, 0x38]; // Program header table number of entries pointer; 2 bytes
|
||||
pub const SHENTSIZE_OFFSET: [u8; 2] = [0x2E, 0x3A]; // Size of section header table; 2 bytes
|
||||
pub const SHNUM_OFFSET: [u8; 2] = [0x30, 0x3C]; // Number of entries in section table pointer; 2 bytes
|
||||
|
|
@ -105,43 +105,45 @@ pub struct FileHeader {
|
|||
pub is_x86_64: bool,
|
||||
pub endian: EndianType,
|
||||
pub abi: u8,
|
||||
pub elf_type: u8,
|
||||
pub isa: u8,
|
||||
pub entryoff: u8,
|
||||
pub phoff: u8,
|
||||
pub shoff: u8,
|
||||
pub ehsize: u8,
|
||||
pub phentsize: u8,
|
||||
pub phnum: u8,
|
||||
pub shentsize: u8,
|
||||
pub shnum: u8,
|
||||
pub shstrndx: u8
|
||||
pub abi_str: String,
|
||||
pub elf_type: u16,
|
||||
pub isa: u16,
|
||||
pub isa_str: String,
|
||||
pub entryoff: u64,
|
||||
pub phoff: u64,
|
||||
pub shoff: u64,
|
||||
pub ehsize: u16,
|
||||
pub phentsize: u16,
|
||||
pub phnum: u16,
|
||||
pub shentsize: u16,
|
||||
pub shnum: u16,
|
||||
pub shstrndx: u16
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ProgramHeader {
|
||||
pub program_type: u8,
|
||||
pub flags: u8,
|
||||
pub offset: u8,
|
||||
pub vaddr: u8,
|
||||
pub paddr: u8,
|
||||
pub filesz: u8,
|
||||
pub memsz: u8,
|
||||
pub align: u8,
|
||||
pub program_type: u32,
|
||||
pub flags: u32,
|
||||
pub offset: u64,
|
||||
pub vaddr: u64,
|
||||
pub paddr: u64,
|
||||
pub filesz: u64,
|
||||
pub memsz: u64,
|
||||
pub align: u64,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SectionHeader {
|
||||
pub name: u8,
|
||||
pub section_type: u8,
|
||||
pub flags: u8,
|
||||
pub addr: u8,
|
||||
pub offset: u8,
|
||||
pub size: u8,
|
||||
pub link: u8,
|
||||
pub info: u8,
|
||||
pub addralign: u8,
|
||||
pub entsize: u8
|
||||
pub name: u32,
|
||||
pub section_type: u32,
|
||||
pub flags: u64,
|
||||
pub addr: u64,
|
||||
pub offset: u64,
|
||||
pub size: u64,
|
||||
pub link: u32,
|
||||
pub info: u32,
|
||||
pub addralign: u64,
|
||||
pub entsize: u64
|
||||
}
|
||||
194
src/main.rs
194
src/main.rs
|
|
@ -4,6 +4,9 @@
|
|||
// Description: Main entrypoint script for chisel. Contains basic procedures
|
||||
// for gathering ELF file and program data.
|
||||
|
||||
use iced_x86::*;
|
||||
use std::collections::HashMap;
|
||||
use std::io::Write;
|
||||
use std::path;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
|
|
@ -43,33 +46,108 @@ fn main() {
|
|||
// Build the File Header data structure
|
||||
let file_header: elf::FileHeader = build_file_header(bytes);
|
||||
|
||||
|
||||
// TODO: This is fundamentally wrong. Using the phentsize and phnum
|
||||
// values from the file header, iterate over the program header
|
||||
// table to find all of the individual program headers. There is
|
||||
// not just one over-arching program header
|
||||
|
||||
// Build Program Header data structure
|
||||
let program_header: elf::ProgramHeader = build_program_header(
|
||||
bytes,
|
||||
file_header.phoff,
|
||||
file_header.is_x86_64
|
||||
);
|
||||
|
||||
|
||||
// TODO: Same thing applies for the Section Headers...
|
||||
|
||||
// Build Section Header data structure
|
||||
let section_header: elf::SectionHeader = build_section_header(
|
||||
bytes,
|
||||
file_header.shoff,
|
||||
file_header.is_x86_64
|
||||
);
|
||||
|
||||
println!("\t- Found {} program header entries {} bytes in length", file_header.phnum, file_header.phentsize);
|
||||
println!("\t- Found {} section header entries {} bytes in length", file_header.shnum, file_header.shentsize);
|
||||
println!("\t- Found .shstrtab section at index {}", file_header.shstrndx);
|
||||
|
||||
println!("{:?}", file_header);
|
||||
println!("{:?}", program_header);
|
||||
println!("{:?}", section_header);
|
||||
|
||||
println!("\nParsing Section Headers...");
|
||||
|
||||
|
||||
// Determine the shstrtab offset.
|
||||
// This is found by taking the string table index and multiplying it by the section header entry size, then
|
||||
// adding this to the initial section header offset.
|
||||
let shstrtab_offset: u64 = file_header.shoff + (file_header.shentsize as u64 * file_header.shstrndx as u64);
|
||||
|
||||
// Build a read-only version of the .shstrtab section
|
||||
let shstrtab_section: elf::SectionHeader = build_section_header(
|
||||
bytes,
|
||||
shstrtab_offset as usize,
|
||||
file_header.is_x86_64
|
||||
);
|
||||
|
||||
let shstrtab_start: u64 = shstrtab_section.offset;
|
||||
let shstrtab_end: u64 = shstrtab_section.offset + shstrtab_section.size;
|
||||
let shstrtab_data: Vec<u8> = bytes[shstrtab_start as usize..shstrtab_end as usize].to_vec();
|
||||
|
||||
println!("\t- Found .shstrtab section");
|
||||
|
||||
|
||||
println!("\n=== Sections ===");
|
||||
|
||||
let mut section_table_map: HashMap<String, elf::SectionHeader> = HashMap::new();
|
||||
let mut section_table_offset: u64 = file_header.shoff;
|
||||
let mut section_table_count: i32 = 0;
|
||||
|
||||
// Build Section Header data structure
|
||||
for _ in 0..file_header.shnum {
|
||||
let section_header: elf::SectionHeader = build_section_header(
|
||||
bytes,
|
||||
section_table_offset as usize,
|
||||
file_header.is_x86_64
|
||||
);
|
||||
|
||||
// Determine the section name for each section using the shstrtab data
|
||||
let section_name: String = util::parse_section_name(&shstrtab_data, section_header.name as usize);
|
||||
|
||||
println!("[{}] {}", section_table_count, section_name);
|
||||
println!("{:?}", section_header);
|
||||
|
||||
section_table_map.insert(section_name, section_header);
|
||||
|
||||
section_table_offset += file_header.shentsize as u64;
|
||||
section_table_count += 1;
|
||||
}
|
||||
|
||||
println!("\nParsing Program Segments...");
|
||||
|
||||
println!("\n=== Program Segments ===");
|
||||
|
||||
let mut program_table_offset = file_header.phoff;
|
||||
let mut program_table_count: i32 = 0;
|
||||
|
||||
// Build Section Header data structure
|
||||
for _ in 0..file_header.phnum {
|
||||
// Build Program Header data structure
|
||||
let program_header: elf::ProgramHeader = build_program_header(
|
||||
bytes,
|
||||
program_table_offset as usize,
|
||||
file_header.is_x86_64
|
||||
);
|
||||
|
||||
// Set a default section name if there's no index found in the table
|
||||
let program_name: String = util::parse_program_segment_type(program_header.program_type);
|
||||
|
||||
println!("[{}] {}", program_table_count, program_name);
|
||||
println!("{:?}", program_header);
|
||||
|
||||
program_table_offset += file_header.phentsize as u64;
|
||||
program_table_count += 1;
|
||||
}
|
||||
|
||||
|
||||
// Now that we have all the sections, spit out the .text section and start a linear disassembly
|
||||
let text_section: &elf::SectionHeader = section_table_map.get(".text").unwrap();
|
||||
let text_section_offset: usize = text_section.offset as usize;
|
||||
let text_section_end: usize = text_section_offset + text_section.size as usize;
|
||||
|
||||
let text_section_buff: &[u8] = &bytes[text_section_offset..text_section_end];
|
||||
|
||||
let mut decoder: Decoder = Decoder::new(64, text_section_buff, DecoderOptions::NONE);
|
||||
let mut instruction: Instruction = Instruction::default();
|
||||
let instruction_start: u64 = 0;
|
||||
let instruction_length: u64 = 1;
|
||||
|
||||
while (instruction_start + instruction_length) < text_section.size {
|
||||
//let instruction_bytes: &[u8] = &text_section_buff[instruction_start..instruction_length];
|
||||
//instruction.
|
||||
//decoder.decode_out(instruction)
|
||||
}
|
||||
|
||||
//let out_file = fs::File::create("out.s").unwrap();
|
||||
//out_file.write()
|
||||
//out_file.flush();
|
||||
|
||||
} else {
|
||||
println!("[Error] Could not find magic number, is this an ELF executable?")
|
||||
|
|
@ -85,7 +163,7 @@ fn main() {
|
|||
|
||||
|
||||
fn build_file_header(data: &Vec<u8>) -> elf::FileHeader {
|
||||
|
||||
|
||||
// Determine x86 or x64 architecture
|
||||
// 0 : x86
|
||||
// 1 : x64
|
||||
|
|
@ -96,24 +174,26 @@ fn build_file_header(data: &Vec<u8>) -> elf::FileHeader {
|
|||
is_x86_64: arch != 0,
|
||||
endian: util::parse_endian(data[elf::ENDIAN_OFFSET as usize]),
|
||||
abi: data[elf::ABI_OFFSET as usize],
|
||||
elf_type: data[elf::TYPE_OFFSET as usize],
|
||||
isa: data[elf::MACHINE_OFFSET as usize],
|
||||
entryoff: data[elf::ENTRYPOINT_OFFSET as usize],
|
||||
phoff: data[elf::PHOFF_OFFSET[arch] as usize],
|
||||
shoff: data[elf::SHOFF_OFFSET[arch] as usize],
|
||||
ehsize: data[elf::EHSIZE_OFFSET[arch] as usize],
|
||||
phentsize: data[elf::PHENTSIZE_OFFSET[arch] as usize],
|
||||
phnum: data[elf::PHNUM_OFFSET[arch] as usize],
|
||||
shentsize: data[elf::SHENTSIZE_OFFSET[arch] as usize],
|
||||
shnum: data[elf::SHNUM_OFFSET[arch] as usize],
|
||||
shstrndx: data[elf::SHSTRNDX_OFFSET[arch] as usize],
|
||||
abi_str: util::parse_abi(data[elf::ABI_OFFSET as usize]),
|
||||
elf_type: util::u16_from_buffer(data, elf::TYPE_OFFSET as usize),
|
||||
isa: util::u16_from_buffer(data, elf::MACHINE_OFFSET as usize),
|
||||
isa_str: util::parse_isa(util::u16_from_buffer(data, elf::MACHINE_OFFSET as usize)),
|
||||
entryoff: util::u64_from_buffer(data, elf::ENTRYPOINT_OFFSET as usize),
|
||||
phoff: util::u64_from_buffer(data, elf::PHOFF_OFFSET[arch] as usize),
|
||||
shoff: util::u64_from_buffer(data, elf::SHOFF_OFFSET[arch] as usize),
|
||||
ehsize: util::u16_from_buffer(data, elf::EHSIZE_OFFSET[arch] as usize),
|
||||
phentsize: util::u16_from_buffer(data, elf::PHENTSIZE_OFFSET[arch] as usize),
|
||||
phnum: util::u16_from_buffer(data, elf::PHNUM_OFFSET[arch] as usize),
|
||||
shentsize: util::u16_from_buffer(data, elf::SHENTSIZE_OFFSET[arch] as usize),
|
||||
shnum: util::u16_from_buffer(data, elf::SHNUM_OFFSET[arch] as usize),
|
||||
shstrndx: util::u16_from_buffer(data, elf::SHSTRNDX_OFFSET[arch] as usize),
|
||||
};
|
||||
|
||||
return file_header;
|
||||
}
|
||||
|
||||
|
||||
fn build_program_header(data: &Vec<u8>, phoffset: u8, is_x86_64: bool) -> elf::ProgramHeader {
|
||||
fn build_program_header(data: &Vec<u8>, phoffset: usize, is_x86_64: bool) -> elf::ProgramHeader {
|
||||
|
||||
// Cast the supplied is_x86_64 bool to an array offset
|
||||
// 0 : x86
|
||||
|
|
@ -121,21 +201,21 @@ fn build_program_header(data: &Vec<u8>, phoffset: u8, is_x86_64: bool) -> elf::P
|
|||
let arch: usize = is_x86_64.into();
|
||||
|
||||
let program_header: elf::ProgramHeader = elf::ProgramHeader {
|
||||
program_type: data[(elf::PH_TYPE_OFFSET + phoffset) as usize],
|
||||
flags: data[(elf::PH_FLAGS_OFFSET[arch] + phoffset) as usize],
|
||||
offset: data[(elf::PH_OFFSET_OFFSET[arch] + phoffset) as usize],
|
||||
vaddr: data[(elf::PH_VADDR_OFFSET[arch] + phoffset) as usize],
|
||||
paddr: data[(elf::PH_PADDR_OFFSET[arch] + phoffset) as usize],
|
||||
filesz: data[(elf::PH_FILESZ_OFFSET[arch] + phoffset) as usize],
|
||||
memsz: data[(elf::PH_MEMSZ_OFFSET[arch] + phoffset) as usize],
|
||||
align: data[(elf::PH_ALIGN_OFFSET[arch] + phoffset) as usize],
|
||||
program_type: util::u32_from_buffer(data, phoffset + elf::PH_TYPE_OFFSET as usize),
|
||||
flags: util::u32_from_buffer(data, phoffset + elf::PH_FLAGS_OFFSET[arch] as usize),
|
||||
offset: util::u64_from_buffer(data, phoffset + elf::PH_OFFSET_OFFSET[arch] as usize),
|
||||
vaddr: util::u64_from_buffer(data, phoffset + elf::PH_VADDR_OFFSET[arch] as usize),
|
||||
paddr: util::u64_from_buffer(data, phoffset + elf::PH_PADDR_OFFSET[arch] as usize),
|
||||
filesz: util::u64_from_buffer(data, phoffset + elf::PH_FILESZ_OFFSET[arch] as usize),
|
||||
memsz: util::u64_from_buffer(data, phoffset + elf::PH_MEMSZ_OFFSET[arch] as usize),
|
||||
align: util::u64_from_buffer(data, phoffset + elf::PH_ALIGN_OFFSET[arch] as usize)
|
||||
};
|
||||
|
||||
return program_header;
|
||||
}
|
||||
|
||||
|
||||
fn build_section_header(data: &Vec<u8>, shoffset: u8, is_x86_64: bool) -> elf::SectionHeader {
|
||||
fn build_section_header(data: &Vec<u8>, shoffset: usize, is_x86_64: bool) -> elf::SectionHeader {
|
||||
|
||||
// Cast the supplied is_x86_64 bool to an array offset
|
||||
// 0 : x86
|
||||
|
|
@ -143,16 +223,16 @@ fn build_section_header(data: &Vec<u8>, shoffset: u8, is_x86_64: bool) -> elf::S
|
|||
let arch: usize = is_x86_64.into();
|
||||
|
||||
let section_header: elf::SectionHeader = elf::SectionHeader {
|
||||
name: data[(elf::SH_NAME_OFFSET + shoffset) as usize],
|
||||
section_type: data[(elf::SH_TYPE_OFFSET + shoffset) as usize],
|
||||
flags: data[(elf::SH_FLAGS_OFFSET + shoffset) as usize],
|
||||
addr: data[(elf::SH_ADDR_OFFSET[arch] + shoffset) as usize],
|
||||
offset: data[(elf::SH_OFFSET_OFFSET[arch] + shoffset) as usize],
|
||||
size: data[(elf::SH_SIZE_OFFSET[arch] + shoffset) as usize],
|
||||
link: data[(elf::SH_LINK_OFFSET[arch] + shoffset) as usize],
|
||||
info: data[(elf::SH_INFO_OFFSET[arch] + shoffset) as usize],
|
||||
addralign: data[(elf::SH_ADDRALIGN_OFFSET[arch] + shoffset) as usize],
|
||||
entsize: data[(elf::SH_ENTSIZE_OFFSET[arch] + shoffset) as usize],
|
||||
name: util::u32_from_buffer(data, shoffset + elf::SH_NAME_OFFSET as usize),
|
||||
section_type: util::u32_from_buffer(data, shoffset + elf::SH_TYPE_OFFSET as usize),
|
||||
flags: util::u64_from_buffer(data, shoffset + elf::SH_FLAGS_OFFSET as usize),
|
||||
addr: util::u64_from_buffer(data, shoffset + elf::SH_ADDR_OFFSET[arch] as usize),
|
||||
offset: util::u64_from_buffer(data, shoffset + elf::SH_OFFSET_OFFSET[arch] as usize),
|
||||
size: util::u64_from_buffer(data, shoffset + elf::SH_SIZE_OFFSET[arch] as usize),
|
||||
link: util::u32_from_buffer(data, shoffset + elf::SH_LINK_OFFSET[arch] as usize),
|
||||
info: util::u32_from_buffer(data, shoffset + elf::SH_INFO_OFFSET[arch] as usize),
|
||||
addralign: util::u64_from_buffer(data, shoffset + elf::SH_ADDRALIGN_OFFSET[arch] as usize),
|
||||
entsize: util::u64_from_buffer(data, shoffset + elf::SH_ENTSIZE_OFFSET[arch] as usize)
|
||||
};
|
||||
|
||||
return section_header;
|
||||
|
|
|
|||
78
src/util.rs
78
src/util.rs
|
|
@ -4,6 +4,8 @@
|
|||
// Description: Utility script for storing common-use and helper
|
||||
// functions.
|
||||
|
||||
use std::mem;
|
||||
|
||||
use crate::elf::{self, EndianType, ArchitectureType};
|
||||
|
||||
|
||||
|
|
@ -45,7 +47,7 @@ pub fn parse_abi(abi: u8) -> String {
|
|||
}
|
||||
|
||||
|
||||
pub fn parse_isa(isa: u8) -> String {
|
||||
pub fn parse_isa(isa: u16) -> String {
|
||||
match isa {
|
||||
0x03 => "Intel x86".to_string(),
|
||||
0x3E => "AMD x86-64".to_string(),
|
||||
|
|
@ -56,9 +58,83 @@ pub fn parse_isa(isa: u8) -> String {
|
|||
0x32 => "IA_64".to_string(),
|
||||
0x28 => "Arm".to_string(),
|
||||
0xB7 => "Arm 64-bit".to_string(),
|
||||
0xF3 => "RISC-V".to_string(),
|
||||
|
||||
// Match unknown ISA
|
||||
_ => "Unknown".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn u16_from_buffer(buff: &Vec<u8>, index: usize) -> u16 {
|
||||
const SIZE: usize = mem::size_of::<u16>();
|
||||
|
||||
let mut slice: [u8; SIZE] = [0; SIZE];
|
||||
slice.copy_from_slice(&buff[index..index+SIZE]);
|
||||
|
||||
let value: u16 = u16::from_ne_bytes(slice);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
pub fn u32_from_buffer(buff: &Vec<u8>, index: usize) -> u32 {
|
||||
const SIZE: usize = mem::size_of::<u32>();
|
||||
|
||||
let mut slice: [u8; SIZE] = [0; SIZE];
|
||||
slice.copy_from_slice(&buff[index..index+SIZE]);
|
||||
|
||||
let value: u32 = u32::from_ne_bytes(slice);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
pub fn u64_from_buffer(buff: &Vec<u8>, index: usize) -> u64 {
|
||||
const SIZE: usize = mem::size_of::<u64>();
|
||||
|
||||
let mut slice: [u8; SIZE] = [0; SIZE];
|
||||
slice.copy_from_slice(&buff[index..index+SIZE]);
|
||||
|
||||
let value: u64 = u64::from_ne_bytes(slice);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
pub fn parse_section_name(buff: &Vec<u8>, index: usize) -> String {
|
||||
let mut name: Vec<u8> = Vec::new();
|
||||
let mut char_ctr: usize = index;
|
||||
let mut char: u8 = buff[index];
|
||||
|
||||
while char != 0x00 {
|
||||
name.push(char);
|
||||
char_ctr += 1;
|
||||
char = buff[char_ctr];
|
||||
}
|
||||
|
||||
let result = String::from_utf8(name).expect("Failed to parse section name!");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
pub fn parse_program_segment_type(segment_type: u32) -> String {
|
||||
match segment_type {
|
||||
0x00000000 => "PT_NULL".to_string(),
|
||||
0x00000001 => "PT_LOAD".to_string(),
|
||||
0x00000002 => "PT_DYNAMIC".to_string(),
|
||||
0x00000003 => "PT_INTERP".to_string(),
|
||||
0x00000004 => "PT_NOTE".to_string(),
|
||||
0x00000005 => "PT_SHLIB".to_string(),
|
||||
0x00000006 => "PT_PHDR".to_string(),
|
||||
0x00000007 => "PT_TLS".to_string(),
|
||||
0x60000000 => "PT_LOOS".to_string(),
|
||||
0x6FFFFFFF => "PT_HIOS".to_string(),
|
||||
0x70000000 => "PT_LOPROC".to_string(),
|
||||
0x7FFFFFFF => "PT_HIPROC".to_string(),
|
||||
|
||||
// Match unknown segment type
|
||||
_ => "UNKNOWN".to_string()
|
||||
}
|
||||
}
|
||||
104
test_run
Normal file
104
test_run
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
File exists, reading 'testing/hello'...
|
||||
Found ELF Magic Number...
|
||||
Parsing File Header...
|
||||
- Found 13 program header entries 56 bytes in length
|
||||
- Found 31 section header entries 64 bytes in length
|
||||
- Found .shstrtab section at index 30
|
||||
FileHeader { arch: X86_64, is_x86_64: true, endian: Little, abi: 0, abi_str: "SystemV", elf_type: 3, isa: 62, isa_str: "AMD x86-64", entryoff: 4192, phoff: 64, shoff: 13976, ehsize: 64, phentsize: 56, phnum: 13, shentsize: 64, shnum: 31, shstrndx: 30 }
|
||||
|
||||
Parsing Section Headers...
|
||||
- Found .shstrtab section
|
||||
|
||||
=== Sections ===
|
||||
[0]
|
||||
SectionHeader { name: 0, section_type: 0, flags: 0, addr: 0, offset: 0, size: 0, link: 0, info: 0, addralign: 0, entsize: 0 }
|
||||
[1] .interp
|
||||
SectionHeader { name: 27, section_type: 1, flags: 2, addr: 792, offset: 792, size: 28, link: 0, info: 0, addralign: 1, entsize: 0 }
|
||||
[2] .note.gnu.property
|
||||
SectionHeader { name: 35, section_type: 7, flags: 2, addr: 824, offset: 824, size: 48, link: 0, info: 0, addralign: 8, entsize: 0 }
|
||||
[3] .note.gnu.build-id
|
||||
SectionHeader { name: 54, section_type: 7, flags: 2, addr: 872, offset: 872, size: 36, link: 0, info: 0, addralign: 4, entsize: 0 }
|
||||
[4] .note.ABI-tag
|
||||
SectionHeader { name: 73, section_type: 7, flags: 2, addr: 908, offset: 908, size: 32, link: 0, info: 0, addralign: 4, entsize: 0 }
|
||||
[5] .gnu.hash
|
||||
SectionHeader { name: 87, section_type: 1879048182, flags: 2, addr: 944, offset: 944, size: 36, link: 6, info: 0, addralign: 8, entsize: 0 }
|
||||
[6] .dynsym
|
||||
SectionHeader { name: 97, section_type: 11, flags: 2, addr: 984, offset: 984, size: 168, link: 7, info: 1, addralign: 8, entsize: 24 }
|
||||
[7] .dynstr
|
||||
SectionHeader { name: 105, section_type: 3, flags: 2, addr: 1152, offset: 1152, size: 143, link: 0, info: 0, addralign: 1, entsize: 0 }
|
||||
[8] .gnu.version
|
||||
SectionHeader { name: 113, section_type: 1879048191, flags: 2, addr: 1296, offset: 1296, size: 14, link: 6, info: 0, addralign: 2, entsize: 2 }
|
||||
[9] .gnu.version_r
|
||||
SectionHeader { name: 126, section_type: 1879048190, flags: 2, addr: 1312, offset: 1312, size: 48, link: 7, info: 1, addralign: 8, entsize: 0 }
|
||||
[10] .rela.dyn
|
||||
SectionHeader { name: 141, section_type: 4, flags: 2, addr: 1360, offset: 1360, size: 192, link: 6, info: 0, addralign: 8, entsize: 24 }
|
||||
[11] .rela.plt
|
||||
SectionHeader { name: 151, section_type: 4, flags: 66, addr: 1552, offset: 1552, size: 24, link: 6, info: 24, addralign: 8, entsize: 24 }
|
||||
[12] .init
|
||||
SectionHeader { name: 161, section_type: 1, flags: 6, addr: 4096, offset: 4096, size: 27, link: 0, info: 0, addralign: 4, entsize: 0 }
|
||||
[13] .plt
|
||||
SectionHeader { name: 156, section_type: 1, flags: 6, addr: 4128, offset: 4128, size: 32, link: 0, info: 0, addralign: 16, entsize: 16 }
|
||||
[14] .plt.got
|
||||
SectionHeader { name: 167, section_type: 1, flags: 6, addr: 4160, offset: 4160, size: 16, link: 0, info: 0, addralign: 16, entsize: 16 }
|
||||
[15] .plt.sec
|
||||
SectionHeader { name: 176, section_type: 1, flags: 6, addr: 4176, offset: 4176, size: 16, link: 0, info: 0, addralign: 16, entsize: 16 }
|
||||
[16] .text
|
||||
SectionHeader { name: 185, section_type: 1, flags: 6, addr: 4192, offset: 4192, size: 268, link: 0, info: 0, addralign: 16, entsize: 0 }
|
||||
[17] .fini
|
||||
SectionHeader { name: 191, section_type: 1, flags: 6, addr: 4460, offset: 4460, size: 13, link: 0, info: 0, addralign: 4, entsize: 0 }
|
||||
[18] .rodata
|
||||
SectionHeader { name: 197, section_type: 1, flags: 2, addr: 8192, offset: 8192, size: 18, link: 0, info: 0, addralign: 4, entsize: 0 }
|
||||
[19] .eh_frame_hdr
|
||||
SectionHeader { name: 205, section_type: 1, flags: 2, addr: 8212, offset: 8212, size: 52, link: 0, info: 0, addralign: 4, entsize: 0 }
|
||||
[20] .eh_frame
|
||||
SectionHeader { name: 219, section_type: 1, flags: 2, addr: 8264, offset: 8264, size: 172, link: 0, info: 0, addralign: 8, entsize: 0 }
|
||||
[21] .init_array
|
||||
SectionHeader { name: 229, section_type: 14, flags: 3, addr: 15800, offset: 11704, size: 8, link: 0, info: 0, addralign: 8, entsize: 8 }
|
||||
[22] .fini_array
|
||||
SectionHeader { name: 241, section_type: 15, flags: 3, addr: 15808, offset: 11712, size: 8, link: 0, info: 0, addralign: 8, entsize: 8 }
|
||||
[23] .dynamic
|
||||
SectionHeader { name: 253, section_type: 6, flags: 3, addr: 15816, offset: 11720, size: 496, link: 7, info: 0, addralign: 8, entsize: 16 }
|
||||
[24] .got
|
||||
SectionHeader { name: 171, section_type: 1, flags: 3, addr: 16312, offset: 12216, size: 72, link: 0, info: 0, addralign: 8, entsize: 8 }
|
||||
[25] .data
|
||||
SectionHeader { name: 262, section_type: 1, flags: 3, addr: 16384, offset: 12288, size: 16, link: 0, info: 0, addralign: 8, entsize: 0 }
|
||||
[26] .bss
|
||||
SectionHeader { name: 268, section_type: 8, flags: 3, addr: 16400, offset: 12304, size: 8, link: 0, info: 0, addralign: 1, entsize: 0 }
|
||||
[27] .comment
|
||||
SectionHeader { name: 273, section_type: 1, flags: 48, addr: 0, offset: 12304, size: 43, link: 0, info: 0, addralign: 1, entsize: 1 }
|
||||
[28] .symtab
|
||||
SectionHeader { name: 1, section_type: 2, flags: 0, addr: 0, offset: 12352, size: 864, link: 29, info: 18, addralign: 8, entsize: 24 }
|
||||
[29] .strtab
|
||||
SectionHeader { name: 9, section_type: 3, flags: 0, addr: 0, offset: 13216, size: 477, link: 0, info: 0, addralign: 1, entsize: 0 }
|
||||
[30] .shstrtab
|
||||
SectionHeader { name: 17, section_type: 3, flags: 0, addr: 0, offset: 13693, size: 282, link: 0, info: 0, addralign: 1, entsize: 0 }
|
||||
|
||||
Parsing Program Segments...
|
||||
|
||||
=== Program Segments ===
|
||||
[0] PT_PHDR
|
||||
ProgramHeader { program_type: 6, flags: 4, offset: 64, vaddr: 64, paddr: 64, filesz: 728, memsz: 728, align: 8 }
|
||||
[1] PT_INTERP
|
||||
ProgramHeader { program_type: 3, flags: 4, offset: 792, vaddr: 792, paddr: 792, filesz: 28, memsz: 28, align: 1 }
|
||||
[2] PT_LOAD
|
||||
ProgramHeader { program_type: 1, flags: 4, offset: 0, vaddr: 0, paddr: 0, filesz: 1576, memsz: 1576, align: 4096 }
|
||||
[3] PT_LOAD
|
||||
ProgramHeader { program_type: 1, flags: 5, offset: 4096, vaddr: 4096, paddr: 4096, filesz: 377, memsz: 377, align: 4096 }
|
||||
[4] PT_LOAD
|
||||
ProgramHeader { program_type: 1, flags: 4, offset: 8192, vaddr: 8192, paddr: 8192, filesz: 244, memsz: 244, align: 4096 }
|
||||
[5] PT_LOAD
|
||||
ProgramHeader { program_type: 1, flags: 6, offset: 11704, vaddr: 15800, paddr: 15800, filesz: 600, memsz: 608, align: 4096 }
|
||||
[6] PT_DYNAMIC
|
||||
ProgramHeader { program_type: 2, flags: 6, offset: 11720, vaddr: 15816, paddr: 15816, filesz: 496, memsz: 496, align: 8 }
|
||||
[7] PT_NOTE
|
||||
ProgramHeader { program_type: 4, flags: 4, offset: 824, vaddr: 824, paddr: 824, filesz: 48, memsz: 48, align: 8 }
|
||||
[8] PT_NOTE
|
||||
ProgramHeader { program_type: 4, flags: 4, offset: 872, vaddr: 872, paddr: 872, filesz: 68, memsz: 68, align: 4 }
|
||||
[9] UNKNOWN
|
||||
ProgramHeader { program_type: 1685382483, flags: 4, offset: 824, vaddr: 824, paddr: 824, filesz: 48, memsz: 48, align: 8 }
|
||||
[10] UNKNOWN
|
||||
ProgramHeader { program_type: 1685382480, flags: 4, offset: 8212, vaddr: 8212, paddr: 8212, filesz: 52, memsz: 52, align: 4 }
|
||||
[11] UNKNOWN
|
||||
ProgramHeader { program_type: 1685382481, flags: 6, offset: 0, vaddr: 0, paddr: 0, filesz: 0, memsz: 0, align: 16 }
|
||||
[12] UNKNOWN
|
||||
ProgramHeader { program_type: 1685382482, flags: 4, offset: 11704, vaddr: 15800, paddr: 15800, filesz: 584, memsz: 584, align: 1 }
|
||||
9
test_run32
Normal file
9
test_run32
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
File exists, reading 'testing/hello32'...
|
||||
Found ELF Magic Number...
|
||||
Parsing File Header...
|
||||
- Found 11 program header entries 32 bytes in length
|
||||
- Found 29 section header entries 40 bytes in length
|
||||
- Found .shstrtab section at index 28
|
||||
FileHeader { arch: X86, is_x86_64: false, endian: Little, abi: 0, abi_str: "SystemV", elf_type: 3, isa: 3, isa_str: "Intel x86", entryoff: 223338303600, phoff: 59184649338932, shoff: 13780, ehsize: 52, phentsize: 32, phnum: 11, shentsize: 40, shnum: 29, shstrndx: 28 }
|
||||
|
||||
Parsing Section Headers...
|
||||
Loading…
Reference in New Issue
Block a user