MSP430: ld: Update output section tail when shuffling ".either" sections
The MSP430 linker shuffles input sections with names beginning with
".either" between the upper and lower memory regions, to try to avoid
one region overflowing when there is space in the other region.
However, when an ".either" input section attached to the tail of an
output section was moved to a different output section in the other
region, that tail wasn't being updated to the new section at the end
of the original output section.
This caused a bug where a shuffled section could end up in the
middle of another section in the output executable, resulting in
corrupted code or data.
When changing the output section of an input section attached to the
tail of its output section, that tail is now updated to point to
the new input section at the end of the section list.
ld/ChangeLog:
2020-08-06 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* emultempl/msp430.em (change_output_section): Update the tail
of the output section statement list when moving the original
tail to a different output section.
(eval_upper_either_sections): Don't move sections from the upper
region to the lower region unless the upper region is
overflowing.