public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [GAS][ARM]Positively emit symbols for alignment.
@ 2015-04-24 12:53 Renlin Li
  2015-04-24 16:40 ` Nicholas Clifton
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Renlin Li @ 2015-04-24 12:53 UTC (permalink / raw)
  To: binutils; +Cc: Nicholas Clifton, Marcus Shawcroft, Richard Earnshaw

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

Hi all,

In arm_init_frag(), when ARM or THUMB are recorded,  it will simply 
return without doing anything. This is not correct in a few cases.

For the following two cases:
case 1:
         nop        ----> MAP_ARM
         .long   0 ---> MAP_DATA
         .align  4 --->
                       ---->(1)
                       ----> start new frag
         .word   0x12345678

(1) paddings here are all treated as data, because the previous state is 
MAP_DATA.

case 2:
         nop       ----> MAP_ARM
         .long   0 ---> MAP_DATA
         .byte   1
         .align  2 ---> (1)
                      ----> (2)
                      ----> start new frag
         .long   0x12345678 ----> (3)

stage 1: while parsing the input file:
(1) arm_init_frag early returns, No state change, no new symbol. (3)No 
state change, no new symbol.
stage 2: Later, while writing the object file:
(2)MAP_DATA, MAP_ARM are inserted by insert_data_mapping_symol to handle 
alignment. (3) interpreted as instruction because of the MAP_ARM 
inserted at (2)


This change might generate redundant symbols, some of them can be 
removed later. In check_mapping_symbols(), the symbols at the end of a 
section, and overlapping symbols will be removed.

gas checked without any new issues. Okay to commit?

By the way, Nick, aarch64 has the same issue. The same can be done to 
aarch64_init_frag(). Another way is to remove 
fragP->tc_frag_data.recorded. It's only used in a few places. But I am 
sure what dose it intended to do, Could you please explain a little bit 
for me?

Regards,
Renlin Li


gas/ChangeLog:

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

     * config/tc-arm.c (arm_init_frag): Always emit mapping symbols.

gas/testsuite/ChangeLog:

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

     * gas/arm/thumb2_vpool_be.d: Adjust the desired output.
     * gas/arm/vldconst_be.d: Ditto.


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

diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index b17ea6c..5fa2790 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -21015,24 +21015,22 @@ arm_init_frag (fragS * fragP, int max_chars)
   /* If the current ARM vs THUMB mode has not already
      been recorded into this frag then do so now.  */
   if ((fragP->tc_frag_data.thumb_mode & MODE_RECORDED) == 0)
-    {
       fragP->tc_frag_data.thumb_mode = thumb_mode | MODE_RECORDED;
 
-      /* Record a mapping symbol for alignment frags.  We will delete this
-	 later if the alignment ends up empty.  */
-      switch (fragP->fr_type)
-	{
-	  case rs_align:
-	  case rs_align_test:
-	  case rs_fill:
-	    mapping_state_2 (MAP_DATA, max_chars);
-	    break;
-	  case rs_align_code:
-	    mapping_state_2 (thumb_mode ? MAP_THUMB : MAP_ARM, max_chars);
-	    break;
-	  default:
-	    break;
-	}
+  /* Record a mapping symbol for alignment frags.  We will delete this
+     later if the alignment ends up empty.  */
+  switch (fragP->fr_type)
+    {
+    case rs_align:
+    case rs_align_test:
+    case rs_fill:
+      mapping_state_2 (MAP_DATA, max_chars);
+      break;
+    case rs_align_code:
+      mapping_state_2 (thumb_mode ? MAP_THUMB : MAP_ARM, max_chars);
+      break;
+    default:
+      break;
     }
 }
 
diff --git a/gas/testsuite/gas/arm/thumb2_vpool_be.d b/gas/testsuite/gas/arm/thumb2_vpool_be.d
index 816cddc..15aafa5 100644
--- a/gas/testsuite/gas/arm/thumb2_vpool_be.d
+++ b/gas/testsuite/gas/arm/thumb2_vpool_be.d
@@ -125,8 +125,7 @@ Disassembly of section .text:
 000001c8 <thumb2_ldr\+0x1c8> 0ff00fff 	.word	0x0ff00fff
 000001cc <thumb2_ldr\+0x1cc> f0000000 	.word	0xf0000000
 000001d0 <thumb2_ldr\+0x1d0> ed9f 1b01 	vldr	d1, \[pc, #4\]	; 000001d8 <thumb2_ldr\+0x1d8>
-000001d4 <thumb2_ldr\+0x1d4> 0000      	movs	r0, r0
-000001d6 <thumb2_ldr\+0x1d6> 0000      	movs	r0, r0
+000001d4 <thumb2_ldr\+0x1d4> 00000000 	.word	0x00000000
 000001d8 <thumb2_ldr\+0x1d8> 0000fff0 	.word	0x0000fff0
 000001dc <thumb2_ldr\+0x1dc> 00000000 	.word	0x00000000
 000001e0 <thumb2_ldr\+0x1e0> f101 0000 	add.w	r0, r1, #0
@@ -150,8 +149,7 @@ Disassembly of section .text:
 00000228 <thumb2_ldr\+0x228> eddf 7a03 	vldr	s15, \[pc, #12\]	; 00000238 <thumb2_ldr\+0x238>
 0000022c <thumb2_ldr\+0x22c> eddf 0b14 	vldr	d16, \[pc, #80\]	; 00000280 <thumb2_ldr\+0x280>
 00000230 <thumb2_ldr\+0x230> eddf 1b15 	vldr	d17, \[pc, #84\]	; 00000288 <thumb2_ldr\+0x288>
-00000234 <thumb2_ldr\+0x234> 0000      	movs	r0, r0
-00000236 <thumb2_ldr\+0x236> 0000      	movs	r0, r0
+00000234 <thumb2_ldr\+0x234> 00000000 	.word	0x00000000
 00000238 <thumb2_ldr\+0x238> 0000fff0 	.word	0x0000fff0
 0000023c <thumb2_ldr\+0x23c> 00000000 	.word	0x00000000
 00000240 <thumb2_ldr\+0x240> ff000000 	.word	0xff000000
diff --git a/gas/testsuite/gas/arm/vldconst_be.d b/gas/testsuite/gas/arm/vldconst_be.d
index cf3dbf9..f99371b 100644
--- a/gas/testsuite/gas/arm/vldconst_be.d
+++ b/gas/testsuite/gas/arm/vldconst_be.d
@@ -236,7 +236,7 @@ Disassembly of section .text:
 00000388 <foo\+0x388> 0000fff0 	.word	0x0000fff0
 0000038c <foo\+0x38c> 00000000 	.word	0x00000000
 00000390 <foo\+0x390> ed9f1b00 	vldr	d1, \[pc\]	; 00000398 <foo\+0x398>
-00000394 <foo\+0x394> 00000000 	andeq	r0, r0, r0
+00000394 <foo\+0x394> 00000000 	.word	0x00000000
 00000398 <foo\+0x398> 0000fff0 	.word	0x0000fff0
 0000039c <foo\+0x39c> 00000000 	.word	0x00000000
 000003a0 <foo\+0x3a0> e2810000 	add	r0, r1, #0
@@ -260,7 +260,7 @@ Disassembly of section .text:
 000003e8 <foo\+0x3e8> eddf7a02 	vldr	s15, \[pc, #8\]	; 000003f8 <foo\+0x3f8>
 000003ec <foo\+0x3ec> eddf0b13 	vldr	d16, \[pc, #76\]	; 00000440 <foo\+0x440>
 000003f0 <foo\+0x3f0> eddf1b14 	vldr	d17, \[pc, #80\]	; 00000448 <foo\+0x448>
-000003f4 <foo\+0x3f4> 00000000 	andeq	r0, r0, r0
+000003f4 <foo\+0x3f4> 00000000 	.word	0x00000000
 000003f8 <foo\+0x3f8> 0000fff0 	.word	0x0000fff0
 000003fc <foo\+0x3fc> 00000000 	.word	0x00000000
 00000400 <foo\+0x400> ff000000 	.word	0xff000000

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

end of thread, other threads:[~2015-06-17 10:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-24 12:53 [GAS][ARM]Positively emit symbols for alignment Renlin Li
2015-04-24 16:40 ` Nicholas Clifton
2015-05-05 15:22   ` Commit: [GAS][AARCH64]Positively " Renlin Li
2015-04-28 21:07 ` [GAS][ARM]Positively " Hans-Peter Nilsson
2015-04-29  9:21   ` [GAS][ARM]Positively emit symbols for alignment. --> [PATCH][LD][ARM] Fix two test case failures Renlin Li
2015-04-29  9:23     ` Richard Earnshaw
2015-06-16  8:24 ` [2.25][ARM][GAS]Backport "Positively emit symbols for alignment." Renlin Li
2015-06-16  8:29   ` Tristan Gingold
2015-06-16  8:31   ` Renlin Li
2015-06-17  9:39 ` [2.25][AARCH64][GAS]Backport " Renlin Li
2015-06-17 10:20   ` Tristan Gingold

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).