* configure: Ignore new autoconf configure options.
[binutils-gdb.git] / bfd / elf32-mips.c
index 09f144fee9bc65f7074788459499f56e6d337e91..118ebb07b39a3df3f8c5b8c7cee4e485628f6b9c 100644 (file)
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "libbfd.h"
 #include "bfdlink.h"
 #include "genlink.h"
-#include "libelf.h"
+#include "elf-bfd.h"
 #include "elf/mips.h"
 
 /* Get the ECOFF swapping routines.  */
@@ -882,7 +882,7 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, code)
      bfd *abfd;
      bfd_reloc_code_real_type code;
 {
-  int i;
+  unsigned int i;
 
   for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map); i++)
     {
@@ -1352,7 +1352,7 @@ mips_elf_symbol_processing (abfd, asym)
        {
          /* Initialize the acommon section.  */
          mips_elf_acom_section.name = ".acommon";
-         mips_elf_acom_section.flags = SEC_NO_FLAGS;
+         mips_elf_acom_section.flags = SEC_ALLOC;
          mips_elf_acom_section.output_section = &mips_elf_acom_section;
          mips_elf_acom_section.symbol = &mips_elf_acom_symbol;
          mips_elf_acom_section.symbol_ptr_ptr = &mips_elf_acom_symbol_ptr;
@@ -1526,10 +1526,18 @@ mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
   msec = bfd_get_section_by_name (abfd, ".mdebug");
   if (msec != NULL)
     {
+      flagword origflags;
       struct mips_elf_find_line *fi;
       const struct ecoff_debug_swap * const swap =
        get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
 
+      /* If we are called during a link, mips_elf_final_link may have
+        cleared the SEC_HAS_CONTENTS field.  We force it back on here
+        if appropriate (which it normally will be).  */
+      origflags = msec->flags;
+      if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS)
+       msec->flags |= SEC_HAS_CONTENTS;
+
       fi = elf_tdata (abfd)->find_line_info;
       if (fi == NULL)
        {
@@ -1542,14 +1550,17 @@ mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
                bfd_alloc (abfd, sizeof (struct mips_elf_find_line)));
          if (fi == NULL)
            {
-             bfd_set_error (bfd_error_no_memory);
+             msec->flags = origflags;
              return false;
            }
 
          memset (fi, 0, sizeof (struct mips_elf_find_line));
 
          if (! mips_elf_read_ecoff_info (abfd, msec, &fi->d))
-           return false;
+           {
+             msec->flags = origflags;
+             return false;
+           }
 
          /* Swap in the FDR information.  */
          fi->d.fdr = ((struct fdr *)
@@ -1558,7 +1569,7 @@ mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
                                   sizeof (struct fdr))));
          if (fi->d.fdr == NULL)
            {
-             bfd_set_error (bfd_error_no_memory);
+             msec->flags = origflags;
              return false;
            }
          external_fdr_size = swap->external_fdr_size;
@@ -1582,7 +1593,12 @@ mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
       if (_bfd_ecoff_locate_line (abfd, section, offset, &fi->d, swap,
                                  &fi->i, filename_ptr, functionname_ptr,
                                  line_ptr))
-       return true;
+       {
+         msec->flags = origflags;
+         return true;
+       }
+
+      msec->flags = origflags;
     }
 
   /* Fall back on the generic ELF find_nearest_line routine.  */
@@ -1651,10 +1667,7 @@ mips_elf_link_hash_newfunc (entry, table, string)
           bfd_hash_allocate (table,
                              sizeof (struct mips_elf_link_hash_entry)));
   if (ret == (struct mips_elf_link_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_hash_entry *) ret;
-    }
+    return (struct bfd_hash_entry *) ret;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct mips_elf_link_hash_entry *)
@@ -1683,10 +1696,7 @@ mips_elf_link_hash_table_create (abfd)
   ret = ((struct mips_elf_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct mips_elf_link_hash_table)));
   if (ret == (struct mips_elf_link_hash_table *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
                                       mips_elf_link_hash_newfunc))
@@ -2208,6 +2218,9 @@ mips_elf_final_link (abfd, info)
            gptab_bss_sec = o;
          else
            {
+             (*_bfd_error_handler)
+               ("%s: illegal section name `%s'",
+                bfd_get_filename (abfd), o->name);
              bfd_set_error (bfd_error_nonrepresentable_section);
              return false;
            }
@@ -2354,7 +2367,6 @@ mips_elf_final_link (abfd, info)
                     bfd_alloc (abfd, c * sizeof (Elf32_External_gptab)));
          if (ext_tab == NULL)
            {
-             bfd_set_error (bfd_error_no_memory);
              free (tab);
              return false;
            }
@@ -2525,7 +2537,7 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section,
     {
       int r_type;
       reloc_howto_type *howto;
-      long r_symndx;
+      unsigned long r_symndx;
       bfd_vma addend;
       struct elf_link_hash_entry *h;
       asection *sec;