bfd: install plugin-api.h as needed
[deliverable/binutils-gdb.git] / bfd / elf64-mips.c
index ad00a3db19b4a36e646080904fc3365f03b8a4e7..7ed54fac78a4067939ce66190c4004b9623356ac 100644 (file)
@@ -1,6 +1,7 @@
 /* MIPS-specific support for 64-bit ELF
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007 Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
    Ian Lance Taylor, Cygnus Support
    Linker support added by Mark Mitchell, CodeSourcery, LLC.
    <mark@codesourcery.com>
@@ -1328,7 +1329,20 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
   /* TLS relocations.  */
   EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32),
   EMPTY_HOWTO (R_MIPS_TLS_DTPREL32),
-  EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
+
+  HOWTO (R_MIPS_TLS_DTPMOD64,  /* type */
+        0,                     /* rightshift */
+        4,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont, /* complain_on_overflow */
+        _bfd_mips_elf_generic_reloc, /* special_function */
+        "R_MIPS_TLS_DTPMOD64", /* name */
+        FALSE,                 /* partial_inplace */
+        MINUS_ONE,             /* src_mask */
+        MINUS_ONE,             /* dst_mask */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_MIPS_TLS_DTPREL64,  /* type */
         0,                     /* rightshift */
@@ -1339,7 +1353,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         complain_overflow_dont, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_DTPREL64", /* name */
-        TRUE,                  /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         MINUS_ONE,             /* src_mask */
         MINUS_ONE,             /* dst_mask */
         FALSE),                /* pcrel_offset */
@@ -1354,7 +1368,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         complain_overflow_signed, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_GD",       /* name */
-        TRUE,                  /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0x0000ffff,            /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
@@ -1369,7 +1383,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         complain_overflow_signed, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_LDM",      /* name */
-        TRUE,                  /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0x0000ffff,            /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
@@ -1384,7 +1398,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         complain_overflow_signed, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_DTPREL_HI16",      /* name */
-        TRUE,                  /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0x0000ffff,            /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
@@ -1399,7 +1413,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         complain_overflow_signed, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_DTPREL_LO16",      /* name */
-        TRUE,                  /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0x0000ffff,            /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
@@ -1414,13 +1428,27 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         complain_overflow_signed, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_GOTTPREL", /* name */
-        TRUE,                  /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0x0000ffff,            /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
+  /* TLS IE dynamic relocations.  */
   EMPTY_HOWTO (R_MIPS_TLS_TPREL32),
