# elfinfo - Extract info from ELF files Elfinfo shows you some nice stats about your ELF file, useful for microcontroller binaries if you want to keep an eye on how much flash and data you're using. Given this LD script (only significant parts shown, the rest is ignored): MEMORY { flash(r) : ORIGIN = 0x00180000, LENGTH = 32K data(rw) : ORIGIN = 0x00200000, LENGTH = 4K /* Place IDT at the bottom of SRAM, 52 gate wide */ esram_idt (rw) : ORIGIN = 0x00280000, LENGTH = 0x1A0 esram(rw) : ORIGIN = 0x002801A0, LENGTH = 8K - 1K - 0x1A0 stack(rw) : ORIGIN = 0x00281C00, LENGTH = 1K } this is a possible output: Memory areas Name Flags Start End Size Used flash --- 00180000 00188000 32k 28% data --- 00200000 00201000 4k 0% esram_idt --- 00280000 002801a0 416 0% esram --- 002801a0 00281c00 6k 3% stack --- 00281c00 00282000 1k 0% # Building This code currently depend on experimental patches for Antlr4's C++ runtime which has to be build first. This should more or less do it: git clone https://github.com/trygvis/antlr4 cd antlr4/runtime/Cpp mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=$HOME/opt/antlr-cpp .. make make install This will build and install Antlr4 into $HOME/opt/antlr-cpp. To build this code follow a similar approach: mkdir build cmake -DAntlr4_DIR=$HOME/opt/antlr-cpp/lib/cmake/Antlr4 \ -DCMAKE_INSTALL_PREFIX=$HOME/opt/elfinfo \ -DCMAKE_SKIP_RPATH=ON \ .. make make install