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 another ARM GAS segment fault


Even with the patch

http://sourceware.org/ml/binutils/2010-03/msg00262.html

there is still another case which will cause ARM GAS to crash. It's possible that a new mapping symbol will be created at address 0 while there is already another mapping symbol at address 0. So when we see value == 0, we cannot assert first_map == NULL. This patch fixes it. No regressions. Is it OK?


-- Jie Zhang CodeSourcery (650) 331-3385 x735
	* config/tc-arm.c (make_mapping_symbol): Handle the case
	that multiple mapping symbols have the same value 0.

	testsuite/
	* gas/arm/mapmisc.s: Test multiple mapping symbols have
	the same value 0.

Index: config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.439
diff -u -p -r1.439 tc-arm.c
--- config/tc-arm.c	19 Mar 2010 14:43:09 -0000	1.439
+++ config/tc-arm.c	1 Apr 2010 09:16:33 -0000
@@ -2493,19 +2493,24 @@ make_mapping_symbol (enum mstate state, 
   /* Save the mapping symbols for future reference.  Also check that
      we do not place two mapping symbols at the same offset within a
      frag.  We'll handle overlap between frags in
-     check_mapping_symbols.  */
+     check_mapping_symbols.
+
+     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 (value == 0)
     {
-      know (frag->tc_frag_data.first_map == NULL);
+      if (frag->tc_frag_data.first_map != NULL)
+	{
+	  know (S_GET_VALUE (frag->tc_frag_data.first_map) == 0);
+	  symbol_remove (frag->tc_frag_data.first_map, &symbol_rootP, &symbol_lastP);
+	}
       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));
-      /* 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);
     }
Index: testsuite/gas/arm/mapmisc.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/mapmisc.s,v
retrieving revision 1.2
diff -u -p -r1.2 mapmisc.s
--- testsuite/gas/arm/mapmisc.s	19 Mar 2010 14:43:09 -0000	1.2
+++ testsuite/gas/arm/mapmisc.s	1 Apr 2010 09:16:34 -0000
@@ -1,6 +1,8 @@
 	.text
 	.type foo, %function
 foo:
+	.align 2
+	.fill 0, 0, 0
 	nop
 	.ascii "abcd"
 	nop

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