BFD whitespace fixes
[deliverable/binutils-gdb.git] / bfd / elf32-mips.c
index 5654fb664e9862bc6224e0e424e72e6e33f7618a..3fb619f6b147cee20aeff541a64d05c71361fd77 100644 (file)
@@ -1,5 +1,5 @@
 /* MIPS-specific support for 32-bit ELF
-   Copyright (C) 1993-2016 Free Software Foundation, Inc.
+   Copyright (C) 1993-2017 Free Software Foundation, Inc.
 
    Most of the information added by Ian Lance Taylor, Cygnus Support,
    <ian@cygnus.com>.
@@ -172,7 +172,7 @@ static reloc_howto_type elf_mips_howto_table_rel[] =
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
-                               /* This needs complex overflow
+                               /* This needs complex overflow
                                   detection, because the upper four
                                   bits must match the PC + 4.  */
         _bfd_mips_elf_generic_reloc, /* special_function */
@@ -534,7 +534,7 @@ static reloc_howto_type elf_mips_howto_table_rel[] =
 
   /* Protected jump conversion.  This is an optimization hint.  No
      relocation is required for correctness.  */
-  HOWTO (R_MIPS_JALR,          /* type */
+  HOWTO (R_MIPS_JALR,          /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
@@ -542,7 +542,7 @@ static reloc_howto_type elf_mips_howto_table_rel[] =
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
-        "R_MIPS_JALR",         /* name */
+        "R_MIPS_JALR",         /* name */
         FALSE,                 /* partial_inplace */
         0x00000000,            /* src_mask */
         0x00000000,            /* dst_mask */
@@ -838,7 +838,7 @@ static reloc_howto_type elf_mips16_howto_table_rel[] =
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
-                               /* This needs complex overflow
+                               /* This needs complex overflow
                                   detection, because the upper four
                                   bits must match the PC.  */
         _bfd_mips_elf_generic_reloc, /* special_function */
@@ -860,7 +860,7 @@ static reloc_howto_type elf_mips16_howto_table_rel[] =
         "R_MIPS16_GPREL",      /* name */
         TRUE,                  /* partial_inplace */
         0x0000ffff,            /* src_mask */
-        0x0000ffff,            /* dst_mask */
+        0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* A MIPS16 reference to the global offset table.  */
@@ -875,7 +875,7 @@ static reloc_howto_type elf_mips16_howto_table_rel[] =
         "R_MIPS16_GOT16",      /* name */
         TRUE,                  /* partial_inplace */
         0x0000ffff,            /* src_mask */
-        0x0000ffff,            /* dst_mask */
+        0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* A MIPS16 call through the global offset table.  */
@@ -890,7 +890,7 @@ static reloc_howto_type elf_mips16_howto_table_rel[] =
         "R_MIPS16_CALL16",     /* name */
         TRUE,                  /* partial_inplace */
         0x0000ffff,            /* src_mask */
-        0x0000ffff,            /* dst_mask */
+        0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MIPS16 high 16 bits of symbol value.  */
@@ -905,7 +905,7 @@ static reloc_howto_type elf_mips16_howto_table_rel[] =
         "R_MIPS16_HI16",       /* name */
         TRUE,                  /* partial_inplace */
         0x0000ffff,            /* src_mask */
-        0x0000ffff,            /* dst_mask */
+        0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MIPS16 low 16 bits of symbol value.  */
@@ -920,7 +920,7 @@ static reloc_howto_type elf_mips16_howto_table_rel[] =
         "R_MIPS16_LO16",       /* name */
         TRUE,                  /* partial_inplace */
         0x0000ffff,            /* src_mask */
-        0x0000ffff,            /* dst_mask */
+        0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MIPS16 TLS general dynamic variable reference.  */
@@ -1027,6 +1027,21 @@ static reloc_howto_type elf_mips16_howto_table_rel[] =
         0x0000ffff,            /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
+
+  /* MIPS16 16-bit PC-relative branch offset.  */
+  HOWTO (R_MIPS16_PC16_S1,     /* type */
+        1,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        16,                    /* bitsize */
+        TRUE,                  /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_signed, /* complain_on_overflow */
+        _bfd_mips_elf_generic_reloc, /* special_function */
+        "R_MIPS16_PC16_S1",    /* name */
+        TRUE,                  /* partial_inplace */
+        0x0000ffff,            /* src_mask */
+        0x0000ffff,            /* dst_mask */
+        TRUE),                 /* pcrel_offset */
 };
 
 static reloc_howto_type elf_micromips_howto_table_rel[] =
@@ -1043,7 +1058,7 @@ static reloc_howto_type elf_micromips_howto_table_rel[] =
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
-                               /* This needs complex overflow
+                               /* This needs complex overflow
                                   detection, because the upper four
                                   bits must match the PC.  */
         _bfd_mips_elf_generic_reloc, /* special_function */
@@ -1610,8 +1625,8 @@ static reloc_howto_type elf_mips_copy_howto =
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_COPY",         /* name */
         FALSE,                 /* partial_inplace */
-        0x0,                   /* src_mask */
-        0x0,                   /* dst_mask */
+        0x0,                   /* src_mask */
+        0x0,                   /* dst_mask */
         FALSE);                /* pcrel_offset */
 
 /* Originally a VxWorks extension, but now used for other systems too.  */
