bfd/
authorRichard Sandiford <rdsandiford@googlemail.com>
Thu, 7 Aug 2008 20:03:25 +0000 (20:03 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Thu, 7 Aug 2008 20:03:25 +0000 (20:03 +0000)
* elf-bfd.h (MIPS_ELF_TDATA): New elf_object_id.
* elf32-mips.c (bfd_elf32_mkobject): Define.
* elf64-mips.c (bfd_elf64_mkobject): Likewise.
* elfn32-mips.c (bfd_elf32_mkobject): Likewise.
* elfxx-mips.h (_bfd_mips_elf_mkobject): Declare.
* elfxx-mips.c (is_mips_elf): New macro.
(_bfd_mips_elf_mkobject): New function.
(_bfd_mips_elf_final_link): Use is_mips_elf.
(_bfd_mips_elf_merge_private_bfd_data): Likewise.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf32-mips.c
bfd/elf64-mips.c
bfd/elfn32-mips.c
bfd/elfxx-mips.c
bfd/elfxx-mips.h

index 9b6d8088ed7e0f7d30b6193230b11157cd75158b..98ec7e7a70d1d41128c238fe0913ddf3969fa5e0 100644 (file)
@@ -1,3 +1,15 @@
+2008-08-07  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * elf-bfd.h (MIPS_ELF_TDATA): New elf_object_id.
+       * elf32-mips.c (bfd_elf32_mkobject): Define.
+       * elf64-mips.c (bfd_elf64_mkobject): Likewise.
+       * elfn32-mips.c (bfd_elf32_mkobject): Likewise.
+       * elfxx-mips.h (_bfd_mips_elf_mkobject): Declare.
+       * elfxx-mips.c (is_mips_elf): New macro.
+       (_bfd_mips_elf_mkobject): New function.
+       (_bfd_mips_elf_final_link): Use is_mips_elf.
+       (_bfd_mips_elf_merge_private_bfd_data): Likewise.
+
 2008-08-07  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * elfxx-mips.c (mips_elf_record_relocs): Defer allocation of a
index 2d59ea444f8b83f4ef3f25b23c3ef1d4ba3109a4..d1772557b8fb6f0b4ce68add2b6db14725b50b98 100644 (file)
@@ -1408,6 +1408,7 @@ enum elf_object_id
   ARM_ELF_TDATA,
   HPPA_ELF_TDATA,
   I386_ELF_TDATA,
+  MIPS_ELF_TDATA,
   PPC32_ELF_TDATA,
   PPC64_ELF_TDATA,
   S390_ELF_TDATA,
index 526c222f5433f9924983d3603371e673aa6f9de2..e04e797c8069000774083589558e59f6ea51058f 100644 (file)
@@ -1630,6 +1630,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
 #define bfd_elf32_bfd_get_relocated_section_contents \
                                _bfd_elf_mips_get_relocated_section_contents
+#define bfd_elf32_mkobject             _bfd_mips_elf_mkobject
 #define bfd_elf32_bfd_link_hash_table_create \
                                        _bfd_mips_elf_link_hash_table_create
 #define bfd_elf32_bfd_final_link       _bfd_mips_elf_final_link
index f79d889bb3ff5661c036c3891803d5f4f905d43f..61db0f8cd17df16349a8ad7ec88ce01c0bf00d63 100644 (file)
@@ -3210,6 +3210,7 @@ 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
index 63734f8d5c745a3fbe8f75b18a28a0c4490c12a8..4e8a8d7a58c9e549b4ad36b8601f12dadcd835ff 100644 (file)
@@ -2458,6 +2458,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
 #define bfd_elf32_bfd_get_relocated_section_contents \
                                _bfd_elf_mips_get_relocated_section_contents
+#define bfd_elf32_mkobject             _bfd_mips_elf_mkobject
 #define bfd_elf32_bfd_link_hash_table_create \
                                        _bfd_mips_elf_link_hash_table_create
 #define bfd_elf32_bfd_final_link       _bfd_mips_elf_final_link
index 4e1481b2b6b906ca96829c6e4340687e1153f35d..5c87ecde07adcef380b48fc799b9c46fcba74ab3 100644 (file)
@@ -243,6 +243,11 @@ struct _mips_elf_section_data
 #define mips_elf_section_data(sec) \
   ((struct _mips_elf_section_data *) elf_section_data (sec))
 
+#define is_mips_elf(bfd)                               \
+  (bfd_get_flavour (bfd) == bfd_target_elf_flavour     \
+   && elf_tdata (bfd) != NULL                          \
+   && elf_object_id (bfd) == MIPS_ELF_TDATA)
+
 /* The ABI says that every symbol used by dynamic relocations must have
    a global GOT entry.  Among other things, this provides the dynamic
    linker with a free, directly-indexed cache.  The GOT can therefore
@@ -10640,6 +10645,15 @@ error_return:
   return NULL;
 }
 \f
+/* Allocate ABFD's target-dependent data.  */
+
+bfd_boolean
+_bfd_mips_elf_mkobject (bfd *abfd)
+{
+  return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata),
+                                 MIPS_ELF_TDATA);
+}
+
 /* Create a MIPS ELF linker hash table.  */
 
 struct bfd_link_hash_table *
@@ -10936,9 +10950,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info)
              input_section = p->u.indirect.section;
              input_bfd = input_section->owner;
 
-             if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
-                 || (get_elf_backend_data (input_bfd)
-                     ->elf_backend_ecoff_debug_swap) == NULL)
+             if (!is_mips_elf (input_bfd))
                {
                  /* I don't know what a non MIPS ELF bfd would be
                     doing with a .mdebug section, but I don't really
@@ -11611,8 +11623,7 @@ _bfd_mips_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
       return FALSE;
     }
 
-  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
-      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+  if (!is_mips_elf (ibfd) || !is_mips_elf (obfd))
     return TRUE;
 
   if (strcmp (bfd_get_target (ibfd), bfd_get_target (obfd)) != 0)
index 659c418cf4d8620ceb3903b7f3dd77a494e114a0..5b791731369acd8eb95478db369fd250b9bff3fb 100644 (file)
@@ -93,6 +93,8 @@ extern bfd_boolean _bfd_mips_elf_set_section_contents
 extern bfd_byte *_bfd_elf_mips_get_relocated_section_contents
   (bfd *, struct bfd_link_info *, struct bfd_link_order *,
    bfd_byte *, bfd_boolean, asymbol **);
+extern bfd_boolean _bfd_mips_elf_mkobject
+  (bfd *);
 extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
   (bfd *);
 extern struct bfd_link_hash_table *_bfd_mips_vxworks_link_hash_table_create