[PATCH v2] ld: Sort section contributions in PDB files
Jan Beulich
jbeulich@suse.com
Mon Feb 27 09:13:53 GMT 2023
On 27.02.2023 01:59, Mark Harmstone wrote:
> @@ -4177,32 +4210,43 @@ create_section_contrib_substream (bfd *abfd, void **data, uint32_t *size)
> {
> for (asection *s = in->sections; s; s = s->next)
> {
> - uint16_t sect_num;
> -
> if (s->size == 0 || discarded_section (s))
> continue;
>
> - sect_num = find_section_number (abfd, s->output_section);
> -
> - memcpy (&sc->characteristics,
> - sect_flags + ((sect_num - 1) * sizeof (uint32_t)),
> - sizeof (uint32_t));
> -
> - bfd_putl16 (sect_num, &sc->section);
> - bfd_putl16 (0, &sc->padding1);
> - bfd_putl32 (s->output_offset, &sc->offset);
> - bfd_putl32 (s->size, &sc->size);
> - bfd_putl16 (mod_index, &sc->module_index);
> - bfd_putl16 (0, &sc->padding2);
> - bfd_putl32 (0, &sc->data_crc);
> - bfd_putl32 (0, &sc->reloc_crc);
> + sc2->s = s;
> + sc2->sect_num = find_section_number (abfd, s->output_section);
> + sc2->mod_index = mod_index;
>
> - sc++;
> + sc2++;
> }
>
> mod_index++;
> }
>
> + qsort (sc_in, num_sc, sizeof (struct in_sc), section_contribs_compare);
You want to apply Nick's requested change here as well, changing
sizeof (struct in_sc) to sizeof (* sc_in). Okay with that adjustment,
assuming ...
> + ptr = *data;
> + sc = (struct section_contribution *) (ptr + 1); /* Skip the version word. */
... you did at least consider Nick's remark regarding this, but
didn't find any good replacement (and Nick's suggestion also didn't
fit).
Jan
More information about the Binutils
mailing list