This is an old revision of the document!


LibElf

This is a BSD-licensed implementation of the elf(3) API.

In the absence of a standard API to read and manipulate ELF objects, many of our tools use adhoc ELF parsers. Such tools include:

  • btxld(8): reads and parses the ELF header when loading files.
  • elfdump(1): displays information about ELF files.
  • gprof(1): reporting tool for cc -pg profiling.
  • kgzip(8): compresses a kernel.
  • pmcstat(8): performance monitoring controller for PMC based profiling.
  • readelf(1): prints information about ELF files.

(In addition to these, file(1) in src/contrib/file/ and the GNU binutils programs in src/contrib/binutils/ also parse ELF files, but aren't likely to benefit from a libelf in the base system.)

Ideally, we would want tools that analyse ELF files to be as machine-independent as possible. This would allow them to be used as cross tools. For example, a cross-tool version of pmcstat would be able to analyse hwpmc logs from an embedded device of a different architecture than the machine that it is running in on.

Also, the availability of an base system ELF parsing library would also geko if and when we create BSD licensed versions of the GNU tools we use, for example, ld(1) or a debugger.

Other program analysis tools like dtrace(1) would also benefit from a base system libelf(3).

The elf(3) API appears to have been developed in SVR4 and is currently in use in Solaris and other SVR4 derived systems. An LGPLed implementation of this API is present in some Linux-based operating systems.

libelf is being developed in FreeBSD's Perforce repository.

P4:[http://perforce.freebsd.org/depotTreeBrowser.cgi?FSPC=//depot/user/jkoshy/projects/libbsdelf //depot/user/jkoshy/projects/libbsdelf]

The P4 source tree will contain sources for the library, sources for an API test suite, and sources for a tutorial.

  • libelf.1149444879.txt.gz
  • Last modified: 2006/06/04 18:14
  • by JosephKoshy