-  EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
+
+  HOWTO (R_MIPS_TLS_TPREL64,   /* type */
+        0,                     /* rightshift */
+        4,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont, /* complain_on_overflow */
+        _bfd_mips_elf_generic_reloc, /* special_function */
+        "R_MIPS_TLS_TPREL64",  /* name */
+        FALSE,                 /* partial_inplace */
+        MINUS_ONE,             /* src_mask */
+        MINUS_ONE,             /* dst_mask */
+        FALSE),                /* pcrel_offset */
 
   /* TLS thread pointer offset.  */
   HOWTO (R_MIPS_TLS_TPREL_HI16,        /* type */
@@ -1432,7 +1460,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         complain_overflow_signed, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_TPREL_HI16", /* name */
-        TRUE,                  /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0x0000ffff,            /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
@@ -1447,7 +1475,7 @@ static reloc_howto_type mips_elf64_howto_table_rela[] =
         complain_overflow_signed, /* complain_on_overflow */
         _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS_TLS_TPREL_LO16", /* name */
-        TRUE,                  /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0x0000ffff,            /* src_mask */
         0x0000ffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
@@ -2591,7 +2619,7 @@ mips_elf64_slurp_one_reloc_table (bfd *abfd, asection *asect,
            default:
              if (! used_sym)
                {
-                 if (rela.r_sym == 0)
+                 if (rela.r_sym == STN_UNDEF)
                    relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
                  else
                    {
@@ -2694,13 +2722,13 @@ mips_elf64_slurp_reloc_table (bfd *abfd, asection *asect,
          || asect->reloc_count == 0)
        return TRUE;
 
-      rel_hdr = &d->rel_hdr;
-      reloc_count = NUM_SHDR_ENTRIES (rel_hdr);
-      rel_hdr2 = d->rel_hdr2;
+      rel_hdr = d->rel.hdr;
+      reloc_count = rel_hdr ? NUM_SHDR_ENTRIES (rel_hdr) : 0;
+      rel_hdr2 = d->rela.hdr;
       reloc_count2 = (rel_hdr2 ? NUM_SHDR_ENTRIES (rel_hdr2) : 0);
 
       BFD_ASSERT (asect->reloc_count == reloc_count + reloc_count2);
-      BFD_ASSERT (asect->rel_filepos == rel_hdr->sh_offset
+      BFD_ASSERT ((rel_hdr && asect->rel_filepos == rel_hdr->sh_offset)
                  || (rel_hdr2 && asect->rel_filepos == rel_hdr2->sh_offset));
 
     }
@@ -2728,19 +2756,18 @@ mips_elf64_slurp_reloc_table (bfd *abfd, asection *asect,
   /* The slurp_one_reloc_table routine increments reloc_count.  */
   asect->reloc_count = 0;
 
-  if (! mips_elf64_slurp_one_reloc_table (abfd, asect,
-                                         rel_hdr, reloc_count,
-                                         relents,
-                                         symbols, dynamic))
+  if (rel_hdr != NULL
+      && ! mips_elf64_slurp_one_reloc_table (abfd, asect,
+                                            rel_hdr, reloc_count,
+                                            relents,
+                                            symbols, dynamic))
+    return FALSE;
+  if (rel_hdr2 != NULL
+      && ! mips_elf64_slurp_one_reloc_table (abfd, asect,
+                                            rel_hdr2, reloc_count2,
+                                            relents + reloc_count * 3,
+                                            symbols, dynamic))
     return FALSE;
-  if (d->rel_hdr2 != NULL)
-    {
-      if (! mips_elf64_slurp_one_reloc_table (abfd, asect,
-                                             rel_hdr2, reloc_count2,
-                                             relents + reloc_count * 3,
-                                             symbols, dynamic))
-       return FALSE;
-    }
 
   asect->relocation = relents;
   return TRUE;
@@ -2799,7 +2826,7 @@ mips_elf64_write_relocs (bfd *abfd, asection *sec, void *data)
        }
     }
 
-  rel_hdr = &elf_section_data (sec)->rel_hdr;
+  rel_hdr = _bfd_elf_single_rel_hdr (sec);
 
   /* Do the actual relocation.  */
 
@@ -3055,7 +3082,7 @@ elf64_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
 
        /* pr_pid */
-       elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32);
+       elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
 
        /* pr_reg */
        offset = 112;
@@ -3179,6 +3206,7 @@ const struct elf_size_info mips_elf64_size_info =
 };
 
 #define ELF_ARCH                       bfd_arch_mips
+#define ELF_TARGET_ID                  MIPS_ELF_DATA
 #define ELF_MACHINE_CODE               EM_MIPS
 
 #define elf_backend_collect            TRUE
@@ -3257,7 +3285,6 @@ const struct elf_size_info mips_elf64_size_info =
 #define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents
 #define bfd_elf64_bfd_get_relocated_section_contents \
                                _bfd_elf_mips_get_relocated_section_contents
-#define bfd_elf64_mkobject             _bfd_mips_elf_mkobject
 #define bfd_elf64_bfd_link_hash_table_create \
                                _bfd_mips_elf_link_hash_table_create
 #define bfd_elf64_bfd_final_link       _bfd_mips_elf_final_link
@@ -3286,6 +3313,7 @@ extern bfd_boolean bfd_elf64_archive_write_armap
 #define bfd_elf64_archive_truncate_arname \
                        _bfd_archive_coff_truncate_arname
 #define bfd_elf64_archive_read_ar_hdr  _bfd_archive_coff_read_ar_hdr
+#define bfd_elf64_archive_write_ar_hdr _bfd_archive_coff_write_ar_hdr
 #define bfd_elf64_archive_openr_next_archived_file \
                        _bfd_archive_coff_openr_next_archived_file
 #define bfd_elf64_archive_get_elt_at_index \
This page took 0.02783 seconds and 4 git commands to generate.