diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 2163d53..85fa68a 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -1860,8 +1860,8 @@ s_aarch64_inst (int ignored ATTRIBUTE_UNUSED)
      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))
+  if (!need_pass_2 && ((subseg_text_p (now_seg) && mapstate == MAP_DATA)
+		       || ! subseg_text_p (now_seg)))
     frag_align_code (2, 0);
 
 #ifdef OBJ_ELF
@@ -5710,8 +5710,8 @@ md_assemble (char *str)
        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))
+    if (!need_pass_2 && ((subseg_text_p (now_seg) && mapstate == MAP_DATA)
+			 || ! subseg_text_p (now_seg)))
 	frag_align_code (2, 0);
 
       mapping_state (MAP_INSN);
