bf1865065f
Prior to the patch, addends for relocs were being adjusted even if they went beyond an alignment boundary. This is wrong - to preserve alignment constraints, the relaxation logic adds as many padding bytes at the alignment boundary as was deleted, so addends beyond the boundary should not be adjusted. avr-prop-7.s reproduces this scenario. Also, prior to this patch, the relaxation logic assumed that the addr parameter pointed to the middle of the instruction to be deleted, and that addr - count would therefore be the shrinked instruction's address. This is true when actually shrinking instructions. The alignment constraints handling logic also invokes the same logic though, with addr as the starting offset of padding bytes and with count as the number of bytes to be deleted. Calculating the shrinked insn's address as addr - count is obviously wrong in this case - that offset would point to count bytes before the last non-padded byte. avr-prop-8.s reproduces this scenario. To fix scenario 1, the patch adds an additional check to ensure reloc addends aren't adjusted if they cross a shrink boundary. The shrink boundary is either the section size or an alignment boundary. Addends pointing at an alignment boundary don't need to be adjusted, as padding would occur and keep the boundary the same. Addends pointing at section size need to be adjusted though, as no padding occurs and the section size itself would get decremented. The patch records whether padding occured (did_pad) and uses that to detect and handle this condition. To fix scenario 2, the patch adds an additional parameter (delete_shrinks_insn) to elf32_avr_relax_delete_bytes to distinguish instruction bytes deletion from padding bytes deletion. It then uses that to correctly set shrinked_insn_address. bfd/ChangeLog: 2016-09-02 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> PR ld/20545 * elf32-avr.c (elf32_avr_relax_delete_bytes): Add parameter delete_shrinks_insn. Modify computation of shrinked_insn_address. Compute shrink_boundary and adjust addend only if addend_within_shrink_boundary. (elf32_avr_relax_section): Modify calls to elf32_avr_relax_delete_bytes to pass extra parameter. ld/ChangeLog: 2016-09-02 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> PR ld/20545 * testsuite/ld-avr/avr-prop-7.d: New test. * testsuite/ld-avr/avr-prop-7.s: New test. * testsuite/ld-avr/avr-prop-8.d: New test. * testsuite/ld-avr/avr-prop-8.s: New test. |
||
---|---|---|
.. | ||
avr-prop-1.d | ||
avr-prop-1.s | ||
avr-prop-2.d | ||
avr-prop-2.s | ||
avr-prop-3.d | ||
avr-prop-3.s | ||
avr-prop-4.d | ||
avr-prop-4.s | ||
avr-prop-5.d | ||
avr-prop-5.s | ||
avr-prop-6.d | ||
avr-prop-6.s | ||
avr-prop-7.d | ||
avr-prop-7.s | ||
avr-prop-8.d | ||
avr-prop-8.s | ||
avr.exp | ||
gc-section-debugline.d | ||
lds-mega.d | ||
lds-mega.s | ||
lds-tiny.d | ||
lds-tiny.s | ||
norelax_diff.d | ||
per-function-debugline.s | ||
region_overflow.d | ||
region_overflow.s | ||
relax_diff.d | ||
relax-02.d | ||
relax-02.s | ||
relax-03.d | ||
relax-03.s | ||
relax-elf-flags-01.d | ||
relax-elf-flags-02.d | ||
relax-elf-flags-03.d | ||
relax-elf-flags-04.d | ||
relax-elf-flags-05.d | ||
relax-elf-flags-06.d | ||
relax-elf-flags-07.d | ||
relax-elf-flags-08.d | ||
relax-elf-flags-a.s | ||
relax-elf-flags-b.s | ||
relax.s |