0006-arm-pie-tls.diff 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From 7d6e280a0f3b9978b0edb20173d067d071531a3d Mon Sep 17 00:00:00 2001
  2. From: Szabolcs Nagy <[email protected]>
  3. Date: Wed, 2 Oct 2019 19:46:46 +0100
  4. Subject: [PATCH] [PR ld/22263][PR ld/25056] arm: Avoid dynamic TLS relocs in
  5. PIE
  6. Dynamic relocs are only needed in an executable for TLS symbols if
  7. those are defined in an external module and even then TLS access
  8. can be relaxed to use IE model instead of GD.
  9. Several bfd_link_pic checks are turned into bfd_link_dll checks
  10. to fix TLS handling in PIE, for the same fix some other targets
  11. used !bfd_link_executable checks, but that includes relocatable
  12. objects so dll seems safer (in most cases either should work, since
  13. dynamic relocations are not applied in relocatable objects).
  14. On arm* fixes
  15. FAIL: Build pr22263-1
  16. bfd/
  17. 2019-10-02 Szabolcs Nagy <[email protected]>
  18. PR ld/22263
  19. PR ld/25056
  20. * elf32-arm.c (elf32_arm_tls_transition): Use bfd_link_dll instead of
  21. bfd_link_pic for TLS checks.
  22. (elf32_arm_final_link_relocate): Likewise.
  23. (allocate_dynrelocs_for_symbol): Likewise.
  24. ---
  25. bfd/elf32-arm.c | 10 +++++-----
  26. 1 file changed, 5 insertions(+), 5 deletions(-)
  27. diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
  28. index bb53e039e3..451949d278 100644
  29. --- a/bfd/elf32-arm.c
  30. +++ b/bfd/elf32-arm.c
  31. @@ -4914,7 +4914,7 @@ elf32_arm_tls_transition (struct bfd_link_info *info, int r_type,
  32. {
  33. int is_local = (h == NULL);
  34. - if (bfd_link_pic (info)
  35. + if (bfd_link_dll (info)
  36. || (h && h->root.type == bfd_link_hash_undefweak))
  37. return r_type;
  38. @@ -11700,7 +11700,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
  39. {
  40. /* If we don't know the module number, create a relocation
  41. for it. */
  42. - if (bfd_link_pic (info))
  43. + if (bfd_link_dll (info))
  44. {
  45. Elf_Internal_Rela outrel;
  46. @@ -11804,7 +11804,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
  47. now, and emit any relocations. If both an IE GOT and a
  48. GD GOT are necessary, we emit the GD first. */
  49. - if ((bfd_link_pic (info) || indx != 0)
  50. + if ((bfd_link_dll (info) || indx != 0)
  51. && (h == NULL
  52. || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
  53. && !resolved_to_zero)
  54. @@ -11821,7 +11821,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
  55. /* We should have relaxed, unless this is an undefined
  56. weak symbol. */
  57. BFD_ASSERT ((h && (h->root.type == bfd_link_hash_undefweak))
  58. - || bfd_link_pic (info));
  59. + || bfd_link_dll (info));
  60. BFD_ASSERT (globals->sgotplt_jump_table_size + offplt + 8
  61. <= globals->root.sgotplt->size);
  62. @@ -16494,7 +16494,7 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf)
  63. indx = h->dynindx;
  64. if (tls_type != GOT_NORMAL
  65. - && (bfd_link_pic (info) || indx != 0)
  66. + && (bfd_link_dll (info) || indx != 0)
  67. && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
  68. || h->root.type != bfd_link_hash_undefweak))
  69. {
  70. --
  71. 2.17.1