[AArch64] Emit DATA_MAP in order within text section
authorRenlin Li <renlin.li@arm.com>
Thu, 2 Apr 2015 13:59:45 +0000 (14:59 +0100)
committerJiong Wang <jiong.wang@arm.com>
Thu, 2 Apr 2015 13:59:45 +0000 (14:59 +0100)
2015-03-27  Renlin Li  <renlin.li@arm.com>

gas/
  * config/tc-aarch64.c (mapping_state): Emit MAP_DATA within text section in order.
  (mapping_state_2): Don't emit MAP_DATA here.
  (s_aarch64_inst): Align frag during state transition.
  (md_assemble): Likewise.

gas/ChangeLog
gas/config/tc-aarch64.c

index 4c57d734190081c401ae236f38117d7503d784d6..d8335abe6c98b8a487accf72ad3a491fc2ba83ed 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-02  Renlin Li  <renlin.li@arm.com>
+
+       * config/tc-aarch64.c (mapping_state): Emit MAP_DATA within text section in order.
+       (mapping_state_2): Don't emit MAP_DATA here.
+       (s_aarch64_inst): Align frag during state transition.
+       (md_assemble): Likewise.
+
 2015-04-02  Ed Maste  <emaste@freebsd.org>
 
        * config/tc-aarch64.c (set_error_kind): Delete.
index 1d4d1d057acfab82edadf3dbebe720a6168099aa..2163d5394788fa4ba51f61baa3e43d91ad462f51 100644 (file)
@@ -1455,7 +1455,6 @@ static void mapping_state_2 (enum mstate state, int max_chars);
 /* Set the mapping state to STATE.  Only call this when about to
    emit some STATE bytes to the file.  */
 
-#define TRANSITION(from, to) (mapstate == (from) && state == (to))
 void
 mapping_state (enum mstate state)
 {
@@ -1472,9 +1471,25 @@ mapping_state (enum mstate state)
        alignment.  */
     record_alignment (now_seg, 2);
 
-  if (TRANSITION (MAP_UNDEFINED, MAP_DATA))
-    /* This case will be evaluated later in the next else.  */
+#define TRANSITION(from, to) (mapstate == (from) && state == (to))
+  if (TRANSITION (MAP_UNDEFINED, MAP_DATA) && now_seg != text_section)
+    /* Emit MAP_DATA within text section in order. Otherwise, it will be
+       evaluated later in the next else.  */
     return;
+  else if (TRANSITION (MAP_UNDEFINED, MAP_INSN))
+    {
+      /* Only add the symbol if the offset is > 0:
+        if we're at the first frag, check it's size > 0;
+        if we're not at the first frag, then for sure
+        the offset is > 0.  */
+      struct frag *const frag_first = seg_info (now_seg)->frchainP->frch_root;
+      const int add_symbol = (frag_now != frag_first)
+       || (frag_now_fix () > 0);
+
+      if (add_symbol)
+       make_mapping_symbol (MAP_DATA, (valueT) 0, frag_first);
+    }
+#undef TRANSITION
 
   mapping_state_2 (state, 0);
 }
@@ -1495,24 +1510,9 @@ mapping_state_2 (enum mstate state, int max_chars)
        There is nothing else to do.  */
     return;
 
-  if (TRANSITION (MAP_UNDEFINED, MAP_INSN))
-    {
-      /* Only add the symbol if the offset is > 0:
-        if we're at the first frag, check it's size > 0;
-        if we're not at the first frag, then for sure
-        the offset is > 0.  */
-      struct frag *const frag_first = seg_info (now_seg)->frchainP->frch_root;
-      const int add_symbol = (frag_now != frag_first)
-       || (frag_now_fix () > 0);
-
-      if (add_symbol)
-       make_mapping_symbol (MAP_DATA, (valueT) 0, frag_first);
-    }
-
   seg_info (now_seg)->tc_segment_info_data.mapstate = state;
   make_mapping_symbol (state, (valueT) frag_now_fix () - max_chars, frag_now);
 }
-#undef TRANSITION
 #else
 #define mapping_state(x)       /* nothing */
 #define mapping_state_2(x, y)  /* nothing */
@@ -1855,8 +1855,15 @@ 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, align it anyway.  */
+  enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate;
+  if (!need_pass_2 && ((now_seg == text_section && mapstate == MAP_DATA)
+                      || now_seg != text_section))
     frag_align_code (2, 0);
+
 #ifdef OBJ_ELF
   mapping_state (MAP_INSN);
 #endif
@@ -5698,6 +5705,15 @@ md_assemble (char *str)
        dump_opcode_operands (opcode);
 #endif /* DEBUG_AARCH64 */
 
+    /* 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, align it anyway.  */
+    enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate;
+    if (!need_pass_2 && ((now_seg == text_section && mapstate == MAP_DATA)
+                        || now_seg != text_section))
+       frag_align_code (2, 0);
+
       mapping_state (MAP_INSN);
 
       inst_base = &inst.base;
This page took 0.035865 seconds and 4 git commands to generate.