--- binutils-2004-q3d-pristine/bfd/elf32-arm.c	2004-11-05 02:57:40.000000000 +0200
+++ binutils-2004-q3d-uclibc/bfd/elf32-arm.c	2005-02-24 10:32:58.000000000 +0200
@@ -4617,6 +4617,38 @@
   return TRUE;
 }
 
+/* Find any dynamic relocs that apply to read-only sections.  */
+
+static bfd_boolean
+elf32_arm_readonly_dynrelocs (h, inf)
+     struct elf_link_hash_entry *h;
+     PTR inf;
+{
+  struct elf32_arm_link_hash_entry *eh;
+  struct elf32_arm_relocs_copied *p;
+
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+  eh = (struct elf32_arm_link_hash_entry *) h;
+  for (p = eh->relocs_copied; p != NULL; p = p->next)
+    {
+      asection *s = p->section;
+
+      if (s != NULL && (s->flags & SEC_READONLY) != 0)
+       {
+         struct bfd_link_info *info = (struct bfd_link_info *) inf;
+
+         info->flags |= DF_TEXTREL;
+
+         /* Not an error, just cut short the traversal.  */
+         return FALSE;
+       }
+    }
+  return TRUE;
+}
+
+
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
@@ -4801,7 +4833,7 @@
 	 dynamic linker and used by the debugger.  */
 #define add_dynamic_entry(TAG, VAL) \
   _bfd_elf_add_dynamic_entry (info, TAG, VAL)
-
+	
       if (!info->shared)
 	{
 	  if (!add_dynamic_entry (DT_DEBUG, 0))
@@ -4825,6 +4857,12 @@
 	    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,
+                               (PTR) info);
+
       if ((info->flags & DF_TEXTREL) != 0)
 	{
 	  if (!add_dynamic_entry (DT_TEXTREL, 0))

