Set bfd_error to no_symbols if the symbols could not be read.
[deliverable/binutils-gdb.git] / bfd / elf32-v850.c
index c873ed9a651762fdb62b7fa501f7a95b6e30b1c8..07890c6a7cf5fe3a458a741b56f8d65816b290e0 100644 (file)
@@ -1,5 +1,5 @@
 /* V850-specific support for 32-bit ELF
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -64,14 +64,12 @@ static void v850_elf_final_write_processing
   PARAMS ((bfd *, boolean));
 static boolean v850_elf_set_private_flags
   PARAMS ((bfd *, flagword));
-static boolean v850_elf_copy_private_bfd_data
-  PARAMS ((bfd *, bfd *));
 static boolean v850_elf_merge_private_bfd_data
   PARAMS ((bfd *, bfd *));
 static boolean v850_elf_print_private_bfd_data
   PARAMS ((bfd *, PTR));
 static boolean v850_elf_section_from_bfd_section
-  PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *));
+  PARAMS ((bfd *, asection *, int *));
 static void v850_elf_symbol_processing
   PARAMS ((bfd *, asymbol *));
 static boolean v850_elf_add_symbol_hook
@@ -81,12 +79,12 @@ static boolean v850_elf_link_output_symbol_hook
   PARAMS ((bfd *, struct bfd_link_info *, const char *,
           Elf_Internal_Sym *, asection *));
 static boolean v850_elf_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
+  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static boolean v850_elf_gc_sweep_hook
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
           const Elf_Internal_Rela *));
 static asection * v850_elf_gc_mark_hook
-  PARAMS ((bfd *, struct bfd_link_info *,
+  PARAMS ((asection *, struct bfd_link_info *,
           Elf_Internal_Rela *, struct elf_link_hash_entry *,
           Elf_Internal_Sym *));
 
@@ -1324,7 +1322,7 @@ v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err)
                nop
        foo:
                nop      */
-  if (reloc->howto->pc_relative == true)
+  if (reloc->howto->pc_relative)
     {
       /* Here the variable relocation holds the final address of the
         symbol we are relocating against, plus any addend.  */
@@ -1531,6 +1529,9 @@ v850_elf_relocate_section (output_bfd, info, input_bfd, input_section,
   Elf_Internal_Rela *           rel;
   Elf_Internal_Rela *           relend;
 
+  if (info->relocateable)
+    return true;
+
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
 
@@ -1568,28 +1569,8 @@ v850_elf_relocate_section (output_bfd, info, input_bfd, input_section,
           || r_type == R_V850_GNU_VTINHERIT)
         continue;
 
-      howto = v850_elf_howto_table + r_type;
-
-      if (info->relocateable)
-       {
-         /* This is a relocateable link.  We don't have to change
-             anything, unless the reloc is against a section symbol,
-             in which case we have to adjust according to where the
-             section symbol winds up in the output section.  */
-         if (r_symndx < symtab_hdr->sh_info)
-           {
-             sym = local_syms + r_symndx;
-             if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
-               {
-                 sec = local_sections[r_symndx];
-                 rel->r_addend += sec->output_offset + sym->st_value;
-               }
-           }
-
-         continue;
-       }
-
       /* This is a final link.  */
+      howto = v850_elf_howto_table + r_type;
       h = NULL;
       sym = NULL;
       sec = NULL;
@@ -1742,8 +1723,8 @@ v850_elf_gc_sweep_hook (abfd, info, sec, relocs)
 }
 
 static asection *
-v850_elf_gc_mark_hook (abfd, info, rel, h, sym)
-       bfd *abfd;
+v850_elf_gc_mark_hook (sec, info, rel, h, sym)
+       asection *sec;
        struct bfd_link_info *info ATTRIBUTE_UNUSED;
        Elf_Internal_Rela *rel;
        struct elf_link_hash_entry *h;
@@ -1773,15 +1754,8 @@ v850_elf_gc_mark_hook (abfd, info, rel, h, sym)
        }
      }
    else
-     {
-       if (!(elf_bad_symtab (abfd)
-           && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
-         && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
-                && sym->st_shndx != SHN_COMMON))
-          {
-            return bfd_section_from_elf_index (abfd, sym->st_shndx);
-          }
-      }
+     return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
+
   return NULL;
 }
 
@@ -1837,28 +1811,6 @@ v850_elf_set_private_flags (abfd, flags)
   return true;
 }
 
-/* Copy backend specific data from one object module to another.  */
-
-static boolean
-v850_elf_copy_private_bfd_data (ibfd, obfd)
-     bfd * ibfd;
-     bfd * obfd;
-{
-  if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
-      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
-    return true;
-
-  BFD_ASSERT (!elf_flags_init (obfd)
-             || (elf_elfheader (obfd)->e_flags
-                 == elf_elfheader (ibfd)->e_flags));
-
-  elf_gp (obfd) = elf_gp (ibfd);
-  elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
-  elf_flags_init (obfd) = true;
-
-  return true;
-}
-
 /* Merge backend specific data from an object file
    to the output object file when linking.  */
 static boolean
