Giter Site home page Giter Site logo

elfloader's Introduction

Hi there ๐Ÿ‘‹

I'm embedded developer with hardware/software design skills.

Welcome to my personal projects page!

Top Langs

Technologies that I like

C C++ Python Rust LaTeX Git Debian Docker CMake Vim Visual Studio Code

Anurag's GitHub stats

elfloader's People

Contributors

johannestaelman avatar martinribelotta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elfloader's Issues

How to read Text section๏ผŒI can't understand the Elf32_Rel struct!

Hi, Thanks for your code, these days, I have a project to need load the elf file for my arm product, it is base the MTK sdk without MMU.
but when I read your code, somewhere I can't understand. Like this function:

static int relocate(ELFExec_t *e, Elf32_Shdr *h, ELFSection_t *s,
const char *name) {
if (s->data) {
Elf32_Rel rel;
size_t relEntries = h->sh_size / sizeof(rel);
size_t relCount;
(void) LOADER_SEEK_FROM_START(e->fd, h->sh_offset);
DBG(" Offset Info Type Name\n");
//้‡ๅฎšไฝ่Š‚ไธญ็š„ๆ•ฐๆฎ
for (relCount = 0; relCount < relEntries; relCount++) {
if (LOADER_READ(e->fd, &rel, sizeof(rel)) == sizeof(rel)) {
Elf32_Sym sym;
Elf32_Addr symAddr;

    char name[33] = "<unnamed>";
    int symEntry = ELF32_R_SYM(rel.r_info);
    int relType = ELF32_R_TYPE(rel.r_info);
    Elf32_Addr relAddr = ((Elf32_Addr) s->data) + rel.r_offset;

    readSymbol(e, symEntry, &sym, name, sizeof(name));
    DBG(" %08X %08X %-16s %s\n", rel.r_offset, rel.r_info, typeStr(relType),
        name);

    symAddr = addressOf(e, &sym, name);
    if (symAddr != 0xffffffff) {
      DBG("  symAddr=%08X relAddr=%08X\n", symAddr, relAddr);
      if (relocateSymbol(relAddr, relType, symAddr) == -1)
        return -1;
    } else {
      DBG("  No symbol address of %s\n", name);
      return -1;
    }
  }
}
return 0;

} else
MSG("Section not loaded");
return -1;
}

it is like the text. data. bass section is all the same struct with the struct below.
typedef struct
{
Elf32_Addr r_offset;
Elf32_Word r_info;
} Elf32_Rel;
I read my elf file,
image
data like this picture, it is ER_RO section, so ,how I relocate this ? I can't understand this format!
thank you!

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.