This is an old revision of the document!
LibElf
This is a BSD-licensed implementation of the elf(3) API.
Rationale
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 forcc -pgprofiling.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
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.
Development
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.
References
- [http://docs.sun.com/app/docs/doc/817-1984 Linker and Libraries Guide] from Sun Microsystems.
- [http://developers.sun.com/solaris/articles/elf.html LibELF tutorial] from Sun Microsystems.
- [http://www.mr511.de/software/english.html LGPL'ed libelf(3) implementation] by Michael Riepe.
- An [http://www.ertos.nicta.com.au/software/kenge/libelf/devel/ ELF library] from the ERTOS project (doesn't implement the
elf(3)API). - [http://tetworks.opengroup.org/tet/ Test Execution Toolkit] from the Open Group.