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: Tristan Gingold <gingold at adacore dot com>
- To: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel 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: Fri, 10 Jun 2016 16:59:37 +0200
- 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>
> 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.
>
> Regards
> Senthil