Skip to content

Reads an .elf file, disassembles the '.text' section and decodes the '.debug_line' section.

License

Notifications You must be signed in to change notification settings

GrandChris/elf_analysis

Repository files navigation

elf_analysis Build Actions Status

Reads an .elf file and parses the .text and .debug_line sections. It assigns every instruction a source file and a line number. The data is provided through a C interface. The source code is compiled to WebAssembly using Emscripten to be used in the VS-Code extension Elf Lens.

Features

What it does

  • Parses an .elf file using elfio
  • Disassembles the '.text' section using capstone
  • Decodes the '.debug_line' section using a diy implementation
  • Provides a C interface to access the data

Development environment

  • Uses VSCode Remote-Containers for development
  • Uses the same Docker container to build the project with Github Actions
  • Dependencies (elfio and capstone) are fetched during CMake configure with FetchContent
  • The source code is compiled using GCC 10
  • The source code is compiled using Emscripten

Limitations

  • It is designed to work with a small codebase (for embedded development)
  • It supports only 'ARM Thumb Code' for the '.text' section and 'Dwarf 3' debug information (standard when building with GCC) in the '.debug_line' section
  • It also has a limited support for 'x86-64' code (no guarantees here)

How to build

GCC

# assuming CMake, Ninja and GCC 10 is installed
cmake -G Ninja -S . -B ./build
cmake --build ./build

Emscripten

# assuming CMake, Ninja, LLVM and Emscripten is installed
cmake -G Ninja -S . -B ./build -DCMAKE_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake 
cmake --build ./build

You can also use the VS-Code extension Remote-Containers and run the predefined Tasks to build this project.
Note that building this project was only tested with Ubuntu Groovy so far.

About

Reads an .elf file, disassembles the '.text' section and decodes the '.debug_line' section.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published