This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [Patch, avr] Fix PR 20221 - adjust syms and relocs only if relax shrunk section
- From: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>
- To: Tristan Gingold <gingold at adacore dot com>
- Cc: Denis Chertykov <chertykov at gmail dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>, Andrew Burgess <andrew dot burgess at embecosm dot com>, "Nick Clifton" <nickc at redhat dot com>
- Date: Mon, 13 Jun 2016 18:13:54 +0530
- Subject: Re: [Patch, avr] Fix PR 20221 - adjust syms and relocs only if relax shrunk section
- Authentication-results: sourceware.org; auth=none
- References: <8760tkawob dot fsf at atmel dot com> <CADOs=zYtb4c7Cryc6QHrz5xOPoZ7oh5-ewp3Gams0fS7LHwTDQ at mail dot gmail dot com> <877fdx9yzm dot fsf at atmel dot com> <5C21EE8A-4871-4E76-8972-108F31E463D6 at adacore dot com>
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