ld/pdb: Handle bigobj input files in handle_debugs_section
Fixes linker's PDB debug symbol handling for bigobj COFF files.
The linker’s PDB handling function handle_debugs_section incorrectly assumed a fixed symbol entry size when processing COFF symbol tables. This commit updates it to use bfd_coff_symesz to correctly determine the symbol entry size, accommodating the larger 20-byte entries found in bigobj files, thus preventing incorrect parsing of debug information.
In Details
The handle_debugs_section function in ld/pdb.c iterated over the raw COFF symbol table using sizeof(struct external_syment). This size is 18 bytes for standard COFF, but pe-bigobj files use 20-byte entries. This patch corrects the iteration to use bfd_coff_symesz(mod) which returns the appropriate size for the given BFD, thus handling bigobj files correctly. A test case using -mbig-obj on x86 is added.
- PDB
- Program Database, a file format used by Microsoft for storing debugging and linking information.
- COFF
- Common Object File Format, a standard file format for object files, executable files, and dynamic libraries on Unix-like systems.
- bigobj
- A variant of the COFF format that supports larger object files, particularly by increasing the size of symbol table entries.
- bfd_coff_symesz
- A BFD (Binary File Descriptor) library function that returns the size of a COFF symbol entry for a given BFD context.