* elf32-arm.c (STUB_ENTRY_NAME): Define.
[deliverable/binutils-gdb.git] / bfd / elf32-bfin.c
index 72604cf44d618f5da77172ace3f4ee82cf105e87..f83abd28acc6d89d2bd9298d43d8f8026741e8ff 100644 (file)
@@ -5,7 +5,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
 
    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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
-   USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/bfin.h"
@@ -716,7 +716,7 @@ static reloc_howto_type bfin_howto_table [] =
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_BFIN_GOT12",                /* name */
+        "R_BFIN_GOT17M4",      /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
@@ -1057,8 +1057,8 @@ bfin_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 
   else
     cache_ptr->howto = (reloc_howto_type *) NULL;
-
 }
+
 /* Given a BFD reloc type, return the howto.  */
 static reloc_howto_type *
 bfin_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
@@ -1078,8 +1078,33 @@ bfin_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
    return &bfin_gnuext_howto_table [r_type - BFIN_GNUEXT_RELOC_MIN];
 
   return (reloc_howto_type *) NULL;
+}
+
+static reloc_howto_type *
+bfin_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                           const char *r_name)
+{
+  unsigned int i;
 
+  for (i = 0;
+       i < (sizeof (bfin_howto_table)
+           / sizeof (bfin_howto_table[0]));
+       i++)
+    if (bfin_howto_table[i].name != NULL
+       && strcasecmp (bfin_howto_table[i].name, r_name) == 0)
+      return &bfin_howto_table[i];
+
+  for (i = 0;
+       i < (sizeof (bfin_gnuext_howto_table)
+           / sizeof (bfin_gnuext_howto_table[0]));
+       i++)
+    if (bfin_gnuext_howto_table[i].name != NULL
+       && strcasecmp (bfin_gnuext_howto_table[i].name, r_name) == 0)
+      return &bfin_gnuext_howto_table[i];
+
+  return NULL;
 }
+
 /* Given a bfin relocation type, return the howto.  */
 static reloc_howto_type *
 bfin_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
@@ -1092,7 +1117,6 @@ bfin_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
    return &bfin_gnuext_howto_table [r_type - BFIN_GNUEXT_RELOC_MIN];
 
   return (reloc_howto_type *) NULL;
-
 }
 
 /* Return TRUE if the name is a local label.
@@ -1218,26 +1242,26 @@ struct bfinfdpic_relocs_info
   /* The following 2 fields record whether the symbol+addend above was
      ever referenced with a GOT relocation.  The 17M4 suffix indicates a
      GOT17M4 relocation; hilo is used for GOTLO/GOTHI pairs.  */
-  unsigned got17m4:1;
-  unsigned gothilo:1;
+  unsigned got17m4;
+  unsigned gothilo;
   /* Whether a FUNCDESC relocation references symbol+addend.  */
-  unsigned fd:1;
+  unsigned fd;
   /* Whether a FUNCDESC_GOT relocation references symbol+addend.  */
-  unsigned fdgot17m4:1;
-  unsigned fdgothilo:1;
+  unsigned fdgot17m4;
+  unsigned fdgothilo;
   /* Whether a FUNCDESC_GOTOFF relocation references symbol+addend.  */
-  unsigned fdgoff17m4:1;
-  unsigned fdgoffhilo:1;
+  unsigned fdgoff17m4;
+  unsigned fdgoffhilo;
   /* Whether symbol+addend is referenced with GOTOFF17M4, GOTOFFLO or
      GOTOFFHI relocations.  The addend doesn't really matter, since we
      envision that this will only be used to check whether the symbol
      is mapped to the same segment as the got.  */
-  unsigned gotoff:1;
+  unsigned gotoff;
   /* Whether symbol+addend is referenced by a LABEL24 relocation.  */
-  unsigned call:1;
+  unsigned call;
   /* Whether symbol+addend is referenced by a 32 or FUNCDESC_VALUE
      relocation.  */
-  unsigned sym:1;
+  unsigned sym;
   /* Whether we need a PLT entry for a symbol.  Should be implied by
      something like:
      (call && symndx == -1 && ! BFINFDPIC_SYM_LOCAL (info, d.h))  */
