This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix ARM GAS segment fault


ARM GAS crashes on the following test case now:

nop
.fill 0, 0, 0
nop

This .fill directive does not generate anything. So the mapping symbol "$d" generated for this .fill will have the same value as the "$a" generated for the second "nop", which GAS does not allow.

To fix this case, this patch just allows two mapping symbols have the same value and let the new one override the old one.

No regression on GAS testsuite. Is it OK?

Regards,
--
Jie Zhang
CodeSourcery
(650) 331-3385 x735
	* config/tc-arm.c (make_mapping_symbol): Hanle the case
	that two mapping symbols have the same value.

	testsuite/
	* gas/arm/mapmisc.s, gas/arm/mapmisc.d: Add the test case
	for two mapping symbols having the same value.

Index: config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.437
diff -u -p -r1.437 tc-arm.c
--- config/tc-arm.c	5 Mar 2010 10:41:04 -0000	1.437
+++ config/tc-arm.c	16 Mar 2010 08:22:12 -0000
@@ -2500,7 +2500,15 @@ make_mapping_symbol (enum mstate state, 
       frag->tc_frag_data.first_map = symbolP;
     }
   if (frag->tc_frag_data.last_map != NULL)
-    know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP));
+    {
+      know (S_GET_VALUE (frag->tc_frag_data.last_map) <= S_GET_VALUE (symbolP));
+      /* If .fill or other data filling directive generates zero sized data,
+	 the mapping symbol for the following code will have the same value
+	 as the one generated for the data filling directive.  In this case,
+	 we replace the old symbol with the new one at the same address.  */
+      if (S_GET_VALUE (frag->tc_frag_data.last_map) == S_GET_VALUE (symbolP))
+	symbol_remove (frag->tc_frag_data.last_map, &symbol_rootP, &symbol_lastP);
+    }
   frag->tc_frag_data.last_map = symbolP;
 }
 
Index: testsuite/gas/arm/mapmisc.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/mapmisc.d,v
retrieving revision 1.3
diff -u -p -r1.3 mapmisc.d
--- testsuite/gas/arm/mapmisc.d	30 Jun 2009 11:57:05 -0000	1.3
+++ testsuite/gas/arm/mapmisc.d	16 Mar 2010 08:22:12 -0000
@@ -46,6 +46,7 @@ SYMBOL TABLE:
 0+9c l       .text	00000000 \$a
 0+a0 l       .text	00000000 \$d
 0+a4 l       .text	00000000 \$a
+0+a8 l       .text	00000000 \$a
 0+00 l    d  .ARM.attributes	00000000 .ARM.attributes
 
 
@@ -93,3 +94,4 @@ Disassembly of section .text:
   9c:	e1a00000 	nop			; \(mov r0, r0\)
   a0:	7778797a 	.word	0x7778797a
   a4:	e1a00000 	nop			; \(mov r0, r0\)
+  a8:	e1a00000 	nop			; \(mov r0, r0\)
Index: testsuite/gas/arm/mapmisc.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/mapmisc.s,v
retrieving revision 1.1
diff -u -p -r1.1 mapmisc.s
--- testsuite/gas/arm/mapmisc.s	5 Mar 2009 15:27:59 -0000	1.1
+++ testsuite/gas/arm/mapmisc.s	16 Mar 2010 08:22:12 -0000
@@ -34,3 +34,5 @@ foo:
 	nop
 	.incbin "mapmisc.dat"
 	nop
+	.fill 0, 0, 0
+	nop

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]