x86: Use zero_undefweak in elf_x86_link_hash_entry
[deliverable/binutils-gdb.git] / bfd / elf32-hppa.c
index 1deebf4f038ee595757be714e2429331620300a2..3adac6d91fbd2f29d734158269e2e4699b621750 100644 (file)
@@ -836,10 +836,10 @@ hppa_build_one_stub (struct bfd_hash_entry *bh, void *in_arg)
        {
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
+           (_("%B(%A+%#Lx): cannot reach %s, recompile with -ffunction-sections"),
             hsh->target_section->owner,
             stub_sec,
-            (long) hsh->stub_offset,
+            hsh->stub_offset,
             hsh->bh_root.string);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
@@ -1171,7 +1171,7 @@ elf32_hppa_check_relocs (bfd *abfd,
 
          /* PR15323, ref flags aren't set for references in the same
             object.  */
-         hh->eh.root.non_ir_ref = 1;
+         hh->eh.root.non_ir_ref_regular = 1;
        }
 
       r_type = ELF32_R_TYPE (rela->r_info);
@@ -1919,16 +1919,20 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info,
   return _bfd_elf_adjust_dynamic_copy (info, eh, sec);
 }
 
-/* Make an undefined weak symbol dynamic.  */
+/* If EH is undefined, make it dynamic if that makes sense.  */
 
 static bfd_boolean
-ensure_undef_weak_dynamic (struct bfd_link_info *info,
-                          struct elf_link_hash_entry *eh)
+ensure_undef_dynamic (struct bfd_link_info *info,
+                     struct elf_link_hash_entry *eh)
 {
-  if (eh->dynindx == -1
+  struct elf_link_hash_table *htab = elf_hash_table (info);
+
+  if (htab->dynamic_sections_created
+      && (eh->root.type == bfd_link_hash_undefweak
+         || eh->root.type == bfd_link_hash_undefined)
+      && eh->dynindx == -1
       && !eh->forced_local
       && eh->type != STT_PARISC_MILLI
-      && eh->root.type == bfd_link_hash_undefweak
       && ELF_ST_VISIBILITY (eh->other) == STV_DEFAULT)
     return bfd_elf_link_record_dynamic_symbol (info, eh);
   return TRUE;
@@ -1957,7 +1961,7 @@ allocate_plt_static (struct elf_link_hash_entry *eh, void *inf)
   if (htab->etab.dynamic_sections_created
       && eh->plt.refcount > 0)
     {
-      if (!ensure_undef_weak_dynamic (info, eh))
+      if (!ensure_undef_dynamic (info, eh))
        return FALSE;
 
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), eh))
@@ -2034,7 +2038,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
 
   if (eh->got.refcount > 0)
     {
-      if (!ensure_undef_weak_dynamic (info, eh))
+      if (!ensure_undef_dynamic (info, eh))
        return FALSE;
 
       sec = htab->etab.sgot;
@@ -2070,8 +2074,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
      changes.  */
   if (bfd_link_pic (info))
     {
+      /* Discard relocs on undefined syms with non-default visibility.  */
+      if ((eh->root.type == bfd_link_hash_undefined
+          || eh->root.type == bfd_link_hash_undefweak)
+         && ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT)
+       hh->dyn_relocs = NULL;
+
 #if RELATIVE_DYNRELOCS
-      if (SYMBOL_CALLS_LOCAL (info, eh))
+      else if (SYMBOL_CALLS_LOCAL (info, eh))
        {
          struct elf32_hppa_dyn_reloc_entry **hdh_pp;
 
@@ -2087,15 +2097,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
        }
 #endif
 
-      /* Also discard relocs on undefined weak syms with non-default
-        visibility.  */
-      if (hh->dyn_relocs != NULL
-         && eh->root.type == bfd_link_hash_undefweak)
+      if (hh->dyn_relocs != NULL)
        {
-         if (ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT)
-           hh->dyn_relocs = NULL;
-
-         else if (!ensure_undef_weak_dynamic (info, eh))
+         if (!ensure_undef_dynamic (info, eh))
            return FALSE;
        }
     }
@@ -2113,19 +2117,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
                   && (eh->root.type == bfd_link_hash_undefweak
                       || eh->root.type == bfd_link_hash_undefined))))
        {
-         if (!ensure_undef_weak_dynamic (info, eh))
+         if (!ensure_undef_dynamic (info, eh))
            return FALSE;
 
-         /* If that succeeded, we know we'll be keeping all the
-            relocs.  */
-         if (eh->dynindx != -1)
-           goto keep;
+         if (eh->dynindx == -1)
+           hh->dyn_relocs = NULL;
        }
-
-      hh->dyn_relocs = NULL;
-      return TRUE;
-
-    keep: ;
+      else
+       hh->dyn_relocs = NULL;
     }
 
   /* Finally, allocate space.  */
@@ -3090,13 +3089,8 @@ elf32_hppa_set_gp (bfd *abfd, struct bfd_link_info *info)
   struct bfd_link_hash_entry *h;
   asection *sec = NULL;
   bfd_vma gp_val = 0;
-  struct elf32_hppa_link_hash_table *htab;
 
-  htab = hppa_link_hash_table (info);
-  if (htab == NULL)
-    return FALSE;
-
-  h = bfd_link_hash_lookup (&htab->etab.root, "$global$", FALSE, FALSE, FALSE);
+  h = bfd_link_hash_lookup (info->hash, "$global$", FALSE, FALSE, FALSE);
 
   if (h != NULL
       && (h->type == bfd_link_hash_defined
@@ -3159,10 +3153,13 @@ elf32_hppa_set_gp (bfd *abfd, struct bfd_link_info *info)
        }
     }
 
-  if (sec != NULL && sec->output_section != NULL)
-    gp_val += sec->output_section->vma + sec->output_offset;
+  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+    {
+      if (sec != NULL && sec->output_section != NULL)
+       gp_val += sec->output_section->vma + sec->output_offset;
 
-  elf_gp (abfd) = gp_val;
+      elf_gp (abfd) = gp_val;
+    }
   return TRUE;
 }
 
@@ -3430,10 +3427,10 @@ final_link_relocate (asection *input_section,
                   error.  */
                _bfd_error_handler
                  /* xgettext:c-format */
-                 (_("%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"),
+                 (_("%B(%A+%#Lx): %s fixup for insn %#x is not supported in a non-shared link"),
                   input_bfd,
                   input_section,
-                  (long) offset,
+                  offset,
                   howto->name,
                   insn);
            }
@@ -3596,10 +3593,10 @@ final_link_relocate (asection *input_section,
     {
       _bfd_error_handler
        /* xgettext:c-format */
-       (_("%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
+       (_("%B(%A+%#Lx): cannot reach %s, recompile with -ffunction-sections"),
         input_bfd,
         input_section,
-        (long) offset,
+        offset,
         hsh->bh_root.string);
       bfd_set_error (bfd_error_bad_value);
       return bfd_reloc_notsupported;
@@ -4287,10 +4284,10 @@ elf32_hppa_relocate_section (bfd *output_bfd,
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B(%A+0x%lx): cannot handle %s for %s"),
+               (_("%B(%A+%#Lx): cannot handle %s for %s"),
                 input_bfd,
                 input_section,
-                (long) rela->r_offset,
+                rela->r_offset,
                 howto->name,
                 sym_name);
              bfd_set_error (bfd_error_bad_value);
This page took 0.03443 seconds and 4 git commands to generate.