gdb provides a mechanism for handling variations in OS ABIs. An OS ABI variant may have influence over any number of variables in the target architecture definition. There are two major components in the OS ABI mechanism: sniffers and handlers.
A sniffer examines a file matching a BFD architecture/flavour pair
(the architecture may be wildcarded) in an attempt to determine the
OS ABI of that file. Sniffers with a wildcarded architecture are considered
to be generic, while sniffers for a specific architecture are
considered to be specific. A match from a specific sniffer
overrides a match from a generic sniffer. Multiple sniffers for an
architecture/flavour may exist, in order to differentiate between two
different operating systems which use the same basic file format. The
OS ABI framework provides a generic sniffer for ELF-format files which
examines the EI_OSABI field of the ELF header, as well as note
sections known to be used by several operating systems.
A handler is used to fine-tune the gdbarch structure for the
selected OS ABI. There may be only one handler for a given OS ABI
for each BFD architecture.
The following OS ABI variants are defined in defs.h:
GDB_OSABI_UNINITIALIZEDGDB_OSABI_UNKNOWNgdbarch
settings for the architecture will be used.
GDB_OSABI_SVR4GDB_OSABI_HURDGDB_OSABI_SOLARISGDB_OSABI_OSF1GDB_OSABI_LINUXGDB_OSABI_FREEBSD_AOUTa.out executable format.
GDB_OSABI_FREEBSD_ELFGDB_OSABI_NETBSD_AOUTa.out executable format.
GDB_OSABI_NETBSD_ELFGDB_OSABI_OPENBSD_ELFGDB_OSABI_WINCEGDB_OSABI_GO32GDB_OSABI_IRIXGDB_OSABI_INTERIXGDB_OSABI_HPUX_ELFGDB_OSABI_HPUX_SOMGDB_OSABI_QNXNTOGDB_OSABI_CYGWINGDB_OSABI_AIXHere are the functions that make up the OS ABI framework:
Return the name of the OS ABI corresponding to osabi.
Register the OS ABI handler specified by init_osabi for the architecture, machine type and OS ABI specified by arch, machine and osabi. In most cases, a value of zero for the machine type, which implies the architecture's default machine type, will suffice.
Register the OS ABI file sniffer specified by sniffer for the BFD architecture/flavour pair specified by arch and flavour. If arch is
bfd_arch_unknown, the sniffer is considered to be generic, and is allowed to examine flavour-flavoured files for any architecture.
Examine the file described by abfd to determine its OS ABI. The value
GDB_OSABI_UNKNOWNis returned if the OS ABI cannot be determined.
Invoke the OS ABI handler corresponding to osabi to fine-tune the
gdbarchstructure specified by gdbarch. If a handler corresponding to osabi has not been registered for gdbarch's architecture, a warning will be issued and the debugging session will continue with the defaults already established for gdbarch.
Helper routine for ELF file sniffers. Examine the file described by abfd and look at ABI tag note sections to determine the OS ABI from the note. This function should be called via
bfd_map_over_sections.