* srconv.c (wr_tr): Write out handcrafted tr block.
[deliverable/binutils-gdb.git] / bfd / elf32-mips.c
index 9ec539382448bd393fd2817dc6b0f9b643c9f2ab..09f144fee9bc65f7074788459499f56e6d337e91 100644 (file)
@@ -18,7 +18,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
@@ -84,6 +84,8 @@ static boolean mips_elf_section_processing
 static void mips_elf_symbol_processing PARAMS ((bfd *, asymbol *));
 static boolean mips_elf_read_ecoff_info
   PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
+static boolean mips_elf_is_local_label
+  PARAMS ((bfd *, asymbol *));
 static boolean mips_elf_find_nearest_line
   PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
           const char **, unsigned int *));
@@ -791,8 +793,8 @@ mips_elf_gprel16_reloc (abfd,
        }
     }
 
-  return gprel16_with_gp (symbol, reloc_entry, input_section, relocateable,
-                         data, elf_gp (output_bfd));
+  return gprel16_with_gp (abfd, symbol, reloc_entry, input_section,
+                         relocateable, data, elf_gp (output_bfd));
 }
 
 static bfd_reloc_status_type
@@ -1016,27 +1018,8 @@ mips_elf_object_p (abfd)
 
   /* Irix 5 is broken.  Object file symbol tables are not always
      sorted correctly such that local symbols precede global symbols,
-     and the sh_info field in the symbol table is not always right.
-     We try to quickly check whether the symbol table is broken for
-     this BFD, and, if it is, we set elf_bad_symtab in tdata.  */
-  if (elf_onesymtab (abfd) != 0)
-    {
-      Elf_Internal_Shdr *symtab_hdr;
-      Elf32_External_Sym esym;
-
-      symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-      if (bfd_seek (abfd,
-                   (symtab_hdr->sh_offset
-                    + symtab_hdr->sh_size
-                    - sizeof (Elf32_External_Sym)),
-                   SEEK_SET) != 0
-         || (bfd_read ((PTR) &esym, 1, sizeof (Elf32_External_Sym), abfd)
-             != sizeof (Elf32_External_Sym)))
-       return false;
-      if (ELF_ST_BIND (bfd_h_get_8 (abfd, (bfd_byte *) esym.st_info))
-         == STB_LOCAL)
-       elf_bad_symtab (abfd) = true;
-    }
+     and the sh_info field in the symbol table is not always right.  */
+  elf_bad_symtab (abfd) = true;
 
   return true;
 }
@@ -1426,7 +1409,7 @@ mips_elf_read_ecoff_info (abfd, section, debug)
 
   swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
 
-  ext_hdr = (char *) malloc (swap->external_hdr_size);
+  ext_hdr = (char *) malloc ((size_t) swap->external_hdr_size);
   if (ext_hdr == NULL && swap->external_hdr_size != 0)
     {
       bfd_set_error (bfd_error_no_memory);
@@ -1448,7 +1431,7 @@ mips_elf_read_ecoff_info (abfd, section, debug)
     debug->ptr = NULL;                                                 \
   else                                                                 \
     {                                                                  \
-      debug->ptr = (type) malloc (size * symhdr->count);               \
+      debug->ptr = (type) malloc ((size_t) (size * symhdr->count));    \
       if (debug->ptr == NULL)                                          \
        {                                                               \
          bfd_set_error (bfd_error_no_memory);                          \
@@ -1507,6 +1490,17 @@ mips_elf_read_ecoff_info (abfd, section, debug)
   return false;
 }
 \f
+/* MIPS ELF local labels start with '$', not 'L'.  */
+
+/*ARGSUSED*/
+static boolean
+mips_elf_is_local_label (abfd, symbol)
+     bfd *abfd;
+     asymbol *symbol;
+{
+  return symbol->name[0] == '$';
+}
+
 /* MIPS ELF uses a special find_nearest_line routine in order the
    handle the ECOFF debugging information.  */
 
@@ -1593,9 +1587,9 @@ mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
 
   /* Fall back on the generic ELF find_nearest_line routine.  */
 
-  return bfd_elf32_find_nearest_line (abfd, section, symbols, offset,
-                                     filename_ptr, functionname_ptr,
-                                     line_ptr);
+  return _bfd_elf_find_nearest_line (abfd, section, symbols, offset,
+                                    filename_ptr, functionname_ptr,
+                                    line_ptr);
 }
 \f
 /* The MIPS ELF linker needs additional information for each symbol in
@@ -2719,9 +2713,9 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                  name = h->root.root.string;
                else
                  {
-                   name = elf_string_from_elf_section (input_bfd,
-                                                       symtab_hdr->sh_link,
-                                                       sym->st_name);
+                   name = bfd_elf_string_from_elf_section (input_bfd,
+                                                           symtab_hdr->sh_link,
+                                                           sym->st_name);
                    if (name == NULL)
                      return false;
                    if (*name == '\0')
@@ -2794,7 +2788,7 @@ elf32_mips_get_relocated_section_contents (abfd, link_info, link_order, data,
       arelent **parent;
       /* for mips */
       int gp_found;
-      bfd_vma gp;
+      bfd_vma gp = 0x12345678; /* initialize just to shut gcc up */
 
       {
        struct bfd_hash_entry *h;
@@ -2805,7 +2799,7 @@ elf32_mips_get_relocated_section_contents (abfd, link_info, link_order, data,
          lh = 0;
        else
          {
-           h = bfd_hash_lookup (link_info->hash, "_gp", false, false);
+           h = bfd_hash_lookup (&link_info->hash->table, "_gp", false, false);
            lh = (struct bfd_link_hash_entry *) h;
          }
       lookup:
@@ -2990,6 +2984,7 @@ static const struct ecoff_debug_swap mips_elf_ecoff_debug_swap =
                                        mips_elf_final_write_processing
 #define elf_backend_ecoff_debug_swap   &mips_elf_ecoff_debug_swap
 
+#define bfd_elf32_bfd_is_local_label   mips_elf_is_local_label
 #define bfd_elf32_find_nearest_line    mips_elf_find_nearest_line
 
 #define bfd_elf32_bfd_link_hash_table_create \
This page took 0.025348 seconds and 4 git commands to generate.