PR26907, segment contains empty SHT_NOBITS section
authorAlan Modra <amodra@gmail.com>
Fri, 27 Nov 2020 22:15:02 +0000 (08:45 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 28 Nov 2020 08:01:32 +0000 (18:31 +1030)
commit8d748d1dc56406228c2c76de2563859213364cbf
tree46df0c063155a202e2d84c698042b8df29f9ccf2
parented5e05a2cf20d3eb473966c17e4c5b57889a9093
PR26907, segment contains empty SHT_NOBITS section

Section ordering is important for _bfd_elf_map_sections_to_segments
and assign_file_positions_for_load_sections, which are only prepared
to handle sections in increasing LMA order.  When zero size sections
are involved it is possible to have multiple sections at the same LMA.
In that case the zero size sections must sort before any non-zero size
sections regardless of their types.

bfd/
PR 26907
* elf.c (elf_sort_sections): Don't sort zero size !load sections
after load sections.
ld/
* testsuite/ld-elf/pr26907.ld,
* testsuite/ld-elf/pr26907.s,
* testsuite/ld-elf/pr26907.d: New test.
bfd/ChangeLog
bfd/elf.c
ld/ChangeLog
ld/testsuite/ld-elf/pr26907.d [new file with mode: 0644]
ld/testsuite/ld-elf/pr26907.ld [new file with mode: 0644]
ld/testsuite/ld-elf/pr26907.s [new file with mode: 0644]