ld/pdb: Improve PDB symbol processing speed by skipping auxiliary entries
Linker's PDB processing speed improved by skipping auxiliary symbol entries.
This commit optimizes the linker’s PDB (Program Database) handling by skipping auxiliary symbol entries in the handle_debugs_section function. Previously, these entries were treated as symbols, leading to unnecessary lookups and slowdowns, especially in large objects with many sections. By identifying and skipping auxiliary entries, which contain unrelated data in their section number field, link times for PDB-generated files can be reduced by up to 10%.
In Details
This commit optimizes the handle_debugs_section function in ld/pdb.c by correctly handling COFF symbol table entries. Auxiliary symbol entries (indicated by n_numaux > 0) have an n_scnum field that does not correspond to a section number but rather to the number of auxiliary entries. Previously, the code incorrectly treated every entry as a symbol and performed a section lookup based on n_scnum. This led to excessive fallbacks to linear section scans for auxiliary entries, significantly impacting link times for objects with the --pdb option (up to 10% slower for large executables)…
- ld
- The GNU linker, responsible for combining object files and libraries into an executable or another object file.
- PDB
- Program Database, a file format commonly used by Microsoft development tools to store information about libraries and executables, including debugging symbols.
- auxiliary symbol entry
- In some object file formats like COFF, a symbol table entry may be followed by auxiliary entries that provide additional information about the primary symbol. These are not independent symbols.
- link time
- The phase of software development where the linker combines compiled object files and libraries into a final executable program.
- COFF
- Common Object File Format, a standard for object files used on many Unix-like systems.