public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [GAS][AARCH64]Don't try to align insn in non-executale section.
@ 2015-04-20 10:34 Renlin Li
  2015-04-24 16:36 ` Nicholas Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Renlin Li @ 2015-04-20 10:34 UTC (permalink / raw)
  To: binutils; +Cc: Nicholas Clifton, Ramana.Radhakrishnan, Marcus Shawcroft

[-- Attachment #1: Type: text/plain, Size: 1431 bytes --]

Hi all,

After my previous patch, instruction will always try to align itself in 
non-text section. https://sourceware.org/ml/binutils/2015-03/msg00389.html

However, this is not required. Only the text section has strict 
alignment requirements. For other section, just leave as it is.
This fixes the latest Linux kernel build with aarch64 tool-chain.

We have got the following assembler in kernel code. 
.altinstr_replacement is not a executable section. with the previous 
patch, gas will try to align the ldarb insn, creating a new frag which 
is different for the one .L663 in.
".if" directive later complains about this: '''Error: non-constant 
expression in ".if" statement'''

661:
      ldrb w3, [x1]
662:
.pushsection .altinstructions,"a"
.word 661b - .
.word 663f - .
.hword 1
.byte 662b-661b
.byte 664f-663f
.popsection
.pushsection .altinstr_replacement, "a"
663:
      ldarb w3, [x1]
664:
      .popsection
      .if ((664b-663b) != (662b-661b))
          .error "Alternatives instruction length mismatch"
      .endif


With the patch, the behavior should be restored. Binuitls regression 
test runs Okay.
Okay to commit?

Regards,
Renlin Li

gas/ChangeLog:

2015-04-20  Renlin Li  <renlin.li@arm.com>

      * config/tc-aarch64.c (s_aarch64_inst): Don't align code for non-text
      section.
      (md_assemble): Likewise, move the align code outside the loop.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch; name=patch.diff, Size: 2154 bytes --]

diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 5492ff4..9e4738a 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -1858,10 +1858,9 @@ s_aarch64_inst (int ignored ATTRIBUTE_UNUSED)
   /* Sections are assumed to start aligned. In executable 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.  */
+     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)
-		       || !subseg_text_p (now_seg)))
+  if (!need_pass_2 && subseg_text_p (now_seg) && mapstate == MAP_DATA)
     frag_align_code (2, 0);
 
 #ifdef OBJ_ELF
@@ -5690,6 +5689,14 @@ md_assemble (char *str)
 
   init_operand_error_report ();
 
+  /* Sections are assumed to start aligned. In executable 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;
@@ -5705,15 +5712,6 @@ md_assemble (char *str)
 	dump_opcode_operands (opcode);
 #endif /* DEBUG_AARCH64 */
 
-    /* Sections are assumed to start aligned. In executable 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 && ((subseg_text_p (now_seg) && mapstate == MAP_DATA)
-			 || !subseg_text_p (now_seg)))
-      frag_align_code (2, 0);
-
       mapping_state (MAP_INSN);
 
       inst_base = &inst.base;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [GAS][AARCH64]Don't try to align insn in non-executale section.
  2015-04-20 10:34 [GAS][AARCH64]Don't try to align insn in non-executale section Renlin Li
@ 2015-04-24 16:36 ` Nicholas Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nicholas Clifton @ 2015-04-24 16:36 UTC (permalink / raw)
  To: Renlin Li, binutils; +Cc: Ramana.Radhakrishnan, Marcus Shawcroft

Hi Renlin,

> gas/ChangeLog:
> 2015-04-20  Renlin Li  <renlin.li@arm.com>
>
>       * config/tc-aarch64.c (s_aarch64_inst): Don't align code for non-text
>       section.
>       (md_assemble): Likewise, move the align code outside the loop.

Approved - please apply.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-24 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-20 10:34 [GAS][AARCH64]Don't try to align insn in non-executale section Renlin Li
2015-04-24 16:36 ` Nicholas Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).