espmaniac / elf_loader Goto Github PK
View Code? Open in Web Editor NEWSimple elf32 loader.
Simple elf32 loader.
Hi,
I'm trying this library.What a good library you have made!
But I found something wrong.As is said in the title,
I tried the program below,
#include <stdio.h>
#include <stdint.h>
int delay(size_t millsec);
uint32_t local_main(uint32_t arg) {
for(int i=0;i<20;i++){
printf("Hello world!\n");
printf("It works for %i times!\n",i);
delay(3000);
}
return 0;
}
As you can see,I used a external function "delay()",but when I do NOT add an implement to the relocate table,the CPU panic'ed.
The host program is below:
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdio.h>
#include "loader.hpp"
#include "Program.h"
extern "C" void delay(size_t microsec){
TickType_t xDelay = microsec / portTICK_PERIOD_MS;
vTaskDelay(xDelay);
}
extern "C" void app_main() {
ElfLoader test((void*)Program, {
{"puts", (void*) puts},
{ "printf", (void*) printf },
{ "delay",(void*) delay }
});
test.parse();
if(test.relocate()==0){
((void (*) ())test.getEntryPoint())();
}else{
printf("Cannot load ELF file!\n");
}
}
Could anyone help me,please?
Thanks.
Hello. Is it possible to use C++ to create an elf file using classes? All attempts to load the file were unsuccessful.
Hi,
I am trying to pass a multidimensional array to slave program but failed.
The ELF can not be loaded and the serial log is below:
Cannot load ELF file!
assert failed: tlsf_free heap_tlsf.c:872 (!block_is_free(block) && "block already marked as free")
Backtrace:0x4008190a:0x3ffb4f200x400851ad:0x3ffb4f40 0x4008a0cd:0x3ffb4f60 0x40089437:0x3ffb5080 0x40089d36:0x3ffb50a0 0x40081b7a:0x3ffb50c0 0x400d4da8:0x3ffb50e0 0x400d5002:0x3ffb5100 0x400d4d8d:0x3ffb5120 0x400e5b0c:0x3ffb5980 0x40087ac9:0x3ffb59a0
0x4008190a: panic_abort at E:/Espressif/frameworks/esp-idf-v4.4.1/components/esp_system/panic.c:402
0x400851ad: esp_system_abort at E:/Espressif/frameworks/esp-idf-v4.4.1/components/esp_system/esp_system.c:128
0x4008a0cd: __assert_func at E:/Espressif/frameworks/esp-idf-v4.4.1/components/newlib/assert.c:85
0x40089437: tlsf_free at E:/Espressif/frameworks/esp-idf-v4.4.1/components/heap/heap_tlsf.c:872 (discriminator 1)
0x40089d36: multi_heap_free_impl at E:/Espressif/frameworks/esp-idf-v4.4.1/components/heap/multi_heap.c:220
0x40081b7a: heap_caps_free at E:/Espressif/frameworks/esp-idf-v4.4.1/components/heap/heap_caps.c:340
0x400d4da8: ElfLoader::elfLoaderFree() at E:\C++\esp32\template-app\build/../components/ELF-Loader/loader.cpp:109
0x400d5002: ElfLoader::~ElfLoader() at E:\C++\esp32\template-app\build/../components/ELF-Loader/loader.cpp:254
0x400d4d8d: app_main at E:\C++\esp32\template-app\build/../main/main.cpp:16
0x400e5b0c: main_task at E:/Espressif/frameworks/esp-idf-v4.4.1/components/freertos/port/port_common.c:129 (discriminator 2)
0x40087ac9: vPortTaskWrapper at E:/Espressif/frameworks/esp-idf-v4.4.1/components/freertos/port/xtensa/port.c:131
Test code is attached below:
#include <stdio.h>
#include <stdint.h>
void delay(size_t millsec);
int local_main(int argc,char argv[4][512]) {
if(argc <=2){
printf("No arguement!\n");
return -1;
}
for(int i=0;i<20;i++){
for(int j=0;j<argc-1;j++){
printf("Arg[%i]: %s\n",j,argv[j]);
}
printf("\nIt works for %i times!\n\n",i+1);
delay(1000);
}
return 0;
}
#include "Program.h"
#include "loader.hpp"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdio.h>
extern "C" void delay(size_t microsec)
{
TickType_t xDelay = microsec / portTICK_PERIOD_MS;
vTaskDelay(xDelay);
}
extern "C" void app_main()
{
ElfLoader t((void*)Program, { { "puts", (void*)puts }, { "printf", (void*)printf }, { "delay", (void*)delay } });
t.parse();
if (t.relocate() == 0) {
int ret = 0;
char in[4][512] = { "local_main","Hello,World!","",""};
ret = ((int (*)(int c, char v[4][512]))t.getEntryPoint())(2, in);
printf("Program exited with errcode %i\n", ret);
} else {
printf("Cannot load ELF file!\n");
}
}
Note that the issue was found before #1 being solved!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.