[binutils-gdb/binutils-2_25-branch] [AArch64][Backport] Don't always create new frag for .inst directive

Jiong Wang jiwang@sourceware.org
Thu May 7 10:59:00 GMT 2015


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4e4d08cf7399b60668ebfeb1eee8ec0625fd368a

commit 4e4d08cf7399b60668ebfeb1eee8ec0625fd368a
Author: Renlin Li <renlin.li@arm.com>
Date:   Thu May 7 11:47:53 2015 +0100

    [AArch64][Backport] Don't always create new frag for .inst directive
    
      2015-05-06  Renlin Li  <renlin.li@arm.com>
    
      Backport from mainline
      gas/
        * config/tc-aarch64.c (s_aarch64_inst): Align frag during state
        transition within executable section.
        (md_assemble): Likewise.

Diff:
---
 gas/ChangeLog           |  6 ++++++
 gas/config/tc-aarch64.c | 16 +++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 300833a..7632ef8 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2015-05-07  Renlin Li  <renlin.li@arm.com>
+
+	* config/tc-aarch64.c (s_aarch64_inst): Align frag during state
+	transition within executable section.
+	(md_assemble): Likewise.
+
 2015-04-06  Evandro Menezes  <e.menezes@samsung.com>
 
 	* config/tc-aarch64.c: Add support for Samsung Exynos M1.
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index ce2ba95..62a1a3f 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -1863,8 +1863,14 @@ s_aarch64_inst (int ignored ATTRIBUTE_UNUSED)
       return;
     }
 
-  if (!need_pass_2)
+  /* Sections are assumed to start aligned. In text section, there is no
+     MAP_DATA symbol pending. So we only align the address during
+     MAP_DATA --> MAP_INSN transition.
+     For other sections, this is not guaranteed.  */
+  enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate;
+  if (!need_pass_2 && (subseg_text_p (now_seg) && mapstate == MAP_DATA))
     frag_align_code (2, 0);
+
 #ifdef OBJ_ELF
   mapping_state (MAP_INSN);
 #endif
@@ -5571,6 +5577,14 @@ md_assemble (char *str)
 
   init_operand_error_report ();
 
+  /* Sections are assumed to start aligned. In text section, there is no
+     MAP_DATA symbol pending. So we only align the address during
+     MAP_DATA --> MAP_INSN transition.
+     For other sections, this is not guaranteed.  */
+  enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate;
+  if (!need_pass_2 && (subseg_text_p (now_seg) && mapstate == MAP_DATA))
+    frag_align_code (2, 0);
+
   saved_cond = inst.cond;
   reset_aarch64_instruction (&inst);
   inst.cond = saved_cond;



More information about the Binutils-cvs mailing list