ld/pdb: Skip auxiliary symbol entries in handle_debugs_section

Message ID 20261102225947.1725-4-oleg.tolmatcev@gmail.com
State New
Headers
Series ld/pdb: Skip auxiliary symbol entries in handle_debugs_section |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Oleg Tolmatcev Nov. 2, 2026, 10:59 p.m. UTC
  handle_debugs_section treated every raw symbol table entry, including
auxiliary entries, as a symbol and looked up a section for its n_scnum.
In auxiliary entries that field holds unrelated data, so the lookup
often missed and fell back to a linear scan over all sections.  With
objects containing thousands of sections this took about 10% of the
link time for a large executable with --pdb.

ld/
	* pdb.c (handle_debugs_section): Skip auxiliary symbol entries.
---
 ld/pdb.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Jan Beulich Nov. 6, 2026, 9:28 a.m. UTC | #1
On 02.11.2026 23:59, Oleg Tolmatcev wrote:
> handle_debugs_section treated every raw symbol table entry, including
> auxiliary entries, as a symbol and looked up a section for its n_scnum.
> In auxiliary entries that field holds unrelated data, so the lookup
> often missed and fell back to a linear scan over all sections.  With
> objects containing thousands of sections this took about 10% of the
> link time for a large executable with --pdb.
> 
> ld/
> 	* pdb.c (handle_debugs_section): Skip auxiliary symbol entries.

Okay, with one nit:

> --- a/ld/pdb.c
> +++ b/ld/pdb.c
> @@ -1956,6 +1956,7 @@ handle_debugs_section (asection *s, bfd *mod, struct string_table *strings,
>  	  bfd_coff_swap_sym_in (mod, &ext[i], &symbols[i]);
>  	  if (symbols[i].n_scnum > 0)
>  	    sectlist[i] = coff_section_from_bfd_index (mod, symbols[i].n_scnum);
> +	  i += symbols[i].n_numaux;
>  	}

As we're adding more stuff there, separating blank lines will become
helpful. I'll add one in patch 1 and another one here.

Jan
  

Patch

diff --git a/ld/pdb.c b/ld/pdb.c
index b940c509de1..29c58306b4a 100644
--- a/ld/pdb.c
+++ b/ld/pdb.c
@@ -1956,6 +1956,7 @@  handle_debugs_section (asection *s, bfd *mod, struct string_table *strings,
 	  bfd_coff_swap_sym_in (mod, &ext[i], &symbols[i]);
 	  if (symbols[i].n_scnum > 0)
 	    sectlist[i] = coff_section_from_bfd_index (mod, symbols[i].n_scnum);
+	  i += symbols[i].n_numaux;
 	}
 
       if (!bfd_coff_relocate_section (abfd, coff_data (abfd)->link_info, mod,