daily update
[deliverable/binutils-gdb.git] / bfd / elf64-mips.c
index 093c7000cf9e8ea3a6a49d1ef0db70f58cb07f7e..8662d6663df1b8ee2d25547bf006cea1d767cb65 100644 (file)
@@ -1,7 +1,5 @@
 /* MIPS-specific support for 64-bit ELF
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright (C) 1996-2014 Free Software Foundation, Inc.
    Ian Lance Taylor, Cygnus Support
    Linker support added by Mark Mitchell, CodeSourcery, LLC.
    <mark@codesourcery.com>
@@ -130,8 +128,8 @@ static bfd_boolean elf64_mips_grok_prstatus
 static bfd_boolean elf64_mips_grok_psinfo
   (bfd *, Elf_Internal_Note *);
 
-extern const bfd_target bfd_elf64_bigmips_vec;
-extern const bfd_target bfd_elf64_littlemips_vec;
+extern const bfd_target mips_elf64_be_vec;
+extern const bfd_target mips_elf64_le_vec;
 
 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
    from smaller values.  Start with zero, widen, *then* decrement.  */
@@ -2184,6 +2182,37 @@ static reloc_howto_type micromips_elf64_howto_table_rel[] =
         0x0000ffff,            /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
+
+  /* Section displacement.  */
+  HOWTO (R_MICROMIPS_SCN_DISP,  /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont, /* complain_on_overflow */
+        _bfd_mips_elf_generic_reloc, /* special_function */
+        "R_MICROMIPS_SCN_DISP", /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  /* Protected jump conversion.  This is an optimization hint.  No
+     relocation is required for correctness.  */
+  HOWTO (R_MICROMIPS_JALR,     /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont, /* complain_on_overflow */
+        _bfd_mips_elf_generic_reloc, /* special_function */
+        "R_MICROMIPS_JALR",    /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        0x00000000,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
 };
 
 static reloc_howto_type micromips_elf64_howto_table_rela[] =
@@ -2495,6 +2524,37 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
         0,                     /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
+
+  /* Section displacement.  */
+  HOWTO (R_MICROMIPS_SCN_DISP,  /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont, /* complain_on_overflow */
+        _bfd_mips_elf_generic_reloc, /* special_function */
+        "R_MICROMIPS_SCN_DISP", /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  /* Protected jump conversion.  This is an optimization hint.  No
+     relocation is required for correctness.  */
+  HOWTO (R_MICROMIPS_JALR,     /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont, /* complain_on_overflow */
+        _bfd_mips_elf_generic_reloc, /* special_function */
+        "R_MICROMIPS_JALR",    /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        0x00000000,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
 };
 
 /* GNU extension to record C++ vtable hierarchy */
@@ -2560,6 +2620,23 @@ static reloc_howto_type elf_mips_gnu_rela16_s2 =
         0,                     /* src_mask */
         0x0000ffff,            /* dst_mask */
         TRUE);                 /* pcrel_offset */
+
+/* 32 bit pc-relative.  Used for compact EH tables.  */
+static reloc_howto_type elf_mips_gnu_pcrel32 =
+  HOWTO (R_MIPS_PC32,          /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        TRUE,                  /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_signed, /* complain_on_overflow */
+        _bfd_mips_elf_generic_reloc, /* special_function */
+        "R_MIPS_PC32",         /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        TRUE);                 /* pcrel_offset */
+
 \f
 /* Originally a VxWorks extension, but now used for other systems too.  */
 static reloc_howto_type elf_mips_copy_howto =
@@ -2570,7 +2647,7 @@ static reloc_howto_type elf_mips_copy_howto =
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
+        _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_COPY",         /* name */
         FALSE,                 /* partial_inplace */
         0x0,                   /* src_mask */
@@ -2586,12 +2663,29 @@ static reloc_howto_type elf_mips_jump_slot_howto =
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
+        _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_JUMP_SLOT",    /* name */
         FALSE,                 /* partial_inplace */
         0x0,                   /* src_mask */
         0x0,                   /* dst_mask */
         FALSE);                /* pcrel_offset */
+
+/* Used in EH tables.  */
+static reloc_howto_type elf_mips_eh_howto =
+  HOWTO (R_MIPS_EH,            /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_signed, /* complain_on_overflow */
+        _bfd_mips_elf_generic_reloc, /* special_function */
+        "R_MIPS_EH",           /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE);                /* pcrel_offset */
+
 \f
 /* Swap in a MIPS 64-bit Rel reloc.  */
 
