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.
+2020-11-28 Alan Modra <amodra@gmail.com>
+
+ PR 26907
+ * elf.c (elf_sort_sections): Don't sort zero size !load sections
+ after load sections.
+
2020-11-27 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* elf.c (special_sections_g): Add .gnu.linkonce.n and .gnu.linkonce.p.
/* Put !SEC_LOAD sections after SEC_LOAD ones. */
-#define TOEND(x) (((x)->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0)
+#define TOEND(x) (((x)->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0 \
+ && (x)->size != 0)
if (TOEND (sec1))
{
+2020-11-28 Alan Modra <amodra@gmail.com>
+
+ * testsuite/ld-elf/pr26907.ld,
+ * testsuite/ld-elf/pr26907.s,
+ * testsuite/ld-elf/pr26907.d: New test.
+
2020-11-27 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* emulparams/armelf.sh (OTHER_SECTIONS): Remove .noinit section
--- /dev/null
+#ld: -T pr26907.ld
+#readelf: -lW
+#xfail: dlx-*-* ft32-*-* h8300-*-* ip2k-*-* m32r*-*-elf* m32r*-*-rtems*
+#xfail: moxie-*-* msp430-*-* mt-*-* pru*-*-* visium-*-*
+
+#failif
+#...
+ +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+ 0x0+ .*
+#...
--- /dev/null
+ENTRY (_start)
+SECTIONS
+{
+ .text : { *(.text) }
+ .bss : { . = .; *(.bss) }
+ .data : { *(.data) }
+}
--- /dev/null
+ .text
+ .global _start
+_start:
+ .quad 0
+
+ .data
+ .quad 0
+
+ .section .bss,"aw",%nobits