From 17e57237251c3d20ba1cea0192d7dcc078ea32e2 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 23 Feb 2010 11:38:36 +0000 Subject: [PATCH] PR 11297: Add support for 8-bit relocations to the AVR toolchain. --- bfd/ChangeLog | 6 ++++++ bfd/elf32-avr.c | 23 +++++++++++++++++++---- gas/ChangeLog | 6 ++++++ gas/config/tc-avr.c | 15 ++++++++++++--- include/elf/ChangeLog | 19 ++++++++++++------- include/elf/avr.h | 3 ++- 6 files changed, 57 insertions(+), 15 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c56c3d548f..1ecd0346d7 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2010-02-23 Andrew Zabolotny + + 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 * reloc.c (bfd_check_overflow): When forming addrmask, shift diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c index 0b85105ba5..92c5be9d17 100644 --- a/bfd/elf32-avr.c +++ b/bfd/elf32-avr.c @@ -473,7 +473,7 @@ static reloc_howto_type elf_avr_howto_table[] = 0xffff, /* dst_mask */ FALSE), /* pcrel_offset */ /* A low 8 bit absolute relocation of 24 bit program memory address. - For LDI command. Will be changed when linker stubs are needed. */ + For LDI command. Will be changed when linker stubs are needed. */ HOWTO (R_AVR_LO8_LDI_GS, /* type */ 1, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -488,7 +488,7 @@ static reloc_howto_type elf_avr_howto_table[] = 0xffff, /* dst_mask */ FALSE), /* pcrel_offset */ /* A low 8 bit absolute relocation of 24 bit program memory address. - For LDI command. Will be changed when linker stubs are needed. */ + For LDI command. Will be changed when linker stubs are needed. */ HOWTO (R_AVR_HI8_LDI_GS, /* type */ 9, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -501,7 +501,21 @@ static reloc_howto_type elf_avr_howto_table[] = FALSE, /* partial_inplace */ 0xffff, /* src_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. */ @@ -539,7 +553,8 @@ static const struct avr_reloc_map avr_reloc_map[] = { BFD_RELOC_AVR_CALL, R_AVR_CALL }, { BFD_RELOC_AVR_LDI, R_AVR_LDI }, { 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 diff --git a/gas/ChangeLog b/gas/ChangeLog index bd4acd59dc..a2807f6d1e 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2010-02-23 Andrew Zabolotny + + 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 PR 9861 diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c index 9d14f6418e..a8840683ca 100644 --- a/gas/config/tc-avr.c +++ b/gas/config/tc-avr.c @@ -1,7 +1,7 @@ /* tc-avr.c -- Assembler code for the ATMEL AVR - Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 - Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. Contributed by Denis Chertykov 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); 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: bfd_putl16 ((bfd_vma) (value >> 1), where); break; @@ -1442,7 +1449,9 @@ avr_cons_fix_new (fragS *frag, { 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); else if (nbytes == 4) fix_new_exp (frag, where, nbytes, exp, FALSE, BFD_RELOC_32); diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index 52e4c371b3..349ee19171 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,8 @@ +2010-02-23 Andrew Zabolotny + + PR binutils/11297 + * avr.h: (R_AVR_8): New relocation number. + 2010-02-18 Matthew Gretton-Dann * arm.h (Tag_MPextension_use): Renumber. @@ -14,7 +19,7 @@ * common.h (NT_386_XSTATE): New. 2010-01-21 Andreas Krebbel - + * s390.h (EF_S390_HIGH_GPRS): Added macro definition. 2010-01-19 Daisuke Hatayama @@ -78,11 +83,11 @@ R_push, R_const, R_add, R_sub, R_mult, R_div, R_mod, R_lshift, R_rshift, R_and, R_or, R_xor, R_land, R_lor, R_len, R_neg, R_comp, R_page, R_hwpage, R_addr, R_pltpc, R_got. - + 2009-08-09 Michael Eager * elf/common.h: Define EM_resnnn reserved values. Add EM_AVR32, - EM_STM8, EM_TILE64, EM_TILEPRO. Change EM_MICROBLAZE. + EM_STM8, EM_TILE64, EM_TILEPRO. Change EM_MICROBLAZE. 2009-08-06 Michael Eager @@ -188,8 +193,8 @@ 2009-03-14 Mark Kettenis - * common.h (NT_OPENBSD_PROCINFO, NT_OPENBSD_AUXV) - (NT_OPENBSD_REGS, NT_OPENBSD_FPREGS, NT_OPENBSD_XFPREGS) + * common.h (NT_OPENBSD_PROCINFO, NT_OPENBSD_AUXV) + (NT_OPENBSD_REGS, NT_OPENBSD_FPREGS, NT_OPENBSD_XFPREGS) (NT_OPENBSD_WCOOKIE): New defines. 2009-03-16 Jan Kratochvil @@ -272,7 +277,7 @@ 2008-11-14 Nathan Sidwell * internal.h (struct elf_segment_map): Add header_size field. - + 2008-10-13 Ulrich Weigand * common.h (AT_BASE_PLATFORM, AT_EXECFN): Define. @@ -346,7 +351,7 @@ END_RELOC_NUMBERS symbol as a sentinel value. 2008-05-15 Christophe Lyon - + * arm.h (END_RELOC_NUMBERS): Provide a maximum value. 2008-04-16 David S. Miller diff --git a/include/elf/avr.h b/include/elf/avr.h index 627dc359de..373448c79e 100644 --- a/include/elf/avr.h +++ b/include/elf/avr.h @@ -1,5 +1,5 @@ /* 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 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_LO8_LDI_GS, 24) RELOC_NUMBER (R_AVR_HI8_LDI_GS, 25) + RELOC_NUMBER (R_AVR_8, 26) END_RELOC_NUMBERS (R_AVR_max) #endif /* _ELF_AVR_H */ -- 2.34.1