[Patch, avr] Fix PR 20221 - adjust syms and relocs only if relax shrunk section
Senthil Kumar Selvaraj
senthil_kumar.selvaraj@atmel.com
Mon Jun 13 12:44:00 GMT 2016
Tristan Gingold writes:
>> On 10 Jun 2016, at 11:25, Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> wrote:
>>
>>
>> Denis Chertykov writes:
>>
>>> 2016-06-08 11:53 GMT+03:00 Senthil Kumar Selvaraj
>>> <senthil_kumar.selvaraj@atmel.com>:
>>>> Hi,
>>>>
>>>> This patch fixes an edge case in linker relaxation that causes symbol
>>>> values to be computed incorrectly in the presence of align directives
>>>> in input source code.
>>>>
>>>> As the below testcase demonstrates, for code like
>>>>
>>>> _start:
>>>> CALL dest
>>>> .align 1
>>>> dest:
>>>> NOP
>>>>
>>>> where the bytes to be deleted (CALL to RCALL, 2 bytes) are adjacent to an
>>>> alignment boundary, no deletion happens - the prop record handling
>>>> merely overwrites the to-be-deleted-bytes with NOPs. AFAICT, this is
>>>> ok - eventually, relaxation sees that the padding is unnecessary and
>>>> strips the NOPs away.
>>>>
>>>> However, the rest of elf32_avr_relax_delete_bytes runs with the assumption
>>>> that the bytes have been deleted, and this causes symbol values and/or
>>>> reloc offsets to be decremented even if nothing has moved. dest, in the
>>>> above testcase, gets decremented by 2 even when the gap got alignment
>>>> padded, and then again when the padding was removed - it ends up
>>>> getting adjusted down twice.
>>>>
>>>> The patch fixes this by recording whether shrinking actually occurred,
>>>> and then skipping the reloc offset/sym value adjutment if it did
>>>> not. There's also a testcase that fails with master (and 2.26) that
>>>> passes with this patch.
>>>>
>>>> Ok for master? Can I backport to 2.26 branch if ok?
>>>>
>>>> Regards
>>>> Senthil
>>>>
>>>>
>>>> bfd/ChangeLog
>>>>
>>>> 2016-06-08 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
>>>>
>>>> PR ld/20221
>>>> * elf32-avr.c (elf32_avr_relax_delete_bytes): Adjust syms
>>>> and relocs only if shrinking occurred.
>>>>
>>>> ld/ChangeLog
>>>>
>>>> 2016-06-08 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
>>>>
>>>> PR ld/20221
>>>> * testsuite/ld-avr/avr-prop-5.d: New.
>>>> * testsuite/ld-avr/avr-prop-5.s: New.
>>>>
>>>>
>>>
>>> Committed.
>>
>> Is this ok for binutils-2_26-branch?
>
> Yes.
bfd/ChangeLog
2016-06-13 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Backport from master
2016-06-08 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
PR ld/20221
* elf32-avr.c (elf32_avr_relax_delete_bytes): Adjust syms
and relocs only if shrinking occurred.
ld/ChangeLog
2016-06-13 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Backport from master
2016-06-08 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
PR ld/20221
* testsuite/ld-avr/avr-prop-5.d: New.
* testsuite/ld-avr/avr-prop-5.s: New.
Committed to binutils-2_26-branch.
Regards
Senthil
More information about the Binutils
mailing list