|
BDE 4.14.0 Production release
|
Provide platform-dependent object file format trait definitions.
This component defines a set of traits that identify and describe a platform's object file format properties. For example, the balst::ObjectFileFormat::ResolverPolicy trait is ascribed a "value" (i.e., Elf or Xcoff) appropriate for each supported platform. The various stack trace traits are actually types declared in the bdescu_ObjectFileFormat struct. These types are intended to be used in specializing template implementations or to enable function overloading based on the prevalent system's characteristics. #defines are also provided by this component to facilitate conditional compilation depending upon object file formats.
DWARF is a format for detailed debugging information. It is not a complete format, but is used within other formats. It is used within ELF on Linux, but not (yet) on Solaris at Bloomberg (currently the ELF format on Solaris still uses STABS). It is used within the Mach-O format (also known as the Dladdr format in this file) used on Darwin. It is also used by the Clang compiler (which uses ELF).
For all these platforms, parsing the DWARF information is necessary for the stack trace to get source file names and line numbers (the ELF format gives source file names, but only in the case of file-scope static functions).
DWARF is implemented for g++ versions earlier than 7.1.0 on Linux.
Linux g++ 7.1.0 uses DWARF version 4, while g++ 5.4.0 and before use DWARF version 3. At the moment the required system header, dwarf.h, is not available in the Bloomberg production build chroot environment, so support for dwarf formats is disabled.
DWARF support on Clang is problematic and not currrently implemented, see the long comment in balst_resolverimpl_elf.cpp, which explains exactly how it could be implemented when that becomes a priority.
We have not yet investigated implementing DWARF for Dladdr (Darwin).
This section illustrates intended use of this component.
The templated (specialized) typeTest function returns a unique, non-zero value when passed an object of types balst::ObjectFileFormat::{Elf,Xcoff,Windows}, and 0 otherwise.
We define an object policy of type balst::ObjectFileFormat::Policy, which will be of type ...::Elf, ...::Xcoff, or ...::Windows appropriate for the platform.
We now test it using typeTest: