qsort: elf_sort_sections use of target_index
authorAlan Modra <amodra@gmail.com>
Mon, 14 Oct 2019 03:20:48 +0000 (13:50 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 14 Oct 2019 06:17:13 +0000 (16:47 +1030)
commit48db3297342d798e58a00771a67b9b4c93412920
tree610c95421aade3fa9371ccb796f8b99d83e56077
parent8c1c5e5de46f415bbdeabb3cad3fd1383f5fb995
qsort: elf_sort_sections use of target_index

elf_sort_sections tried to ensure a stable qsort by using target_index
as the final comparison, but target_index hasn't been set by anything
at the time elf_sort_sections was run.  This patch arrange to have
target_index set.

* elf.c (_bfd_elf_map_sections_to_segments): Init target_index
for sections about to be sorted.
(assign_file_positions_for_load_sections): Likewise.
(elf_sort_sections): Don't bother optimising both TOEND case.
* elflink.c (bfd_elf_final_link): Reset target_index.
bfd/ChangeLog
bfd/elf.c
bfd/elflink.c