Symbol Sort Sections

Symbol tables can be used to map memory addresses, or symbol names, to their corresponding symbol. These operations are common in debuggers and other observability tools. However, analyzing symbol tables to determine these mappings is complicated by the order in which symbols are written to symbol tables. See Symbol Table Layout and Conventions. This layout complicates looking up symbols in the follows ways.

  • Symbols are not sorted by address, or by name, which forces an expensive linear search of the entire table, or the construction of a more efficient data structure at runtime by each consumer.

  • More than one symbol can refer to a given address. Although these symbols are all valid and correct, the choice of which of these equivalent names to use by a debugging tool might not be obvious. Different tools might use different alternative names. These issues are likely to lead to user confusion.

  • Many symbols provide non-address information. These symbols should not be considered as part of such a search.

Symbol sort sections are used to solve these problems. A symbol sort section is an array of Elf32_Word or Elf64_Word objects. Each element of this array is an index into an associated symbol table. The elements of the array are sorted so that the symbols that are referenced are provided in sorted order. Only symbols representing functions or variables are included. The symbols that are associated with a sort array can be displayed using elfdump(1) with the -S option.