2011-05-20 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / bfd / elf32-moxie.c
index e3f01d2e8cad25776ec4ab382c89e2059d2dbf6b..8463599775c060829d249881ab50c99313d8cddb 100644 (file)
@@ -1,6 +1,5 @@
 /* moxie-specific support for 32-bit ELF.
-   Copyright 2008 Anthony Green.
-   Copyright 2009 Free Software Foundation, Inc.
+   Copyright 2009, 2010 Free Software Foundation, Inc.
 
    Copied from elf32-fr30.c which is..
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
@@ -62,6 +61,21 @@ static reloc_howto_type moxie_elf_howto_table [] =
         0x00000000,            /* src_mask */
         0xffffffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
+
+  /* A 10 bit PC-relative relocation.  */
+  HOWTO (R_MOXIE_PCREL10,      /* type.  */
+        1,                     /* rightshift.  */
+        1,                     /* size (0 = byte, 1 = short, 2 = long).  */
+        10,                    /* bitsize.  */
+        TRUE,                  /* pc_relative.  */
+        0,                     /* bitpos.  */
+        complain_overflow_signed, /* complain_on_overflow.  */
+        bfd_elf_generic_reloc, /* special_function.  */
+        "R_MOXIE_PCREL10",             /* name.  */
+        FALSE,                 /* partial_inplace.  */
+        0,                     /* src_mask.  */
+        0x000003FF,            /* dst_mask.  */
+        TRUE),                 /* pcrel_offset.  */
 };
 \f
 /* Map BFD reloc types to MOXIE ELF reloc types.  */
@@ -74,8 +88,9 @@ struct moxie_reloc_map
 
 static const struct moxie_reloc_map moxie_reloc_map [] =
 {
-  { BFD_RELOC_NONE,           R_MOXIE_NONE },
-  { BFD_RELOC_32,             R_MOXIE_32 },
+  { BFD_RELOC_NONE,            R_MOXIE_NONE },
+  { BFD_RELOC_32,              R_MOXIE_32 },
+  { BFD_RELOC_MOXIE_10_PCREL,  R_MOXIE_PCREL10 },
 };
 
 static reloc_howto_type *
@@ -207,10 +222,8 @@ moxie_elf_relocate_section (bfd *output_bfd,
       int r_type;
 
       r_type = ELF32_R_TYPE (rel->r_info);
-
       r_symndx = ELF32_R_SYM (rel->r_info);
-
-      howto  = moxie_elf_howto_table + ELF32_R_TYPE (rel->r_info);
+      howto  = moxie_elf_howto_table + r_type;
       h      = NULL;
       sym    = NULL;
       sec    = NULL;
@@ -238,15 +251,8 @@ moxie_elf_relocate_section (bfd *output_bfd,
        }
 
       if (sec != NULL && elf_discarded_section (sec))
-       {
-         /* For relocs against symbols from removed linkonce sections,
-            or sections discarded by a linker script, we just want the
-            section contents zeroed.  Avoid any special processing.  */
-         _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-         rel->r_info = 0;
-         rel->r_addend = 0;
-         continue;
-       }
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, relend, howto, contents);
 
       if (info->relocatable)
        continue;
This page took 0.024395 seconds and 4 git commands to generate.