public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][GAS][AARCH64]Record instruction alignment for .inst directive.
@ 2015-04-28 15:45 Renlin Li
  2015-04-29 10:50 ` Nicholas Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Renlin Li @ 2015-04-28 15:45 UTC (permalink / raw)
  To: binutils; +Cc: Nicholas Clifton, Marcus Shawcroft

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

Hi all,

This is a simple patch that moves the alignment recording code in 
mapping_state early before it returns. So that, all code related 
alignment will be recorded.

For example, one case missed is for .inst directive. When .inst is 
processed, it will call frag_align_code first, which calls 
mapping_state_2 and set current state to MAP_INSN. Later when 
mapping_state is called, it will return early, because there is no state 
change.

For example,
.text
.short 0xffff
.inst 0x12345678   --> this will set MAP_INSN
ret                --> while processing this insn, mapping_state will 
early return as there is no state change.

The alignment of .text section will not be recorded.

Okay to commit?

Regards,
Renlin Li

gas/ChangeLog:

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

     * config/tc-aarch64.c (mapping_state): Recording alignment before exit.

gas/testsuite/ChangeLog

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

     * gas/aarch64/codealign_1.s: New.
     * gas/aarch64/codealign_1.d: New.

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

diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 5492ff4..231a578 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -1460,17 +1460,17 @@ mapping_state (enum mstate state)
 {
   enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate;
 
-  if (mapstate == state)
-    /* The mapping symbol has already been emitted.
-       There is nothing else to do.  */
-    return;
-
   if (state == MAP_INSN)
     /* AArch64 instructions require 4-byte alignment.  When emitting
        instructions into any section, record the appropriate section
        alignment.  */
     record_alignment (now_seg, 2);
 
+  if (mapstate == state)
+    /* The mapping symbol has already been emitted.
+       There is nothing else to do.  */
+    return;
+
 #define TRANSITION(from, to) (mapstate == (from) && state == (to))
   if (TRANSITION (MAP_UNDEFINED, MAP_DATA) && !subseg_text_p (now_seg))
     /* Emit MAP_DATA within executable section in order.  Otherwise, it will be
diff --git a/gas/testsuite/gas/aarch64/codealign_1.d b/gas/testsuite/gas/aarch64/codealign_1.d
new file mode 100644
index 0000000..08f4c25
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/codealign_1.d
@@ -0,0 +1,13 @@
+#objdump: --section-headers
+# Minimum code alignment should be set.
+
+.*: +file format.*aarch64.*
+
+Sections:
+Idx Name          Size      VMA               LMA               File off  Algn
+  0 \.text         .*  .*  .*  .*  2\*\*2
+                  .*CODE.*
+  1 \.data         .*  .*  .* .*  2\*\*0
+                  .*DATA.*
+  2 \.bss          .*  .*  .*  .*  2\*\*0
+.*
diff --git a/gas/testsuite/gas/aarch64/codealign_1.s b/gas/testsuite/gas/aarch64/codealign_1.s
new file mode 100644
index 0000000..b27cc6b
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/codealign_1.s
@@ -0,0 +1,3 @@
+.text
+  .byte 0xf
+  .inst 0xd503201f

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

* Re: [PATCH][GAS][AARCH64]Record instruction alignment for .inst directive.
  2015-04-28 15:45 [PATCH][GAS][AARCH64]Record instruction alignment for .inst directive Renlin Li
@ 2015-04-29 10:50 ` Nicholas Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nicholas Clifton @ 2015-04-29 10:50 UTC (permalink / raw)
  To: Renlin Li, binutils; +Cc: Marcus Shawcroft

Hi Renlin,

> gas/ChangeLog:
>
> 2015-04-28  Renlin Li  <renlin.li@arm.com>
>
>      * config/tc-aarch64.c (mapping_state): Recording alignment before
> exit.
>
> gas/testsuite/ChangeLog
>
> 2015-04-28  Renlin Li  <renlin.li@arm.com>
>
>      * gas/aarch64/codealign_1.s: New.
>      * gas/aarch64/codealign_1.d: New.

Approved - please apply.

Cheers
   Nick

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

end of thread, other threads:[~2015-04-29 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 15:45 [PATCH][GAS][AARCH64]Record instruction alignment for .inst directive Renlin Li
2015-04-29 10:50 ` 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).