@@ -3152,6 +3246,8 @@ static const struct elf_reloc_map micromips_reloc_map[] =
   { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
   { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
   { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
+  { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
+  { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
 };
 /* Given a BFD reloc type, return a howto structure.  */
 
@@ -3193,6 +3289,10 @@ bfd_elf64_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
       return &elf_mips_gnu_vtinherit_howto;
     case BFD_RELOC_VTABLE_ENTRY:
       return &elf_mips_gnu_vtentry_howto;
+    case BFD_RELOC_32_PCREL:
+      return &elf_mips_gnu_pcrel32;
+    case BFD_RELOC_MIPS_EH:
+      return &elf_mips_eh_howto;
     case BFD_RELOC_MIPS_COPY:
       return &elf_mips_copy_howto;
     case BFD_RELOC_MIPS_JUMP_SLOT:
@@ -3240,6 +3340,10 @@ bfd_elf64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
     return &elf_mips_gnu_rel16_s2;
   if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
     return &elf_mips_gnu_rela16_s2;
+  if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
+    return &elf_mips_gnu_pcrel32;
+  if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
+    return &elf_mips_eh_howto;
   if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
     return &elf_mips_copy_howto;
   if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
@@ -3264,6 +3368,10 @@ mips_elf64_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
        return &elf_mips_gnu_rela16_s2;
       else
        return &elf_mips_gnu_rel16_s2;
+    case R_MIPS_PC32:
+      return &elf_mips_gnu_pcrel32;
+    case R_MIPS_EH:
+      return &elf_mips_eh_howto;
     case R_MIPS_COPY:
       return &elf_mips_copy_howto;
     case R_MIPS_JUMP_SLOT:
@@ -3923,8 +4031,8 @@ mips_elf64_object_p (bfd *abfd)
 static irix_compat_t
 elf64_mips_irix_compat (bfd *abfd)
 {
-  if ((abfd->xvec == &bfd_elf64_bigmips_vec)
-      || (abfd->xvec == &bfd_elf64_littlemips_vec))
+  if ((abfd->xvec == &mips_elf64_be_vec)
+      || (abfd->xvec == &mips_elf64_le_vec))
     return ict_irix6;
   else
     return ict_none;
@@ -3944,10 +4052,10 @@ elf64_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
 
       case 480:                /* Linux/MIPS - N64 kernel */
        /* pr_cursig */
-       elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+       elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
        /* pr_pid */
-       elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
+       elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 32);
 
        /* pr_reg */
        offset = 112;
@@ -3970,9 +4078,9 @@ elf64_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
        return FALSE;
 
       case 136:                /* Linux/MIPS - N64 kernel elf_prpsinfo */
-       elf_tdata (abfd)->core_program
+       elf_tdata (abfd)->core->program
         = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
-       elf_tdata (abfd)->core_command
+       elf_tdata (abfd)->core->command
         = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
     }
 
@@ -3981,7 +4089,7 @@ elf64_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -4077,6 +4185,8 @@ const struct elf_size_info mips_elf64_size_info =
 #define elf_backend_collect            TRUE
 #define elf_backend_type_change_ok     TRUE
 #define elf_backend_can_gc_sections    TRUE
+#define elf_backend_gc_mark_extra_sections \
+                                       _bfd_mips_elf_gc_mark_extra_sections
 #define elf_info_to_howto              mips_elf64_info_to_howto_rela
 #define elf_info_to_howto_rel          mips_elf64_info_to_howto_rel
 #define elf_backend_object_p           mips_elf64_object_p
@@ -4166,6 +4276,7 @@ const struct elf_size_info mips_elf64_size_info =
 #define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound
 #define bfd_elf64_canonicalize_dynamic_reloc mips_elf64_canonicalize_dynamic_reloc
 #define bfd_elf64_bfd_relax_section     _bfd_mips_relax_section
+#define bfd_elf64_mkobject             _bfd_mips_elf_mkobject
 
 /* MIPS ELF64 archive functions.  */
 #define bfd_elf64_archive_functions
@@ -4191,9 +4302,9 @@ extern bfd_boolean bfd_elf64_archive_write_armap
                        _bfd_archive_coff_update_armap_timestamp
 
 /* The SGI style (n)64 NewABI.  */
-#define TARGET_LITTLE_SYM              bfd_elf64_littlemips_vec
+#define TARGET_LITTLE_SYM              mips_elf64_le_vec
 #define TARGET_LITTLE_NAME             "elf64-littlemips"
-#define TARGET_BIG_SYM                 bfd_elf64_bigmips_vec
+#define TARGET_BIG_SYM                 mips_elf64_be_vec
 #define TARGET_BIG_NAME                        "elf64-bigmips"
 
 #define ELF_MAXPAGESIZE                        0x10000
@@ -4210,9 +4321,9 @@ extern bfd_boolean bfd_elf64_archive_write_armap
 #undef ELF_MAXPAGESIZE
 #undef ELF_COMMONPAGESIZE
 
-#define TARGET_LITTLE_SYM              bfd_elf64_tradlittlemips_vec
+#define TARGET_LITTLE_SYM              mips_elf64_trad_le_vec
 #define TARGET_LITTLE_NAME             "elf64-tradlittlemips"
-#define TARGET_BIG_SYM                 bfd_elf64_tradbigmips_vec
+#define TARGET_BIG_SYM                 mips_elf64_trad_be_vec
 #define TARGET_BIG_NAME                        "elf64-tradbigmips"
 
 #define ELF_MAXPAGESIZE                        0x10000
@@ -4230,26 +4341,14 @@ extern bfd_boolean bfd_elf64_archive_write_armap
 #undef TARGET_BIG_SYM
 #undef TARGET_BIG_NAME
 
-#define        TARGET_LITTLE_SYM               bfd_elf64_tradlittlemips_freebsd_vec
+#define        TARGET_LITTLE_SYM               mips_elf64_tradfbsd_le_vec
 #define        TARGET_LITTLE_NAME              "elf64-tradlittlemips-freebsd"
-#define        TARGET_BIG_SYM                  bfd_elf64_tradbigmips_freebsd_vec
+#define        TARGET_BIG_SYM                  mips_elf64_tradfbsd_be_vec
 #define        TARGET_BIG_NAME                 "elf64-tradbigmips-freebsd"
 
 #undef ELF_OSABI
 #define        ELF_OSABI                       ELFOSABI_FREEBSD
 
-/* The kernel recognizes executables as valid only if they carry a
-   "FreeBSD" label in the ELF header.  So we put this label on all
-   executables and (for simplicity) also all other object files.  */
-
-static void
-elf_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
-{
-  _bfd_elf_set_osabi (abfd, info);
-}
-
-#undef elf_backend_post_process_headers
-#define        elf_backend_post_process_headers        elf_fbsd_post_process_headers
 #undef elf64_bed
 #define elf64_bed                              elf64_fbsd_tradbed
 
This page took 0.034113 seconds and 4 git commands to generate.