elf32-arm.c corrections

Peter S. Mazinger ps.m@gmx.net
Sun Mar 20 06:08:00 GMT 2005


Hello!

add_dynamic_entry: changes !info->shared to info->executable (PIE)
corrects typo, and syncs up with other archs (some others could do the 
same). For !relocs the hole part would be omitted, probably some speed gain.

Should the other patch (*3) for allocate_dynrelocs be applied (as done for 
ppc32)?

Why is ELIMINATE_COPY_RELOCS not used for arm?

Thanks, Peter

Please cc to me, 

-- 
Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2
-------------- next part --------------
--- bfd/elf32-arm.c.mps	2005-03-19 22:57:32 +0100
+++ bfd/elf32-arm.c	2005-03-19 23:05:34 +0100
@@ -4658,6 +4658,19 @@
       if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
 	  && h->root.type == bfd_link_hash_undefweak)
 	eh->relocs_copied = NULL;
+
+      /* Make sure undefined weak symbols are output as a dynamic symbol
+	 in PIEs.  */
+      if (info->pie
+	  && eh->relocs_copied != NULL
+	  && h->dynindx == -1
+	  && h->root.type == bfd_link_hash_undefweak
+	  && !h->forced_local)
+	{
+	  if (! bfd_elf_link_record_dynamic_symbol (info, h))
+	    return FALSE;
+	}
+
       else if (htab->root.is_relocatable_executable && h->dynindx == -1
 	       && h->root.type == bfd_link_hash_new)
 	{
-------------- next part --------------
--- bfd/elf32-arm.c.mps	2005-03-19 22:57:32 +0100
+++ bfd/elf32-arm.c	2005-03-19 23:05:34 +0100
@@ -4926,7 +4926,7 @@
 #define add_dynamic_entry(TAG, VAL) \
   _bfd_elf_add_dynamic_entry (info, TAG, VAL)
 
-      if (!info->shared)
+      if (info->executable)
 	{
 	  if (!add_dynamic_entry (DT_DEBUG, 0))
 	    return FALSE;
@@ -4947,22 +4947,21 @@
 	      || !add_dynamic_entry (DT_RELSZ, 0)
 	      || !add_dynamic_entry (DT_RELENT, sizeof (Elf32_External_Rel)))
 	    return FALSE;
-	}
 
-      /* If any dynamic relocs apply to a read-only section,
-	 then we need a DT_TEXTREL entry.  */
-      if ((info->flags & DF_TEXTREL) == 0)
-	elf_link_hash_traverse (&htab->root, elf32_arm_readonly_dynrelocs,
+	  /* If any dynamic relocs apply to a read-only section,
+	     then we need a DT_TEXTREL entry.  */
+	  if ((info->flags & DF_TEXTREL) == 0)
+	    elf_link_hash_traverse (&htab->root, elf32_arm_readonly_dynrelocs,
 				(PTR) info);
 
-      if ((info->flags & DF_TEXTREL) != 0)
-	{
-	  if (!add_dynamic_entry (DT_TEXTREL, 0))
-	    return FALSE;
-	  info->flags |= DF_TEXTREL;
+	  if ((info->flags & DF_TEXTREL) != 0)
+	    {
+	      if (!add_dynamic_entry (DT_TEXTREL, 0))
+		return FALSE;
+	    }
 	}
     }
-#undef add_synamic_entry
+#undef add_dynamic_entry
 
   return TRUE;
 }


More information about the Binutils mailing list