apply mising piece of previous patch
[deliverable/binutils-gdb.git] / bfd / elf32-sh.c
index fb45aebc55e7074b090af4aac9288bd08253e3d5..4304a4ec40a22aae0d20daeb16db94462db6b08a 100644 (file)
@@ -26,6 +26,7 @@
 #include "elf-bfd.h"
 #include "elf/sh.h"
 #include "libiberty.h"
+#include "../opcodes/sh-opc.h"
 
 static bfd_reloc_status_type sh_elf_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
@@ -49,8 +50,10 @@ static bfd_boolean sh_elf_relax_delete_bytes
   (bfd *, asection *, bfd_vma, int);
 static bfd_boolean sh_elf_align_loads
   (bfd *, asection *, Elf_Internal_Rela *, bfd_byte *, bfd_boolean *);
+#ifndef SH64_ELF
 static bfd_boolean sh_elf_swap_insns
   (bfd *, asection *, void *, bfd_byte *, bfd_vma);
+#endif
 static bfd_boolean sh_elf_relocate_section
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
@@ -106,10 +109,12 @@ static enum elf_reloc_type_class sh_elf_reloc_type_class
 #ifdef INCLUDE_SHMEDIA
 inline static void movi_shori_putval (bfd *, unsigned long, char *);
 #endif
+#if !defined SH_TARGET_ALREADY_DEFINED
 static bfd_boolean elf32_shlin_grok_prstatus
   (bfd *abfd, Elf_Internal_Note *note);
 static bfd_boolean elf32_shlin_grok_psinfo
   (bfd *abfd, Elf_Internal_Note *note);
+#endif
 
 /* The name of the dynamic interpreter.  This is put in the .interp
    section.  */
@@ -2237,8 +2242,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
       laddr = irel->r_offset + 4 + irel->r_addend;
       if (laddr >= sec->size)
        {
-         (*_bfd_error_handler) (_("%s: 0x%lx: warning: bad R_SH_USES offset"),
-                                bfd_archive_filename (abfd),
+         (*_bfd_error_handler) (_("%B: 0x%lx: warning: bad R_SH_USES offset"),
+                                abfd,
                                 (unsigned long) irel->r_offset);
          continue;
        }
@@ -2249,8 +2254,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
       if ((insn & 0xf000) != 0xd000)
        {
          ((*_bfd_error_handler)
-          (_("%s: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x"),
-           bfd_archive_filename (abfd), (unsigned long) irel->r_offset, insn));
+          (_("%B: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x"),
+           abfd, (unsigned long) irel->r_offset, insn));
          continue;
        }
 
@@ -2266,8 +2271,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
       if (paddr >= sec->size)
        {
          ((*_bfd_error_handler)
-          (_("%s: 0x%lx: warning: bad R_SH_USES load offset"),
-           bfd_archive_filename (abfd), (unsigned long) irel->r_offset));
+          (_("%B: 0x%lx: warning: bad R_SH_USES load offset"),
+           abfd, (unsigned long) irel->r_offset));
          continue;
        }
 
@@ -2281,8 +2286,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
       if (irelfn >= irelend)
        {
          ((*_bfd_error_handler)
-          (_("%s: 0x%lx: warning: could not find expected reloc"),
-           bfd_archive_filename (abfd), (unsigned long) paddr));
+          (_("%B: 0x%lx: warning: could not find expected reloc"),
+           abfd, (unsigned long) paddr));
          continue;
        }
 
@@ -2309,8 +2314,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
              != (unsigned int) _bfd_elf_section_from_bfd_section (abfd, sec))
            {
              ((*_bfd_error_handler)
-              (_("%s: 0x%lx: warning: symbol in unexpected section"),
-               bfd_archive_filename (abfd), (unsigned long) paddr));
+              (_("%B: 0x%lx: warning: symbol in unexpected section"),
+               abfd, (unsigned long) paddr));
              continue;
            }
 
@@ -2434,8 +2439,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
       if (irelcount >= irelend)
        {
          ((*_bfd_error_handler)
-          (_("%s: 0x%lx: warning: could not find expected COUNT reloc"),
-           bfd_archive_filename (abfd), (unsigned long) paddr));
+          (_("%B: 0x%lx: warning: could not find expected COUNT reloc"),
+           abfd, (unsigned long) paddr));
          continue;
        }
 
