600-arm-textrel.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. http://sources.redhat.com/ml/binutils/2004-06/msg00010.html
  2. --- binutils-2.15.90.0.3-old/bfd/elf32-arm.h 2004-04-12 14:56:33.000000000 -0500
  3. +++ binutils-2.15.90.0.3/bfd/elf32-arm.h 2004-09-03 06:56:40.000000000 -0500
  4. @@ -87,6 +87,8 @@
  5. #endif
  6. static bfd_boolean allocate_dynrelocs
  7. PARAMS ((struct elf_link_hash_entry *h, PTR inf));
  8. +static bfd_boolean elf32_arm_readonly_dynrelocs
  9. + PARAMS ((struct elf_link_hash_entry *, PTR));
  10. static bfd_boolean create_got_section
  11. PARAMS ((bfd * dynobj, struct bfd_link_info * info));
  12. static bfd_boolean elf32_arm_create_dynamic_sections
  13. @@ -3531,6 +3533,37 @@
  14. return TRUE;
  15. }
  16. +/* Find any dynamic relocs that apply to read-only sections. */
  17. +
  18. +static bfd_boolean
  19. +elf32_arm_readonly_dynrelocs (h, inf)
  20. + struct elf_link_hash_entry *h;
  21. + PTR inf;
  22. +{
  23. + struct elf32_arm_link_hash_entry *eh;
  24. + struct elf32_arm_relocs_copied *p;
  25. +
  26. + if (h->root.type == bfd_link_hash_warning)
  27. + h = (struct elf_link_hash_entry *) h->root.u.i.link;
  28. +
  29. + eh = (struct elf32_arm_link_hash_entry *) h;
  30. + for (p = eh->relocs_copied; p != NULL; p = p->next)
  31. + {
  32. + asection *s = p->section;
  33. +
  34. + if (s != NULL && (s->flags & SEC_READONLY) != 0)
  35. + {
  36. + struct bfd_link_info *info = (struct bfd_link_info *) inf;
  37. +
  38. + info->flags |= DF_TEXTREL;
  39. +
  40. + /* Not an error, just cut short the traversal. */
  41. + return FALSE;
  42. + }
  43. + }
  44. + return TRUE;
  45. +}
  46. +
  47. /* Set the sizes of the dynamic sections. */
  48. static bfd_boolean
  49. @@ -3740,6 +3773,12 @@
  50. return FALSE;
  51. }
  52. + /* If any dynamic relocs apply to a read-only section,
  53. + then we need a DT_TEXTREL entry. */
  54. + if ((info->flags & DF_TEXTREL) == 0)
  55. + elf_link_hash_traverse (&htab->root, elf32_arm_readonly_dynrelocs,
  56. + (PTR) info);
  57. +
  58. if ((info->flags & DF_TEXTREL) != 0)
  59. {
  60. if (!add_dynamic_entry (DT_TEXTREL, 0))