@@ -1473,26 +1497,9 @@ _bfinfdpic_add_rofixup (bfd *output_bfd, asection *rofixup, bfd_vma offset,
 static unsigned
 _bfinfdpic_osec_to_segment (bfd *output_bfd, asection *osec)
 {
-  struct elf_segment_map *m;
-  Elf_Internal_Phdr *p;
-
-  /* Find the segment that contains the output_section.  */
-  for (m = elf_tdata (output_bfd)->segment_map,
-        p = elf_tdata (output_bfd)->phdr;
-       m != NULL;
-       m = m->next, p++)
-    {
-      int i;
-
-      for (i = m->count - 1; i >= 0; i--)
-       if (m->sections[i] == osec)
-         break;
-
-      if (i >= 0)
-       break;
-    }
+  Elf_Internal_Phdr *p = _bfd_elf_find_segment_containing_section (output_bfd, osec);
 
-  return p - elf_tdata (output_bfd)->phdr;
+  return (p != NULL) ? p - elf_tdata (output_bfd)->phdr : -1;
 }
 
 inline static bfd_boolean
@@ -1955,7 +1962,9 @@ bfin_check_relocs (bfd * abfd,
         /* This relocation describes which C++ vtable entries
            are actually used.  Record for later use during GC.  */
         case R_BFIN_GNU_VTENTRY:
-          if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+          BFD_ASSERT (h != NULL);
+          if (h != NULL
+              && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
             return FALSE;
           break;
 
@@ -2060,6 +2069,60 @@ elf32_bfin_reloc_type_class (const Elf_Internal_Rela * rela)
       return reloc_class_normal;
     }
 }
+\f
+static bfd_reloc_status_type
+bfin_final_link_relocate (Elf_Internal_Rela *rel, reloc_howto_type *howto,
+                         bfd *input_bfd, asection *input_section,
+                         bfd_byte *contents, bfd_vma address,
+                         bfd_vma value, bfd_vma addend)
+{
+  int r_type = ELF32_R_TYPE (rel->r_info);
+
+  if (r_type == R_pcrel24 || r_type == R_pcrel24_jump_l)
+    {
+      bfd_reloc_status_type r = bfd_reloc_ok;
+      bfd_vma x;
+
+      if (address > bfd_get_section_limit (input_bfd, input_section))
+       return bfd_reloc_outofrange;
+
+      value += addend;
+
+      /* Perform usual pc-relative correction.  */
+      value -= input_section->output_section->vma + input_section->output_offset;
+      value -= address;
+
+      /* We are getting reloc_entry->address 2 byte off from
+        the start of instruction. Assuming absolute postion
+        of the reloc data. But, following code had been written assuming
+        reloc address is starting at begining of instruction.
+        To compensate that I have increased the value of
+        relocation by 1 (effectively 2) and used the addr -2 instead of addr.  */
+
+      value += 2;
+      address -= 2;
+
+      if ((value & 0xFF000000) != 0
+         && (value & 0xFF000000) != 0xFF000000)
+       r = bfd_reloc_overflow;
+
+      value >>= 1;
+
+      x = bfd_get_16 (input_bfd, contents + address);
+      x = (x & 0xff00) | ((value >> 16) & 0xff);
+      bfd_put_16 (input_bfd, x, contents + address);
+
+      x = bfd_get_16 (input_bfd, contents + address + 2);
+      x = value & 0xFFFF;
+      bfd_put_16 (input_bfd, x, contents + address + 2);
+      return r;
+    }
+
+  return _bfd_final_link_relocate (howto, input_bfd, input_section, contents,
+                                  rel->r_offset, value, addend);
+
+}
+
 \f
 /* Relocate an Blackfin ELF section.
 
@@ -2470,6 +2533,9 @@ bfinfdpic_relocate_section (bfd * output_bfd,
          {
            int dynindx;
            bfd_vma addend = rel->r_addend;
+           bfd_vma offset;
+           offset = _bfd_elf_section_offset (output_bfd, info,
+                                             input_section, rel->r_offset);
 
            /* If the symbol is dynamic but binds locally, use
               section+offset.  */
@@ -2526,25 +2592,34 @@ bfinfdpic_relocate_section (bfd * output_bfd,
                      }
                    if (!h || h->root.type != bfd_link_hash_undefweak)
                      {
-                       _bfinfdpic_add_rofixup (output_bfd,
-                                              bfinfdpic_gotfixup_section
-                                              (info),
-                                              _bfd_elf_section_offset
-                                              (output_bfd, info,
-                                               input_section, rel->r_offset)
-                                              + input_section
-                                              ->output_section->vma
-                                              + input_section->output_offset,
-                                              picrel);
+                       /* Only output a reloc for a not deleted entry.  */
+                       if (offset >= (bfd_vma)-2)
+                         _bfinfdpic_add_rofixup (output_bfd,
+                                                 bfinfdpic_gotfixup_section
+                                                 (info), -1, picrel);
+                       else
+                         _bfinfdpic_add_rofixup (output_bfd,
+                                                 bfinfdpic_gotfixup_section
+                                                 (info),
+                                                 offset + input_section
+                                                 ->output_section->vma
+                                                 + input_section->output_offset,
+                                                 picrel);
+
                        if (r_type == R_BFIN_FUNCDESC_VALUE)
-                         _bfinfdpic_add_rofixup
-                           (output_bfd,
-                            bfinfdpic_gotfixup_section (info),
-                            _bfd_elf_section_offset
-                            (output_bfd, info,
-                             input_section, rel->r_offset)
-                            + input_section->output_section->vma
-                            + input_section->output_offset + 4, picrel);
+                         {
+                           if (offset >= (bfd_vma)-2)
+                             _bfinfdpic_add_rofixup
+                               (output_bfd,
+                                bfinfdpic_gotfixup_section (info),
+                                -1, picrel);
+                           else
+                             _bfinfdpic_add_rofixup
+                               (output_bfd,
+                                bfinfdpic_gotfixup_section (info),
+                                offset + input_section->output_section->vma
+                                + input_section->output_offset + 4, picrel);
+                         }
                      }
                  }
              }