@@ -1626,8 +1641,8 @@ static reloc_howto_type elf_mips_jump_slot_howto =
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_JUMP_SLOT",    /* name */
         FALSE,                 /* partial_inplace */
-        0x0,                   /* src_mask */
-        0x0,                   /* dst_mask */
+        0x0,                   /* src_mask */
+        0x0,                   /* dst_mask */
         FALSE);                /* pcrel_offset */
 
 /* Used in EH tables.  */
@@ -1643,7 +1658,7 @@ static reloc_howto_type elf_mips_eh_howto =
         "R_MIPS_EH",           /* name */
         TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
-        0xffffffff,            /* dst_mask */
+        0xffffffff,            /* dst_mask */
         FALSE);                /* pcrel_offset */
 
 /* Set the GP value for OUTPUT_BFD.  Returns FALSE if this is a
@@ -2023,7 +2038,8 @@ static const struct elf_reloc_map mips16_reloc_map[] =
     R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
   { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
   { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
-  { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min }
+  { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_16_PCREL_S1, R_MIPS16_PC16_S1 - R_MIPS16_min }
 };
 
 static const struct elf_reloc_map micromips_reloc_map[] =
@@ -2203,10 +2219,10 @@ mips_elf32_rtype_to_howto (unsigned int r_type,
       if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
        return &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
       if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
-        return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
+       return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
       if (r_type >= (unsigned int) R_MIPS_max)
        {
-         (*_bfd_error_handler) (_("Unrecognised MIPS reloc number: %d"), r_type);
+         _bfd_error_handler (_("Unrecognised MIPS reloc number: %d"), r_type);
          bfd_set_error (bfd_error_bad_value);
          r_type = R_MIPS_NONE;
        }
@@ -2337,6 +2353,8 @@ elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
        return FALSE;
 
       case 128:                /* Linux/MIPS elf_prpsinfo */
+       elf_tdata (abfd)->core->pid
+        = bfd_get_32 (abfd, note->descdata + 16);
        elf_tdata (abfd)->core->program
         = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
        elf_tdata (abfd)->core->command
@@ -2357,6 +2375,45 @@ elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 
   return TRUE;
 }
+
+/* Write Linux core PRSTATUS note into core file.  */
+
+static char *
+elf32_mips_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
+                            ...)
+{
+  switch (note_type)
+    {
+    default:
+      return NULL;
+
+    case NT_PRPSINFO:
+      BFD_FAIL ();
+      return NULL;
+
+    case NT_PRSTATUS:
+      {
+       char data[256];
+       va_list ap;
+       long pid;
+       int cursig;
+       const void *greg;
+
+       va_start (ap, note_type);
+       memset (data, 0, 72);
+       pid = va_arg (ap, long);
+       bfd_put_32 (abfd, pid, data + 24);
+       cursig = va_arg (ap, int);
+       bfd_put_16 (abfd, cursig, data + 12);
+       greg = va_arg (ap, const void *);
+       memcpy (data + 72, greg, 180);
+       memset (data + 252, 0, 4);
+       va_end (ap);
+       return elfcore_write_note (abfd, buf, bufsiz,
+                                  "CORE", note_type, data, sizeof (data));
+      }
+    }
+}
 \f
 /* Depending on the target vector we generate some version of Irix
    executables or "normal" MIPS ELF ABI executables.  */
