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 implement adhoc ELF parsers in them. 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.)
Ideally, we would like our tools that analyse ELF files to
be as machine-independent as possible. This would allow them
to be used as cross tools. For example, 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 in-house ELF parsing library would
also help if and when we create BSD licensed versions of ld(1)
or a native debugger or other program analysis tools.
The ELF(3) API
The elf(3) API appears to have been developed in SVR4 and is
currently in use in Solaris. 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]
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 “Tired” Riepe.
- [http://www.ertos.nicta.com.au/software/kenge/libelf/devel/ ELF library from the ERTOS project].