Elfy Node.js ELF Parser

1.0.0 · abandoned · verified Sun Apr 19

Elfy is a JavaScript library designed for parsing ELF (Executable and Linkable Format) files within a Node.js environment. Its current and only stable version, 1.0.0, was last published in late 2019, though the underlying code copyright dates back to 2014, indicating a long period without active development or updates. This package provides a simple API, primarily a `parse` method, to interpret the structure and content of ELF binaries. Due to its age and lack of maintenance, its primary differentiator is its historical presence as a Node.js-specific ELF parser. Developers seeking more modern features, broader platform support (like browsers), or active maintenance would likely need to consider alternative solutions, as Elfy predates much of the modern JavaScript ecosystem, including native ESM support.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to use Elfy to parse the Node.js executable currently running, showcasing basic ELF header information.

const elfy = require('elfy');
const fs = require('fs');

// Read the current Node.js executable itself
const nodeExecutableBuffer = fs.readFileSync(process.execPath);

try {
  const elf = elfy.parse(nodeExecutableBuffer);
  console.log('Successfully parsed ELF file:');
  console.log('ELF Magic:', elf.magic ? Buffer.from(elf.magic).toString('hex') : 'N/A');
  console.log('Entry Point:', elf.entry);
  console.log('Program Headers:', elf.ph.length, 'entries');
  console.log('Section Headers:', elf.sh.length, 'entries');
} catch (error) {
  console.error('Error parsing ELF file:', error.message);
  if (error.message.includes('Invalid ELF magic')) {
    console.error('The provided file does not appear to be a valid ELF executable.');
  }
}

view raw JSON →