summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..7a189bf
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,25 @@
+mod structs;
+use crate::structs::ElfHeader;
+
+#[repr(C)]
+#[derive(Debug)]
+struct Elf {
+    header: &'static ElfHeader,
+}
+
+impl Elf {
+    pub fn new(bytes: &[u8]) -> Elf {
+        let header = unsafe { &*(bytes.as_ptr() as *const ElfHeader) };
+        assert_eq!(&header.ident.magic, b"\x7fELF");
+        
+        Elf {
+            header
+        }
+    }
+} 
+
+fn main() {
+    let data = include_bytes!("../elf");
+    let elf = Elf::new(&data[..]);
+    println!("{:?}", elf);
+}