2000-12-07 Kazu Hirata <kazu@hxi.com>
[binutils-gdb.git] / bfd / elf32-mips.c
index 4b0b641de31e6abafe05e38f298cf2e4df9e7e3f..4a44ae2e7bef9b93f52a57d60e7e8388918fe7b7 100644 (file)
@@ -1846,6 +1846,9 @@ elf_mips_mach (flags)
     case E_MIPS_MACH_MIPS32_4K:
       return bfd_mach_mips32_4k;
 
+    case E_MIPS_MACH_SB1:
+      return bfd_mach_mips_sb1;
+
     default:
       switch (flags & EF_MIPS_ARCH)
        {
@@ -2369,6 +2372,10 @@ _bfd_mips_elf_final_write_processing (abfd, linker)
     case bfd_mach_mips64:
       val = E_MIPS_ARCH_64;
       break;
+
+    case bfd_mach_mips_sb1:
+      val = E_MIPS_ARCH_64 | E_MIPS_MACH_SB1;
+      break;
     }
 
   elf_elfheader (abfd)->e_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
@@ -2490,6 +2497,8 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd)
   flagword old_flags;
   flagword new_flags;
   boolean ok;
+  boolean null_input_bfd = true;
+  asection *sec;
 
   /* Check if we have the same endianess */
   if (_bfd_generic_verify_endian_match (ibfd, obfd) == false)
@@ -2529,6 +2538,27 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd)
   if (new_flags == old_flags)
     return true;
 
+  /* Check to see if the input BFD actually contains any sections.
+     If not, its flags may not have been initialised either, but it cannot
+     actually cause any incompatibility.  */
+  for (sec = ibfd->sections; sec != NULL; sec = sec->next)
+    {
+      /* Ignore synthetic sections and empty .text, .data and .bss sections
+         which are automatically generated by gas.  */
+      if (strcmp (sec->name, ".reginfo")
+         && strcmp (sec->name, ".mdebug")
+         && ((!strcmp (sec->name, ".text")
+              || !strcmp (sec->name, ".data")
+              || !strcmp (sec->name, ".bss"))
+             && sec->_raw_size != 0))
+       {
+         null_input_bfd = false;
+         break;
+       }
+    }
+  if (null_input_bfd)
+    return true;
+
   ok = true;
 
   if ((new_flags & EF_MIPS_PIC) != (old_flags & EF_MIPS_PIC))