@@ -2564,15 +2639,19 @@ bfinfdpic_relocate_section (bfd * output_bfd,
                           name, input_bfd, input_section, rel->r_offset);
                        return FALSE;
                      }
-                   _bfinfdpic_add_dyn_reloc (output_bfd,
-                                             bfinfdpic_gotrel_section (info),
-                                             _bfd_elf_section_offset
-                                             (output_bfd, info,
-                                              input_section, rel->r_offset)
-                                             + input_section
-                                             ->output_section->vma
-                                             + input_section->output_offset,
-                                             r_type, dynindx, addend, picrel);
+                   /* Only output a reloc for a not deleted entry.  */
+                   if (offset >= (bfd_vma)-2)
+                     _bfinfdpic_add_dyn_reloc (output_bfd,
+                                               bfinfdpic_gotrel_section (info),
+                                               0, R_unused0, dynindx, addend, picrel);
+                   else
+                     _bfinfdpic_add_dyn_reloc (output_bfd,
+                                               bfinfdpic_gotrel_section (info),
+                                               offset
+                                               + input_section
+                                               ->output_section->vma
+                                               + input_section->output_offset,
+                                               r_type, dynindx, addend, picrel);
                  }
                else if (osec)
                  addend += osec->output_section->vma;
@@ -2582,7 +2661,7 @@ bfinfdpic_relocate_section (bfd * output_bfd,
                relocation = addend - rel->r_addend;
              }
 
