This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [Patch, avr] Add DIFF relocations
- From: Denis Chertykov <chertykov at gmail dot com>
- To: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>, Nick Clifton <nickc at redhat dot com>
- Date: Thu, 10 Apr 2014 19:53:00 +0400
- Subject: Re: [Patch, avr] Add DIFF relocations
- Authentication-results: sourceware.org; auth=none
- References: <20140409124311 dot GA1031 at atmel dot com>
2014-04-09 16:43 GMT+04:00 Senthil Kumar Selvaraj
<senthil_kumar.selvaraj@atmel.com>:
> This patch adds DIFF relocations to the AVR target. Until now, the
> assembler computed symbol differences at assembly time, but this does
> not work well with linker relaxation. For example, the changes Nick
> made to DWARF line number information
> (https://sourceware.org/ml/binutils/2012-06/msg00234.html) did not work
> because the generated fixups were still being resolved at assembly time.
>
> This patch is based a lot on how the xtensa target handles this problem.
> It adds three DIFF relocation types (for 8, 16 and 32 bit diffs) and
> makes the assembler and the linker aware of them. The difference at
> assembly time is written into the object file by the assembler,
> and the linker adjusts it after relaxation.
>
> The generation of DIFF relocations is controlled by a new assembler flag
> (mlink-relax) - without the flag, there will no change from the current
> behavior. I have a patch for gcc that automatically passes mlink-relax
> to the assembler if -mrelax is passed to the gcc driver.
>
> I also have a couple of assembler and linker tests to verify relocation
> generation by the assembler and resolution by the linker.
>
> I have not attached generated files with the patch. If ok, could someone
> apply please? I don't have commit access.
>
> Regards
> Senthil
>
> bfd/ChangeLog
>
> 2014-04-09 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
>
> * elf32-avr.c: Add DIFF relocations for AVR.
> (avr_final_link_relocate): Handle the DIFF relocs.
> (bfd_elf_avr_diff_reloc): New.
> (elf32_avr_is_diff_reloc): New.
> (elf32_avr_adjust_diff_reloc_value): Reduce difference value.
> (elf32_avr_relax_delete_bytes): Recompute difference after deleting
> bytes.
>
> * reloc.c: Add BFD_RELOC_AVR_DIFF8/16/32 relocations
>
> gas/ChangeLog
>
> * config/tc-avr.c: Add new flag mlink-relax.
> (md_show_usage): Add flag and help text.
> (md_parse_option): Record whether link relax is turned on.
> (relaxable_section): New.
> (avr_validate_fix_sub): New.
> (avr_force_relocation): New.
> (md_apply_fix): Generate DIFF reloc.
> (avr_allow_local_subtract): New.
>
> * config/tc-avr.h (TC_LINKRELAX_FIXUP): Define to 0.
> (TC_FORCE_RELOCATION): Define.
> (TC_FORCE_RELOCATION_SUB_SAME): Define.
> (TC_VALIDATE_FIX_SUB): Define.
> (avr_force_relocation): Declare.
> (avr_validate_fix_sub): Declare.
> (md_allow_local_subtract): Define.
> (avr_allow_local_subtract): Declare.
>
> gas/testsuite/ChangeLog
>
> * gas/avr/diffreloc_withrelax.d: New testcase.
> * gas/avr/noreloc_withoutrelax.d: Likewise.
> * gas/avr/relax.s: Likewise.
>
> include/ChangeLog
>
> * elf/avr.h: Add new DIFF relocs.
>
> ld/testsuite/ChangeLog
>
> * ld-avr/norelax_diff.d: New testcase.
> * ld-avr/relax_diff.d: Likewise.
> * ld-avr/relax.s: Likewise.
>
Committed.
Denis.