@@ -1959,9 +1911,8 @@ static asymbol * v850_elf_zcom_symbol_ptr;
    corresponding ELF section index.  */
 
 static boolean
-v850_elf_section_from_bfd_section (abfd, hdr, sec, retval)
+v850_elf_section_from_bfd_section (abfd, sec, retval)
      bfd *                 abfd ATTRIBUTE_UNUSED;
-     Elf32_Internal_Shdr * hdr ATTRIBUTE_UNUSED;
      asection *            sec;
      int *                 retval;
 {
@@ -1985,9 +1936,9 @@ v850_elf_symbol_processing (abfd, asym)
      asymbol * asym;
 {
   elf_symbol_type * elfsym = (elf_symbol_type *) asym;
-  unsigned short index;
+  unsigned int indx;
 
-  index = elfsym->internal_elf_sym.st_shndx;
+  indx = elfsym->internal_elf_sym.st_shndx;
 
   /* If the section index is an "ordinary" index, then it may
      refer to a v850 specific section created by the assembler.
@@ -1995,26 +1946,26 @@ v850_elf_symbol_processing (abfd, asym)
 
      FIXME: Should we alter the st_shndx field as well ?  */
 
-  if (index < elf_elfheader(abfd)[0].e_shnum)
-    switch (elf_elfsections(abfd)[index]->sh_type)
+  if (indx < elf_numsections (abfd))
+    switch (elf_elfsections(abfd)[indx]->sh_type)
       {
       case SHT_V850_SCOMMON:
-       index = SHN_V850_SCOMMON;
+       indx = SHN_V850_SCOMMON;
        break;
 
       case SHT_V850_TCOMMON:
-       index = SHN_V850_TCOMMON;
+       indx = SHN_V850_TCOMMON;
        break;
 
       case SHT_V850_ZCOMMON:
-       index = SHN_V850_ZCOMMON;
+       indx = SHN_V850_ZCOMMON;
        break;
 
       default:
        break;
       }
 
-  switch (index)
+  switch (indx)
     {
     case SHN_V850_SCOMMON:
       if (v850_elf_scom_section.name == NULL)
@@ -2085,7 +2036,7 @@ v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
      asection **              secp;
      bfd_vma *                valp;
 {
-  int index = sym->st_shndx;
+  unsigned int indx = sym->st_shndx;
 
   /* If the section index is an "ordinary" index, then it may
      refer to a v850 specific section created by the assembler.
@@ -2093,26 +2044,26 @@ v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
 
      FIXME: Should we alter the st_shndx field as well ?  */
 
-  if (index < elf_elfheader(abfd)[0].e_shnum)
-    switch (elf_elfsections(abfd)[index]->sh_type)
+  if (indx < elf_numsections (abfd))
+    switch (elf_elfsections(abfd)[indx]->sh_type)
       {
       case SHT_V850_SCOMMON:
-       index = SHN_V850_SCOMMON;
+       indx = SHN_V850_SCOMMON;
        break;
 
       case SHT_V850_TCOMMON:
-       index = SHN_V850_TCOMMON;
+       indx = SHN_V850_TCOMMON;
        break;
 
       case SHT_V850_ZCOMMON:
-       index = SHN_V850_ZCOMMON;
+       indx = SHN_V850_ZCOMMON;
        break;
 
       default:
        break;
       }
 
-  switch (index)
+  switch (indx)
     {
     case SHN_V850_SCOMMON:
       *secp = bfd_make_section_old_way (abfd, ".scommon");
@@ -2165,7 +2116,7 @@ static boolean
 v850_elf_section_from_shdr (abfd, hdr, name)
      bfd *               abfd;
      Elf_Internal_Shdr * hdr;
-     char *              name;
+     const char *        name;
 {
   /* There ought to be a place to keep ELF backend specific flags, but
      at the moment there isn't one.  We just keep track of the
@@ -2240,10 +2191,10 @@ v850_elf_fake_sections (abfd, hdr, sec)
 #define elf_backend_gc_sweep_hook               v850_elf_gc_sweep_hook
 
 #define elf_backend_can_gc_sections 1
+#define elf_backend_rela_normal 1
 
 #define bfd_elf32_bfd_is_local_label_name      v850_elf_is_local_label_name
 #define bfd_elf32_bfd_reloc_type_lookup                v850_elf_reloc_type_lookup
-#define bfd_elf32_bfd_copy_private_bfd_data    v850_elf_copy_private_bfd_data
 #define bfd_elf32_bfd_merge_private_bfd_data   v850_elf_merge_private_bfd_data
 #define bfd_elf32_bfd_set_private_flags                v850_elf_set_private_flags
 #define bfd_elf32_bfd_print_private_bfd_data   v850_elf_print_private_bfd_data
This page took 0.026631 seconds and 4 git commands to generate.