@@ -2458,7 +2515,6 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
                                        _bfd_mips_elf_additional_program_headers
 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
 #define elf_backend_gc_mark_hook       _bfd_mips_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook      _bfd_mips_elf_gc_sweep_hook
 #define elf_backend_copy_indirect_symbol \
                                        _bfd_mips_elf_copy_indirect_symbol
 #define elf_backend_grok_prstatus      elf32_mips_grok_prstatus
@@ -2466,6 +2522,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #define elf_backend_ecoff_debug_swap   &mips_elf32_ecoff_debug_swap
 
 #define elf_backend_got_header_size    (4 * MIPS_RESERVED_GOTNO)
+#define elf_backend_want_dynrelro      1
 #define elf_backend_may_use_rel_p      1
 #define elf_backend_may_use_rela_p     0
 #define elf_backend_default_use_rela_p 0
@@ -2524,10 +2581,10 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #undef ELF_MAXPAGESIZE
 #undef ELF_COMMONPAGESIZE
 
-#define TARGET_LITTLE_SYM               mips_elf32_trad_le_vec
-#define TARGET_LITTLE_NAME              "elf32-tradlittlemips"
-#define TARGET_BIG_SYM                  mips_elf32_trad_be_vec
-#define TARGET_BIG_NAME                 "elf32-tradbigmips"
+#define TARGET_LITTLE_SYM              mips_elf32_trad_le_vec
+#define TARGET_LITTLE_NAME             "elf32-tradlittlemips"
+#define TARGET_BIG_SYM                 mips_elf32_trad_be_vec
+#define TARGET_BIG_NAME                        "elf32-tradbigmips"
 
 /* The MIPS ABI says at Page 5-1:
    Virtual addresses and file offsets for MIPS segments are congruent
@@ -2538,6 +2595,9 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #define ELF_COMMONPAGESIZE             0x1000
 #define elf32_bed                      elf32_tradbed
 
+#undef elf_backend_write_core_note
+#define elf_backend_write_core_note    elf32_mips_write_core_note
+
 /* Include the target file again for this target.  */
 #include "elf32-target.h"
 
@@ -2559,6 +2619,8 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #undef elf32_bed
 #define elf32_bed                              elf32_fbsd_tradbed
 
+#undef elf_backend_write_core_note
+
 #include "elf32-target.h"
 /* Implement elf_backend_final_write_processing for VxWorks.  */
 
@@ -2577,10 +2639,10 @@ mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
 #undef ELF_MAXPAGESIZE
 #undef ELF_COMMONPAGESIZE
 
-#define TARGET_LITTLE_SYM               mips_elf32_vxworks_le_vec
-#define TARGET_LITTLE_NAME              "elf32-littlemips-vxworks"
-#define TARGET_BIG_SYM                  mips_elf32_vxworks_be_vec
-#define TARGET_BIG_NAME                 "elf32-bigmips-vxworks"
+#define TARGET_LITTLE_SYM              mips_elf32_vxworks_le_vec
+#define TARGET_LITTLE_NAME             "elf32-littlemips-vxworks"
+#define TARGET_BIG_SYM                 mips_elf32_vxworks_be_vec
+#define TARGET_BIG_NAME                        "elf32-bigmips-vxworks"
 #undef ELF_OSABI
 
 #undef elf32_bed
@@ -2601,6 +2663,8 @@ mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
 #define elf_backend_default_use_rela_p         1
 #undef elf_backend_got_header_size
 #define elf_backend_got_header_size            (4 * 3)
+#undef elf_backend_dtrel_excludes_plt
+#define elf_backend_dtrel_excludes_plt         1
 
 #undef elf_backend_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_symbol \
This page took 0.036143 seconds and 4 git commands to generate.