load elf file

This commit is contained in:
2025-08-01 21:32:35 -06:00
parent 6203392407
commit aa00e9728d
2 changed files with 23 additions and 10 deletions

View File

@@ -23,7 +23,11 @@ use crate::{
}; };
use defmt::unwrap; use defmt::unwrap;
use elf_loader::{Loader, object::ElfBinary}; use elf_loader::{
Loader, load_exec,
mmap::MmapImpl,
object::{ElfBinary, ElfObject},
};
use static_cell::StaticCell; use static_cell::StaticCell;
use talc::*; use talc::*;
@@ -106,14 +110,12 @@ async fn main(_spawner: Spawner) {
// runs dynamically loaded elf files // runs dynamically loaded elf files
#[embassy_executor::task] #[embassy_executor::task]
async fn userland_task() { async fn userland_task() {
// let loader = Loader::new(); let binary_data: &[u8] = include_bytes!("../../example.bin");
let bin = load_exec!("example", binary_data).unwrap();
let entry = bin.entry();
// let binary_data: &[u8] = &[0; 10]; //include_bytes!("example.bin"); let entry_fn: extern "C" fn() = unsafe { core::mem::transmute(entry) };
// let bin = loader.load_exec(binary_data, None).unwrap(); entry_fn(); // jump into user code
// let entry = bin.entry();
// let entry_fn: extern "C" fn() = unsafe { core::mem::transmute(entry) };
// entry_fn(); // jump into user code
} }
struct Display { struct Display {

View File

@@ -1,3 +1,14 @@
fn main() { #![no_std]
println!("Hello, world!"); #![no_main]
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {} // or call your ABI trap, or `abort()`
}
#[unsafe(no_mangle)]
fn main() {
loop {}
} }