[Patch, avr] Add DIFF relocations

Denis Chertykov chertykov@gmail.com
Thu Apr 10 15:53:00 GMT 2014


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.



More information about the Binutils mailing list