Giter Site home page Giter Site logo

xiej2520 / esp32-elfloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from niicoooo/esp32-elfloader

0.0 0.0 0.0 296 KB

esp32 component to load in ram and relocate elf file

License: GNU General Public License v2.0

Shell 0.08% C 98.21% Makefile 1.70%

esp32-elfloader's Introduction

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;

esp32-elfloader's People

Contributors

niicoooo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.