Libelf port for JavaScript, a library to access ELF objects.
To add Libelf.js to your web application, include it with:
<script src="libelf.min.js"></script>
or install it with the Bower command:
bower install libelf
// var buffer = new Uint8Array([0x7F, 0x45, 0x4C, 0x46, ...]);
var elf = new Elf(buffer);
if (elf.kind() != "elf") {
throw "Not an ELF file";
}
var ehdr = elf.getehdr();
// Handle segments
for (var i = 0; i < ehdr.phnum; i++) {
var phdr = elf.getphdr(i);
}
// Handle sections
for (var i = 0; i < ehdr.shnum; i++) {
var scn = elf.getscn(i);
var shdr = elf.getshdr(scn);
var name = elf.strptr(
ehdr.e_shstrndx.num(),
shdr.sh_name.num());
To build the Libelf.js library, clone the master branch of this repository, and do the following:
-
Install the latest Python 3.8+, CMake and the Emscripten SDK 2.0.21+. Follow the respective instructions and make sure all environment variables are configured correctly. Under Windows MinGW (specifically mingw32-make) is required.
-
Install the development dependencies with:
npm install --also=dev
. -
Install grunt with:
npm install -g grunt
-
Finally, build the source with:
grunt build
.