]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
MSP430: ld: Update output section tail when shuffling ".either" sections
authorJozef Lawrynowicz <jozef.l@mittosystems.com>
Wed, 5 Aug 2020 11:55:07 +0000 (12:55 +0100)
committerJozef Lawrynowicz <jozef.l@mittosystems.com>
Thu, 6 Aug 2020 10:19:36 +0000 (11:19 +0100)
commit1a9f72a7a8f445b8d665eb36b053a18e758e63e6
tree550308f9d1d9aac07f047803a31470b844c5a9b5
parentb5582ab72f025c54d4a6e8f459f78a8c92e6df29
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.
ld/ChangeLog
ld/emultempl/msp430.em