@@ -2443,8 +2448,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
         just deleted one.  */
       if (irelcount->r_addend == 0)
        {
-         ((*_bfd_error_handler) (_("%s: 0x%lx: warning: bad count"),
-                                 bfd_archive_filename (abfd),
+         ((*_bfd_error_handler) (_("%B: 0x%lx: warning: bad count"),
+                                 abfd,
                                  (unsigned long) paddr));
          continue;
        }
@@ -2838,8 +2843,8 @@ sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr,
          if (overflow)
            {
              ((*_bfd_error_handler)
-              (_("%s: 0x%lx: fatal: reloc overflow while relaxing"),
-               bfd_archive_filename (abfd), (unsigned long) irel->r_offset));
+              (_("%B: 0x%lx: fatal: reloc overflow while relaxing"),
+               abfd, (unsigned long) irel->r_offset));
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
@@ -3089,6 +3094,7 @@ sh_elf_align_loads (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
   return FALSE;
 }
 
+#ifndef SH64_ELF
 /* Swap two SH instructions.  This is like sh_swap_insns in coff-sh.c.  */
 
 static bfd_boolean
@@ -3207,8 +3213,8 @@ sh_elf_swap_insns (bfd *abfd, asection *sec, void *relocs,
          if (overflow)
            {
              ((*_bfd_error_handler)
-              (_("%s: 0x%lx: fatal: reloc overflow while relaxing"),
-               bfd_archive_filename (abfd), (unsigned long) irel->r_offset));
+              (_("%B: 0x%lx: fatal: reloc overflow while relaxing"),
+               abfd, (unsigned long) irel->r_offset));
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
@@ -3217,6 +3223,7 @@ sh_elf_swap_insns (bfd *abfd, asection *sec, void *relocs,
 
   return TRUE;
 }
+#endif /* defined SH64_ELF */
 \f
 #ifdef INCLUDE_SHMEDIA
 
@@ -3903,7 +3910,7 @@ sh_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
        return FALSE;
 
       h = (struct elf_link_hash_entry *) bh;
-      h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+      h->def_regular = 1;
       h->type = STT_OBJECT;
 
       if (info->shared
@@ -4010,20 +4017,17 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
 
   /* Make sure we know what is going on here.  */
   BFD_ASSERT (htab->root.dynobj != NULL
-             && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
-                 || h->weakdef != NULL
-                 || ((h->elf_link_hash_flags
-                      & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-                     && (h->elf_link_hash_flags
-                         & ELF_LINK_HASH_REF_REGULAR) != 0
-                     && (h->elf_link_hash_flags
-                         & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+             && (h->needs_plt
+                 || h->u.weakdef != NULL
+                 || (h->def_dynamic
+                     && h->ref_regular
+                     && !h->def_regular)));
 
   /* If this is a function, put it in the procedure linkage table.  We
      will fill in the contents of the procedure linkage table later,
      when we know the address of the .got section.  */
   if (h->type == STT_FUNC
-      || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+      || h->needs_plt)
     {
       if (h->plt.refcount <= 0
          || SYMBOL_CALLS_LOCAL (info, h)
@@ -4036,7 +4040,7 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
             a procedure linkage table, and we can just do a REL32
             reloc instead.  */
          h->plt.offset = (bfd_vma) -1;
-         h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+         h->needs_plt = 0;
        }
 
       return TRUE;
@@ -4047,16 +4051,14 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
   /* If this is a weak symbol, and there is a real definition, the
      processor independent code will have arranged for us to see the
      real definition first, and we can just use the same value.  */
-  if (h->weakdef != NULL)
+  if (h->u.weakdef != NULL)
     {
-      BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
-                 || h->weakdef->root.type == bfd_link_hash_defweak);
-      h->root.u.def.section = h->weakdef->root.u.def.section;
-      h->root.u.def.value = h->weakdef->root.u.def.value;
+      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
+                 || h->u.weakdef->root.type == bfd_link_hash_defweak);
+      h->root.u.def.section = h->u.weakdef->root.u.def.section;
+      h->root.u.def.value = h->u.weakdef->root.u.def.value;
       if (info->nocopyreloc)
-       h->elf_link_hash_flags
-         = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
-            | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
+       h->non_got_ref = h->u.weakdef->non_got_ref;
       return TRUE;
     }
 
@@ -4072,13 +4074,13 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
 
   /* If there are no references to this symbol that do not use the
      GOT, we don't need to generate a copy reloc.  */
-  if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
+  if (!h->non_got_ref)
     return TRUE;
 
   /* If -z nocopyreloc was given, we won't generate them either.  */
   if (info->nocopyreloc)
     {
-      h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+      h->non_got_ref = 0;
       return TRUE;
     }
 
@@ -4095,7 +4097,7 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
      the copy reloc.  */
   if (p == NULL)
     {
-      h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+      h->non_got_ref = 0;
       return TRUE;
     }
 
@@ -4123,7 +4125,7 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
       srel = htab->srelbss;
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
-      h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+      h->needs_copy = 1;
     }
 
   /* We need to figure out the alignment required for this symbol.  I
@@ -4175,7 +4177,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
   eh = (struct elf_sh_link_hash_entry *) h;
   if ((h->got.refcount > 0
-      || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
+       || h->forced_local)
       && eh->gotplt_refcount > 0)
     {
       /* The symbol has been forced local, or we have some direct got refs,
@@ -4193,7 +4195,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       /* Make sure this symbol is output as a dynamic symbol.
         Undefined weak syms won't yet be marked as dynamic.  */
       if (h->dynindx == -1
-         && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+         && !h->forced_local)
        {
          if (! bfd_elf_link_record_dynamic_symbol (info, h))
            return FALSE;
@@ -4217,7 +4219,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
             pointers compare as equal between the normal executable and
             the shared library.  */
          if (! info->shared
-             && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+             && !h->def_regular)
            {
              h->root.u.def.section = s;
              h->root.u.def.value = h->plt.offset;
@@ -4236,13 +4238,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       else
        {
          h->plt.offset = (bfd_vma) -1;
-         h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+         h->needs_plt = 0;
        }
     }
   else
     {
       h->plt.offset = (bfd_vma) -1;
-      h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+      h->needs_plt = 0;
     }
 
   if (h->got.refcount > 0)
@@ -4254,7 +4256,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       /* Make sure this symbol is output as a dynamic symbol.
         Undefined weak syms won't yet be marked as dynamic.  */
       if (h->dynindx == -1
-         && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+         && !h->forced_local)
        {
          if (! bfd_elf_link_record_dynamic_symbol (info, h))
            return FALSE;
@@ -4292,7 +4294,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       /* Make sure this symbol is output as a dynamic symbol.
         Undefined weak syms won't yet be marked as dynamic.  */
       if (h->dynindx == -1
-         && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+         && !h->forced_local)
        {
          if (! bfd_elf_link_record_dynamic_symbol (info, h))
            return FALSE;
@@ -4347,9 +4349,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
         symbols which turn out to need copy relocs or are not
         dynamic.  */
 
-      if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
-         && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-              && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+      if (!h->non_got_ref
+         && ((h->def_dynamic
+              && !h->def_regular)
              || (htab->root.dynamic_sections_created
                  && (h->root.type == bfd_link_hash_undefweak
                      || h->root.type == bfd_link_hash_undefined))))
@@ -4357,7 +4359,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
          /* Make sure this symbol is output as a dynamic symbol.
             Undefined weak syms won't yet be marked as dynamic.  */
          if (h->dynindx == -1
-             && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+             && !h->forced_local)
            {
              if (! bfd_elf_link_record_dynamic_symbol (info, h))
                return FALSE;
@@ -4788,9 +4790,8 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              if (howto->rightshift || howto->src_mask != 0xffffffff)
                {
                  (*_bfd_error_handler)
-                   (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
-                    bfd_archive_filename (input_bfd),
-                    bfd_get_section_name (input_bfd, input_section),
+                   (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"),
+                    input_bfd, input_section,
                     (long) rel->r_offset, howto->name);
                  return FALSE;
                }
@@ -4856,8 +4857,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                      && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
                      && (! info->shared
                          || (! info->symbolic && h->dynindx != -1)
-                         || (h->elf_link_hash_flags
-                             & ELF_LINK_HASH_DEF_REGULAR) == 0))
+                         || !h->def_regular))
                  /* The cases above are those in which relocation is
                     overwritten in the switch block below.  The cases
                     below are those in which we must defer relocation
@@ -4865,11 +4865,9 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                     addresses when creating a shared library.  */
                  || (info->shared
                      && ((! info->symbolic && h->dynindx != -1)
-                         || (h->elf_link_hash_flags
-                             & ELF_LINK_HASH_DEF_REGULAR) == 0)
+                         || !h->def_regular)
                      && ((r_type == R_SH_DIR32
-                          && (h->elf_link_hash_flags
-                              & ELF_LINK_FORCED_LOCAL) == 0)
+                          && !h->forced_local)
                          || r_type == R_SH_REL32)
                      && ((input_section->flags & SEC_ALLOC) != 0
                          /* DWARF will emit R_SH_DIR32 relocations in its
@@ -4877,15 +4875,13 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                             in shared libraries.  We can't do anything
                             with them here.  */
                          || ((input_section->flags & SEC_DEBUGGING) != 0
-                             && (h->elf_link_hash_flags
-                                 & ELF_LINK_HASH_DEF_DYNAMIC) != 0)))
+                             && h->def_dynamic)))
                  /* Dynamic relocs are not propagated for SEC_DEBUGGING
                     sections because such sections are not SEC_ALLOC and
                     thus ld.so will not process them.  */
                  || (sec->output_section == NULL
                      && ((input_section->flags & SEC_DEBUGGING) != 0
-                         && (h->elf_link_hash_flags
-                             & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
+                         && h->def_dynamic))
                  || (sec->output_section == NULL
                      && (sh_elf_hash_entry (h)->tls_type == GOT_TLS_IE
                          || sh_elf_hash_entry (h)->tls_type == GOT_TLS_GD)))
@@ -4893,9 +4889,8 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              else if (sec->output_section == NULL)
                {
                  (*_bfd_error_handler)
-                   (_("%s: unresolvable relocation against symbol `%s' from %s section"),
-                    bfd_archive_filename (input_bfd), h->root.root.string,
-                    bfd_get_section_name (input_bfd, input_section));
+                   (_("%B(%A): unresolvable relocation against symbol `%s'"),
+                    input_bfd, input_section, h->root.root.string);
                  return FALSE;
                }
              else
@@ -4964,8 +4959,8 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              if (disp & mask)
                {
                  ((*_bfd_error_handler)
-                  (_("%s: 0x%lx: fatal: unaligned branch target for relax-support relocation"),
-                   bfd_archive_filename (input_section->owner),
+                  (_("%B: 0x%lx: fatal: unaligned branch target for relax-support relocation"),
+                   input_section->owner,
                    (unsigned long) rel->r_offset));
                  bfd_set_error (bfd_error_bad_value);
                  return FALSE;
@@ -4997,10 +4992,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
          if (relocation & 3)
            {
              ((*_bfd_error_handler)
-              (_("%s: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
-               bfd_archive_filename (input_section->owner),
+              (_("%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+               input_section->owner,
                (unsigned long) rel->r_offset, howto->name, 
-               (unsigned long)relocation));
+               (unsigned long) relocation));
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
@@ -5012,10 +5007,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
          if (relocation & 1)
            {
              ((*_bfd_error_handler)
-              (_("%s: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
-               bfd_archive_filename (input_section->owner),
+              (_("%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+               input_section->owner,
                (unsigned long) rel->r_offset, howto->name, 
-               (unsigned long)relocation));
+               (unsigned long) relocation));
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
@@ -5026,10 +5021,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              || (signed int)relocation > 32)
            {
              ((*_bfd_error_handler)
-              (_("%s: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"),
-               bfd_archive_filename (input_section->owner),
+              (_("%B: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"),
+               input_section->owner,
                (unsigned long) rel->r_offset,
-               (unsigned long)relocation));
+               (unsigned long) relocation));
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
@@ -5040,10 +5035,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              || (signed int)relocation > 16)
            {
              ((*_bfd_error_handler)
-              (_("%s: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"),
-               bfd_archive_filename (input_section->owner),
+              (_("%B: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"),
+               input_section->owner,
                (unsigned long) rel->r_offset,
-               (unsigned long)relocation));
+               (unsigned long) relocation));
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
@@ -5133,8 +5128,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                     become local.  */
                  if (h == NULL
                      || ((info->symbolic || h->dynindx == -1)
-                         && (h->elf_link_hash_flags
-                             & ELF_LINK_HASH_DEF_REGULAR) != 0))
+                         && h->def_regular))
                    {
                      relocate = TRUE;
                      outrel.r_info = ELF32_R_INFO (0, R_SH_RELATIVE);
@@ -5178,7 +5172,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
             procedure linkage table.  */
 
          if (h == NULL
-             || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)
+             || h->forced_local
              || ! info->shared
              || info->symbolic
              || h->dynindx == -1
@@ -5406,7 +5400,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
          if (h == NULL)
            goto final_link_relocate;
 
-         if (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)
+         if (h->forced_local)
            goto final_link_relocate;
 
          if (h->plt.offset == (bfd_vma) -1)
@@ -5459,7 +5453,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              tls_type = sh_elf_hash_entry (h)->tls_type;
              if (! info->shared
                  && (h->dynindx == -1
-                     || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+                     || h->def_regular))
                r_type = R_SH_TLS_LE_32;
            }
 
@@ -6302,15 +6296,16 @@ sh_elf_copy_indirect_symbol (const struct elf_backend_data *bed,
     }
 
   if (ind->root.type != bfd_link_hash_indirect
-      && (dir->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
-    /* If called to transfer flags for a weakdef during processing
-       of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF.
-       We clear it ourselves for ELIMINATE_COPY_RELOCS.  */
-    dir->elf_link_hash_flags |=
-      (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC
-                                  | ELF_LINK_HASH_REF_REGULAR
-                                  | ELF_LINK_HASH_REF_REGULAR_NONWEAK
-                                  | ELF_LINK_HASH_NEEDS_PLT));
+      && dir->dynamic_adjusted)
+    {
+      /* If called to transfer flags for a weakdef during processing
+        of elf_adjust_dynamic_symbol, don't copy non_got_ref.
+        We clear it ourselves for ELIMINATE_COPY_RELOCS.  */
+      dir->ref_dynamic |= ind->ref_dynamic;
+      dir->ref_regular |= ind->ref_regular;
+      dir->ref_regular_nonweak |= ind->ref_regular_nonweak;
+      dir->needs_plt |= ind->needs_plt;
+    }
   else
     _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
 }
@@ -6406,7 +6401,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
          && h->root.type != bfd_link_hash_undefined
          && h->root.type != bfd_link_hash_undefweak
          && (h->dynindx == -1
-             || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+             || h->def_regular))
        r_type = R_SH_TLS_LE_32;
 
       /* Some relocs require a global offset table.  */
@@ -6570,8 +6565,8 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
              else
                {
                  (*_bfd_error_handler)
-                   (_("%s: `%s' accessed both as normal and thread local symbol"),
-                    bfd_archive_filename (abfd), h->root.root.string);
+                   (_("%B: `%s' accessed both as normal and thread local symbol"),
+                    abfd, h->root.root.string);
                  return FALSE;
                }
            }
@@ -6603,13 +6598,13 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
             creating a procedure linkage table entry.  */
 
          if (h == NULL
-             || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)
+             || h->forced_local
              || ! info->shared
              || info->symbolic
              || h->dynindx == -1)
            goto force_got;
 