-           if (r_type == R_BFIN_FUNCDESC_VALUE)
+           if (r_type == R_BFIN_FUNCDESC_VALUE && offset < (bfd_vma)-2)
              {
                /* If we've omitted the dynamic relocation, just emit
                   the fixed addresses of the symbol and of the local
@@ -2712,43 +2791,9 @@ bfinfdpic_relocate_section (bfd * output_bfd,
          break;
        }
 
-      if (r_type == R_pcrel24
-         || r_type == R_pcrel24_jump_l)
-       {
-         bfd_vma x;
-         bfd_vma address = rel->r_offset;
-
-         relocation += rel->r_addend;
-
-         /* Perform usual pc-relative correction.  */
-         relocation -= input_section->output_section->vma + input_section->output_offset;
-         relocation -= address;
-
-         /* We are getting reloc_entry->address 2 byte off from
-            the start of instruction. Assuming absolute postion
-            of the reloc data. But, following code had been written assuming
-            reloc address is starting at begining of instruction.
-            To compensate that I have increased the value of
-            relocation by 1 (effectively 2) and used the addr -2 instead of addr.  */
-
-         relocation += 2;
-         address -= 2;
-
-         relocation >>= 1;
-
-         x = bfd_get_16 (input_bfd, contents + address);
-         x = (x & 0xff00) | ((relocation >> 16) & 0xff);
-         bfd_put_16 (input_bfd, x, contents + address);
-
-         x = bfd_get_16 (input_bfd, contents + address + 2);
-         x = relocation & 0xFFFF;
-         bfd_put_16 (input_bfd, x, contents + address + 2);
-         r = bfd_reloc_ok;
-       }
-      else
-       r = _bfd_final_link_relocate (howto, input_bfd, input_section,
-                                     contents, rel->r_offset,
-                                     relocation, rel->r_addend);
+      r = bfin_final_link_relocate (rel, howto, input_bfd, input_section,
+                                   contents, rel->r_offset,
+                                   relocation, rel->r_addend);
 
       if (r != bfd_reloc_ok)
        {
@@ -2915,6 +2960,14 @@ bfin_relocate_section (bfd * output_bfd,
          {
            bfd_vma off;
 
+         if (dynobj == NULL)
+           {
+             /* Create the .got section.  */
+             elf_hash_table (info)->dynobj = dynobj = output_bfd;
+             if (!_bfd_elf_create_got_section (dynobj, info))
+               return FALSE;
+           }
+
            if (sgot == NULL)
              {
                sgot = bfd_get_section_by_name (dynobj, ".got");
@@ -3006,43 +3059,9 @@ bfin_relocate_section (bfd * output_bfd,
          }
          goto do_default;
 
-       case R_pcrel24:
-       case R_pcrel24_jump_l:
-         {
-           bfd_vma x;
-
-           relocation += rel->r_addend;
-
-           /* Perform usual pc-relative correction.  */
-           relocation -= input_section->output_section->vma + input_section->output_offset;
-           relocation -= address;
-
-           /* We are getting reloc_entry->address 2 byte off from
-              the start of instruction. Assuming absolute postion
-              of the reloc data. But, following code had been written assuming
-              reloc address is starting at begining of instruction.
-              To compensate that I have increased the value of
-              relocation by 1 (effectively 2) and used the addr -2 instead of addr.  */
-
-           relocation += 2;
-           address -= 2;
-
-           relocation >>= 1;
-
-           x = bfd_get_16 (input_bfd, contents + address);
-           x = (x & 0xff00) | ((relocation >> 16) & 0xff);
-           bfd_put_16 (input_bfd, x, contents + address);
-
-           x = bfd_get_16 (input_bfd, contents + address + 2);
-           x = relocation & 0xFFFF;
-           bfd_put_16 (input_bfd, x, contents + address + 2);
-           r = bfd_reloc_ok;
-         }
-         break;
-
        default:
        do_default:
-         r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+         r = bfin_final_link_relocate (rel, howto, input_bfd, input_section,
                                        contents, address,
                                        relocation, rel->r_addend);
 
@@ -3118,6 +3137,118 @@ bfin_gc_mark_hook (asection * sec,
   return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
+/* Update the relocation information for the relocations of the section
+   being removed.  */
+
+static bfd_boolean
+bfinfdpic_gc_sweep_hook (bfd *abfd,
+                        struct bfd_link_info *info,
+                        asection *sec,
+                        const Elf_Internal_Rela *relocs)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+  const Elf_Internal_Rela *rel;
+  const Elf_Internal_Rela *rel_end;
+  struct bfinfdpic_relocs_info *picrel;
+
+  BFD_ASSERT (IS_FDPIC (abfd));
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (abfd);
+  sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym);
+  if (!elf_bad_symtab (abfd))
+    sym_hashes_end -= symtab_hdr->sh_info;
+
+  rel_end = relocs + sec->reloc_count;
+  for (rel = relocs; rel < rel_end; rel++)
+    {
+      struct elf_link_hash_entry *h;
+      unsigned long r_symndx;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx < symtab_hdr->sh_info)
+        h = NULL;
+      else
+        h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+      if (h != NULL)
+       picrel = bfinfdpic_relocs_info_for_global (bfinfdpic_relocs_info (info),
+                                                  abfd, h,
+                                                  rel->r_addend, NO_INSERT);
+      else
+       picrel = bfinfdpic_relocs_info_for_local (bfinfdpic_relocs_info
+                                                 (info), abfd, r_symndx,
+                                                 rel->r_addend, NO_INSERT);
+
+      if (!picrel)
+       return TRUE;
+
+      switch (ELF32_R_TYPE (rel->r_info))
+        {
+       case R_pcrel24:
+       case R_pcrel24_jump_l:
+         picrel->call--;
+         break;
+
+       case R_BFIN_FUNCDESC_VALUE:
+         picrel->relocsfdv--;
+         if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
+           picrel->relocs32++;
+         /* Fall through.  */
+
+       case R_byte4_data:
+         picrel->sym--;
+         if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
+           picrel->relocs32--;
+         break;
+
+       case R_BFIN_GOT17M4:
+         picrel->got17m4--;
+         break;
+
+       case R_BFIN_GOTHI:
+       case R_BFIN_GOTLO:
+         picrel->gothilo--;
+         break;
+
+       case R_BFIN_FUNCDESC_GOT17M4:
+         picrel->fdgot17m4--;
+         break;
+
+       case R_BFIN_FUNCDESC_GOTHI:
+       case R_BFIN_FUNCDESC_GOTLO:
+         picrel->fdgothilo--;
+         break;
+
+       case R_BFIN_GOTOFF17M4:
+       case R_BFIN_GOTOFFHI:
+       case R_BFIN_GOTOFFLO:
+         picrel->gotoff--;
+         break;
+
+       case R_BFIN_FUNCDESC_GOTOFF17M4:
+         picrel->fdgoff17m4--;
+         break;
+
+       case R_BFIN_FUNCDESC_GOTOFFHI:
+       case R_BFIN_FUNCDESC_GOTOFFLO:
+         picrel->fdgoffhilo--;
+         break;
+
+       case R_BFIN_FUNCDESC:
+         picrel->fd--;
+         picrel->relocsfd--;
+         break;
+
+       default:
+         break;
+        }
+    }
+
+  return TRUE;
+}
+
 /* Update the got entry reference counts for the section being removed.  */
 
 static bfd_boolean
@@ -4485,7 +4616,7 @@ bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info,
                        asection *sec, const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
-  struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+  struct elf_link_hash_entry **sym_hashes;
   const Elf_Internal_Rela *rel;
   const Elf_Internal_Rela *rel_end;
   bfd *dynobj;
@@ -4496,9 +4627,6 @@ bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
-  sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym);
-  if (!elf_bad_symtab (abfd))
-    sym_hashes_end -= symtab_hdr->sh_info;
 
   dynobj = elf_hash_table (info)->dynobj;
   rel_end = relocs + sec->reloc_count;
@@ -4581,7 +4709,7 @@ bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_pcrel24:
        case R_pcrel24_jump_l:
          if (IS_FDPIC (abfd))
-           picrel->call = 1;
+           picrel->call++;
          break;
 
        case R_BFIN_FUNCDESC_VALUE:
@@ -4594,46 +4722,46 @@ bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info,
          if (! IS_FDPIC (abfd))
            break;
 
-         picrel->sym = 1;
+         picrel->sym++;
          if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
            picrel->relocs32++;
          break;
 
        case R_BFIN_GOT17M4:
-         picrel->got17m4 = 1;
+         picrel->got17m4++;
          break;
 
        case R_BFIN_GOTHI:
        case R_BFIN_GOTLO:
-         picrel->gothilo = 1;
+         picrel->gothilo++;
          break;
 
        case R_BFIN_FUNCDESC_GOT17M4:
-         picrel->fdgot17m4 = 1;
+         picrel->fdgot17m4++;
          break;
 
        case R_BFIN_FUNCDESC_GOTHI:
        case R_BFIN_FUNCDESC_GOTLO:
-         picrel->fdgothilo = 1;
+         picrel->fdgothilo++;
          break;
 
        case R_BFIN_GOTOFF17M4:
        case R_BFIN_GOTOFFHI:
        case R_BFIN_GOTOFFLO:
-         picrel->gotoff = 1;
+         picrel->gotoff++;
          break;
 
        case R_BFIN_FUNCDESC_GOTOFF17M4:
-         picrel->fdgoff17m4 = 1;
+         picrel->fdgoff17m4++;
          break;
 
        case R_BFIN_FUNCDESC_GOTOFFHI:
        case R_BFIN_FUNCDESC_GOTOFFLO:
-         picrel->fdgoffhilo = 1;
+         picrel->fdgoffhilo++;
          break;
 
        case R_BFIN_FUNCDESC:
-         picrel->fd = 1;
+         picrel->fd++;
          picrel->relocsfd++;
          break;
 
@@ -4647,7 +4775,9 @@ bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info,
         /* This relocation describes which C++ vtable entries are actually
            used.  Record for later use during GC.  */
         case R_BFIN_GNU_VTENTRY:
-          if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+          BFD_ASSERT (h != NULL);
+          if (h != NULL
+              && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
             return FALSE;
           break;
 
@@ -4701,6 +4831,10 @@ bfin_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 
   elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
   elf_flags_init (obfd) = TRUE;
+
+  /* Copy object attributes.  */
+  _bfd_elf_copy_obj_attributes (ibfd, obfd);
+
   return TRUE;
 }
 
@@ -4783,8 +4917,7 @@ elf32_bfin_print_private_bfd_data (bfd * abfd, PTR ptr)
 static bfd_boolean
 elf32_bfin_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
-  flagword old_flags, old_partial;
-  flagword new_flags, new_partial;
+  flagword old_flags, new_flags;
   bfd_boolean error = FALSE;
 
   new_flags = elf_elfheader (ibfd)->e_flags;
@@ -4802,37 +4935,10 @@ elf32_bfin_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
   if (!elf_flags_init (obfd))                  /* First call, no flags set.  */
     {
       elf_flags_init (obfd) = TRUE;
-      old_flags = new_flags;
+      elf_elfheader (obfd)->e_flags = new_flags;
     }
 
-  else if (new_flags == old_flags)             /* Compatible flags are ok.  */
-    ;
-
-  else                                         /* Possibly incompatible flags.  */
-    {
-      /* We don't have to do anything if the pic flags are the same, or the new
-         module(s) were compiled with -mlibrary-pic.  */
-      new_partial = (new_flags & EF_BFIN_PIC_FLAGS);
-      old_partial = (old_flags & EF_BFIN_PIC_FLAGS);
-      if (new_partial == old_partial)
-       ;
-
-      /* If we have mixtures of -fpic and -fPIC, or in both bits.  */
-      else if (new_partial != 0 && old_partial != 0)
-       old_flags |= new_partial;
-
-      /* One module was compiled for pic and the other was not, see if we have
-         had any relocations that are not pic-safe.  */
-      else
-       old_flags |= new_partial;
-
-    }
-
-  /* Update the old flags now with changes made above.  */
-  elf_elfheader (obfd)->e_flags = old_flags;
-
-  if (((new_flags & EF_BFIN_FDPIC) == 0)
-      != (! IS_FDPIC (ibfd)))
+  if (((new_flags & EF_BFIN_FDPIC) == 0) != (! IS_FDPIC (obfd)))
     {
       error = TRUE;
       if (IS_FDPIC (obfd))
@@ -5475,6 +5581,8 @@ error_return:
 #define elf_symbol_leading_char                '_'
 
 #define bfd_elf32_bfd_reloc_type_lookup        bfin_bfd_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup \
+                                       bfin_bfd_reloc_name_lookup
 #define elf_info_to_howto              bfin_info_to_howto
 #define elf_info_to_howto_rel          0
 #define elf_backend_object_p           elf32_bfin_object_p
@@ -5529,6 +5637,7 @@ error_return:
 #define        elf32_bed               elf32_bfinfdpic_bed
 
 #undef elf_backend_gc_sweep_hook
+#define elf_backend_gc_sweep_hook       bfinfdpic_gc_sweep_hook
 
 #undef elf_backend_got_header_size
 #define elf_backend_got_header_size     0
This page took 0.032927 seconds and 4 git commands to generate.