0005-xtensa-gas-put-.literal_position-at-section-start.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From 471702ac4a57878a06e8167f063274cf413e548d Mon Sep 17 00:00:00 2001
  2. From: Max Filippov <jcmvbkbc@gmail.com>
  3. Date: Mon, 8 Apr 2019 13:47:18 -0700
  4. Subject: [PATCH] xtensa: gas: put .literal_position at section start
  5. Provide literal position at the beginning of each section for literal
  6. space reserved by relaxations when text-section-literals or
  7. auto-litpools options are used. Remove code that adds fill frag to the
  8. literal section for every .literal_position directive to avoid creation
  9. of empty literal sections.
  10. Fix auto-litpools tests that got literal pool address changes.
  11. gas/
  12. 2019-04-11 Max Filippov <jcmvbkbc@gmail.com>
  13. * config/tc-xtensa.c (xtensa_is_init_fini): Add declaration.
  14. (xtensa_mark_literal_pool_location): Don't add fill frag to literal
  15. section that records literal pool location.
  16. (md_begin): Call xtensa_mark_literal_pool_location when text
  17. section literals or auto litpools are used.
  18. (xtensa_elf_section_change_hook): Call
  19. xtensa_mark_literal_pool_location when text section literals or
  20. auto litpools are used, there's no literal pool location defined
  21. for the current section and it's not .init or .fini.
  22. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
  23. ---
  24. gas/config/tc-xtensa.c | 22 +++++++++-------------
  25. 1 file changed, 9 insertions(+), 13 deletions(-)
  26. diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
  27. index 0cc06361cf6f..6a80e76fed8c 100644
  28. --- a/gas/config/tc-xtensa.c
  29. +++ b/gas/config/tc-xtensa.c
  30. @@ -497,6 +497,7 @@ static fixS *xg_append_jump (fragS *fragP, symbolS *sym, offsetT offset);
  31. static void xtensa_maybe_create_literal_pool_frag (bfd_boolean, bfd_boolean);
  32. static bfd_boolean auto_litpools = FALSE;
  33. static int auto_litpool_limit = 0;
  34. +static bfd_boolean xtensa_is_init_fini (segT seg);
  35. /* Alignment Functions. */
  36. @@ -4797,7 +4798,6 @@ xtensa_mark_literal_pool_location (void)
  37. {
  38. /* Any labels pointing to the current location need
  39. to be adjusted to after the literal pool. */
  40. - emit_state s;
  41. fragS *pool_location;
  42. if (use_literal_section)
  43. @@ -4818,19 +4818,7 @@ xtensa_mark_literal_pool_location (void)
  44. RELAX_LITERAL_POOL_END, NULL, 0, NULL);
  45. xtensa_set_frag_assembly_state (frag_now);
  46. - /* Now put a frag into the literal pool that points to this location. */
  47. set_literal_pool_location (now_seg, pool_location);
  48. - xtensa_switch_to_non_abs_literal_fragment (&s);
  49. - frag_align (2, 0, 0);
  50. - record_alignment (now_seg, 2);
  51. -
  52. - /* Close whatever frag is there. */
  53. - frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL);
  54. - xtensa_set_frag_assembly_state (frag_now);
  55. - frag_now->tc_frag_data.literal_frag = pool_location;
  56. - frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL);
  57. - xtensa_restore_emit_state (&s);
  58. - xtensa_set_frag_assembly_state (frag_now);
  59. }
  60. @@ -5334,6 +5322,9 @@ md_begin (void)
  61. /* Set up the assembly state. */
  62. if (!frag_now->tc_frag_data.is_assembly_state_set)
  63. xtensa_set_frag_assembly_state (frag_now);
  64. +
  65. + if (!use_literal_section)
  66. + xtensa_mark_literal_pool_location ();
  67. }
  68. @@ -5933,6 +5924,11 @@ xtensa_elf_section_change_hook (void)
  69. /* Set up the assembly state. */
  70. if (!frag_now->tc_frag_data.is_assembly_state_set)
  71. xtensa_set_frag_assembly_state (frag_now);
  72. +
  73. + if (!use_literal_section
  74. + && seg_info (now_seg)->tc_segment_info_data.literal_pool_loc == NULL
  75. + && !xtensa_is_init_fini (now_seg))
  76. + xtensa_mark_literal_pool_location ();
  77. }
  78. --
  79. 2.11.0