PR 11297: Add support for 8-bit relocations to the AVR toolchain.

This commit is contained in:
Nick Clifton
2010-02-23 11:38:36 +00:00
parent 1c063135aa
commit 17e5723725
6 changed files with 57 additions and 15 deletions

View File

@ -1,3 +1,9 @@
2010-02-23 Andrew Zabolotny <anpaza@mail.ru>
PR binutils/11297
* elf32-avr.c (elf_avr_howto_table): Add R_AVR_8.
(avr_reloc_map): Map BFD_RELOC_8 to R_AVR_8.
2010-02-22 Alan Modra <amodra@gmail.com> 2010-02-22 Alan Modra <amodra@gmail.com>
* reloc.c (bfd_check_overflow): When forming addrmask, shift * reloc.c (bfd_check_overflow): When forming addrmask, shift

View File

@ -501,7 +501,21 @@ static reloc_howto_type elf_avr_howto_table[] =
FALSE, /* partial_inplace */ FALSE, /* partial_inplace */
0xffff, /* src_mask */ 0xffff, /* src_mask */
0xffff, /* dst_mask */ 0xffff, /* dst_mask */
FALSE) /* pcrel_offset */ FALSE), /* pcrel_offset */
/* 8 bit offset. */
HOWTO (R_AVR_8, /* type */
0, /* rightshift */
0, /* size (0 = byte, 1 = short, 2 = long) */
8, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield,/* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_AVR_8", /* name */
FALSE, /* partial_inplace */
0x000000ff, /* src_mask */
0x000000ff, /* dst_mask */
FALSE), /* pcrel_offset */
}; };
/* Map BFD reloc types to AVR ELF reloc types. */ /* Map BFD reloc types to AVR ELF reloc types. */
@ -539,7 +553,8 @@ static const struct avr_reloc_map avr_reloc_map[] =
{ BFD_RELOC_AVR_CALL, R_AVR_CALL }, { BFD_RELOC_AVR_CALL, R_AVR_CALL },
{ BFD_RELOC_AVR_LDI, R_AVR_LDI }, { BFD_RELOC_AVR_LDI, R_AVR_LDI },
{ BFD_RELOC_AVR_6, R_AVR_6 }, { BFD_RELOC_AVR_6, R_AVR_6 },
{ BFD_RELOC_AVR_6_ADIW, R_AVR_6_ADIW } { BFD_RELOC_AVR_6_ADIW, R_AVR_6_ADIW },
{ BFD_RELOC_8, R_AVR_8 }
}; };
/* Meant to be filled one day with the wrap around address for the /* Meant to be filled one day with the wrap around address for the

View File

@ -1,3 +1,9 @@
2010-02-23 Andrew Zabolotny <anpaza@mail.ru>
PR binutils/11297
* config/tc-avr.c (md_apply_fix): Handle BFD_RELOC_8.
(avr_cons_fix_new): Handle fixups of a single byte.
2010-02-22 Matthew Gretton-Dann <matthew.gretton-dann@arm.com> 2010-02-22 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
PR 9861 PR 9861

View File

@ -1,7 +1,7 @@
/* tc-avr.c -- Assembler code for the ATMEL AVR /* tc-avr.c -- Assembler code for the ATMEL AVR
Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009,
Free Software Foundation, Inc. 2010 Free Software Foundation, Inc.
Contributed by Denis Chertykov <denisc@overta.ru> Contributed by Denis Chertykov <denisc@overta.ru>
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.
@ -1153,6 +1153,13 @@ md_apply_fix (fixS *fixP, valueT * valP, segT seg)
bfd_putl16 ((bfd_vma) value, where); bfd_putl16 ((bfd_vma) value, where);
break; break;
case BFD_RELOC_8:
if (value > 255 || value < -128)
as_warn_where (fixP->fx_file, fixP->fx_line,
_("operand out of range: %ld"), value);
*where = value;
break;
case BFD_RELOC_AVR_16_PM: case BFD_RELOC_AVR_16_PM:
bfd_putl16 ((bfd_vma) (value >> 1), where); bfd_putl16 ((bfd_vma) (value >> 1), where);
break; break;
@ -1442,7 +1449,9 @@ avr_cons_fix_new (fragS *frag,
{ {
if (exp_mod_pm == 0) if (exp_mod_pm == 0)
{ {
if (nbytes == 2) if (nbytes == 1)
fix_new_exp (frag, where, nbytes, exp, FALSE, BFD_RELOC_8);
else if (nbytes == 2)
fix_new_exp (frag, where, nbytes, exp, FALSE, BFD_RELOC_16); fix_new_exp (frag, where, nbytes, exp, FALSE, BFD_RELOC_16);
else if (nbytes == 4) else if (nbytes == 4)
fix_new_exp (frag, where, nbytes, exp, FALSE, BFD_RELOC_32); fix_new_exp (frag, where, nbytes, exp, FALSE, BFD_RELOC_32);

View File

@ -1,3 +1,8 @@
2010-02-23 Andrew Zabolotny <anpaza@mail.ru>
PR binutils/11297
* avr.h: (R_AVR_8): New relocation number.
2010-02-18 Matthew Gretton-Dann <matthew.gretton-dann@arm.com> 2010-02-18 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
* arm.h (Tag_MPextension_use): Renumber. * arm.h (Tag_MPextension_use): Renumber.

View File

@ -1,5 +1,5 @@
/* AVR ELF support for BFD. /* AVR ELF support for BFD.
Copyright 1999, 2000, 2004, 2006 Free Software Foundation, Inc. Copyright 1999, 2000, 2004, 2006, 2010 Free Software Foundation, Inc.
Contributed by Denis Chertykov <denisc@overta.ru> Contributed by Denis Chertykov <denisc@overta.ru>
This file is part of BFD, the Binary File Descriptor library. This file is part of BFD, the Binary File Descriptor library.
@ -69,6 +69,7 @@ START_RELOC_NUMBERS (elf_avr_reloc_type)
RELOC_NUMBER (R_AVR_MS8_LDI_NEG, 23) RELOC_NUMBER (R_AVR_MS8_LDI_NEG, 23)
RELOC_NUMBER (R_AVR_LO8_LDI_GS, 24) RELOC_NUMBER (R_AVR_LO8_LDI_GS, 24)
RELOC_NUMBER (R_AVR_HI8_LDI_GS, 25) RELOC_NUMBER (R_AVR_HI8_LDI_GS, 25)
RELOC_NUMBER (R_AVR_8, 26)
END_RELOC_NUMBERS (R_AVR_max) END_RELOC_NUMBERS (R_AVR_max)
#endif /* _ELF_AVR_H */ #endif /* _ELF_AVR_H */