-         h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+         h->needs_plt = 1;
          h->plt.refcount += 1;
          ((struct elf_sh_link_hash_entry *) h)->gotplt_refcount += 1;
 
@@ -6634,10 +6629,10 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
          if (h == NULL)
            continue;
 
-         if (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)
+         if (h->forced_local)
            break;
 
-         h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+         h->needs_plt = 1;
          h->plt.refcount += 1;
          break;
 
@@ -6651,7 +6646,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
 #endif
          if (h != NULL && ! info->shared)
            {
-             h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+             h->non_got_ref = 1;
              h->plt.refcount += 1;
            }
 
@@ -6680,14 +6675,12 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
                   || (h != NULL
                       && (! info->symbolic
                           || h->root.type == bfd_link_hash_defweak
-                          || (h->elf_link_hash_flags
-                              & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+                          || !h->def_regular))))
              || (! info->shared
                  && (sec->flags & SEC_ALLOC) != 0
                  && h != NULL
                  && (h->root.type == bfd_link_hash_defweak
-                     || (h->elf_link_hash_flags
-                         & ELF_LINK_HASH_DEF_REGULAR) == 0)))
+                     || !h->def_regular)))
            {
              struct elf_sh_dyn_relocs *p;
              struct elf_sh_dyn_relocs **head;
@@ -6782,8 +6775,9 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
        case R_SH_TLS_LE_32:
          if (info->shared)
            {
-             (*_bfd_error_handler) (_("%s: TLS local exec code cannot be linked into shared objects"),
-                                    bfd_archive_filename (abfd));
+             (*_bfd_error_handler)
+               (_("%B: TLS local exec code cannot be linked into shared objects"),
+                abfd);
              return FALSE;
            }
 
@@ -6875,21 +6869,24 @@ sh_elf_copy_private_data (bfd * ibfd, bfd * obfd)
 
 /* This function returns the ELF architecture number that
    corresponds to the given arch_sh* flags.  */
+
 int
 sh_find_elf_flags (unsigned int arch_set)
 {
+  extern unsigned long sh_get_bfd_mach_from_arch_set (unsigned int);
   unsigned long bfd_mach = sh_get_bfd_mach_from_arch_set (arch_set);
 
   return sh_elf_get_flags_from_mach (bfd_mach);
 }
 
-
 /* This routine initialises the elf flags when required and
    calls sh_merge_bfd_arch() to check dsp/fpu compatibility.  */
 
 static bfd_boolean
 sh_elf_merge_private_data (bfd *ibfd, bfd *obfd)
 {
+  extern bfd_boolean sh_merge_bfd_arch (bfd *, bfd *);
+
   if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
     return TRUE;
@@ -6902,8 +6899,14 @@ sh_elf_merge_private_data (bfd *ibfd, bfd *obfd)
       sh_elf_set_mach_from_flags (obfd);
     }
 
-  if ( ! sh_merge_bfd_arch (ibfd, obfd) )
-    return FALSE;
+  if (! sh_merge_bfd_arch (ibfd, obfd))
+    {
+      _bfd_error_handler ("%B: uses instructions which are incompatible "
+                         "with instructions used in previous modules",
+                         ibfd);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
 
   elf_elfheader (obfd)->e_flags =
     sh_elf_get_flags_from_mach (bfd_get_mach (obfd));
@@ -7066,7 +7069,7 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
       loc = srel->contents + plt_index * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
 
-      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+      if (!h->def_regular)
        {
          /* Mark the symbol as undefined, rather than as defined in
             the .plt section.  Leave the value alone.  */
@@ -7170,7 +7173,7 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
   }
 #endif
 
-  if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+  if (h->needs_copy)
     {
       asection *s;
       Elf_Internal_Rela rel;
@@ -7382,7 +7385,9 @@ sh_elf_reloc_type_class (const Elf_Internal_Rela *rela)
     }
 }
 
+#if !defined SH_TARGET_ALREADY_DEFINED
 /* Support for Linux core dump NOTE sections.  */
+
 static bfd_boolean
 elf32_shlin_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
 {
@@ -7442,6 +7447,7 @@ elf32_shlin_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 
   return TRUE;
 }
+#endif /* not SH_TARGET_ALREADY_DEFINED */
 
  
 /* Return address for Ith PLT stub in section PLT, for relocation REL
@@ -7454,10 +7460,13 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
   return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
 }
 
+#if !defined SH_TARGET_ALREADY_DEFINED
 #define TARGET_BIG_SYM         bfd_elf32_sh_vec
 #define TARGET_BIG_NAME                "elf32-sh"
 #define TARGET_LITTLE_SYM      bfd_elf32_shl_vec
 #define TARGET_LITTLE_NAME     "elf32-shl"
+#endif
+
 #define ELF_ARCH               bfd_arch_sh
 #define ELF_MACHINE_CODE       EM_SH
 #ifdef __QNXTARGET__
@@ -7510,7 +7519,7 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    12
 
-#ifndef INCLUDE_SHMEDIA
+#if !defined INCLUDE_SHMEDIA && !defined SH_TARGET_ALREADY_DEFINED
 
 #include "elf32-target.h"
 
@@ -7552,4 +7561,4 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
 
 #include "elf32-target.h"
 
-#endif /* INCLUDE_SHMEDIA */
+#endif /* neither INCLUDE_SHMEDIA nor SH_TARGET_ALREADY_DEFINED */
This page took 0.034596 seconds and 4 git commands to generate.