Esp32 Elfloader Save

esp32 component to load in ram and relocate elf file

Project README

elfloader module for esp32

This esp32 component is able to load and relocate elf module.

ELF creation

See moduleexample and payloadexamples folders for some examples.

The code must be compiled with -fno-common option and linked with -Wl,-r -nostartfiles -nodefaultlibs -nostdlib options

Usage

Example:

#include "loader.h"


char* data = ... Elf module ...

static const ELFLoaderSymbol_t exports[] = {
    { "puts", (void*) puts },
    { "memcpy", (void*) memcpy },
    { "memmove", (void*) memmove },
    { "strcmp", (void*) strcmp },
    { "strtol", (void*) strtol },
    ...
};
static const ELFLoaderEnv_t env = { exports, sizeof(exports) / sizeof(*exports) };


ELFLoaderContext_t* ctx = elfLoaderInitLoadAndRelocate(data, &env);
if (!ctx) {
    ESP_LOGI(TAG, "elfLoaderInitLoadAndRelocate error");
    return -1;
}
if (elfLoaderSetFunc(ctx, "local_main") != 0) {
    ESP_LOGI(TAG, "elfLoaderSetFunc error: local_main function not fount");
    elfLoaderFree(ctx);
    return -1;
}
ESP_LOGI(TAG, "Running local_main(0x10) function as int local_main(int arg)");
int r = elfLoaderRun(ctx, 0x10);
ESP_LOGI(TAG, "Result: %i", r);
elfLoaderFree(ctx);
return 0;
Open Source Agenda is not affiliated with "Esp32 Elfloader" Project. README Source: niicoooo/esp32-elfloader
Stars
76
Open Issues
2
Last Commit
2 years ago
License

Open Source Agenda Badge

Open Source Agenda Rating