This is the mail archive of the 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]

Committed; fix PR gas/14521, missing renumber_sections for MMIX. Also, RFC.

The SEGV was due to accessing a number_of_sections-sized array with
stale section indices; one too high.

You might think this should be covered by some test in
gas/testsuite/elf, but mmix-knuth-mmixware doesn't count as an ELF
target, despite the object format (until linking) is ELF.  Still, that
test-suite would require lots of changes to avoid spurious failures
for mmix-knuth-mmixware; writing @type instead of %type in e.g. .type
and .section (the opposite of arm*-*) and somehow using a different
syntax for local labels; the ".L0:" is invalid.

I'm blaming tc-extensa.c for setting a bad example; it has a similar
renumber-sections need and solution in its md_post_relax_hook.  But
seriously, I'd like this unkludged.  At the very least I suggest
renumber_sections can be globalized and renamed gas_renumber_sections.
Would that be ok?  Maybe we can do better, like moving the
renumber_sections call in write.c to after tc_frob_file_before_fix and
md_post_relax_hook, assuming valid section numbers aren't needed
before that for some other target.  It'd have to be a target-specific
need or else the Xtensa and MMIX kludges will fail for some cases.

I also noticed that the .section call doesn't modify the existing
.text section but instead causes an *extra* .text section, one with
the AXG flags.  Should that really happen?  (Same for cris-elf and mmix.)

I'll commit this to the 2.23 branch too, together with the
gas/mmix/fb-2 fix committed earlier.

	PR gas/14521
	* config/tc-mmix.h (tc_frob_file_before_fix): Renumber sections
	after call to mmix_frob_file.

	PR gas/14521
	* gas/mmix/group-1.d, gas/mmix/group-1.s: New test.

Index: gas/mmix/group-1.d
RCS file: gas/mmix/group-1.d
diff -N gas/mmix/group-1.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/mmix/group-1.d	1 Sep 2012 17:09:18 -0000
@@ -0,0 +1,12 @@
+#readelf: -Wa
+# Sanity check; the .section line caused a gas SEGV.
+# See PR gas/14521.
+ +\[ .\] \.text +PROGBITS +0+ +0+48 +0+ +0+ +AXG +.*
+COMDAT group section \[    1\] `\.group' \[\.foo\] contains 1 sections:
+ +\[Index\] +Name
+ +\[ +.\] +\.text
Index: gas/mmix/group-1.s
RCS file: gas/mmix/group-1.s
diff -N gas/mmix/group-1.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/mmix/group-1.s	1 Sep 2012 17:09:18 -0000
@@ -0,0 +1 @@
+ .section .text,"axG",@progbits,.foo,comdat

Index: config/tc-mmix.h
RCS file: /cvs/src/src/gas/config/tc-mmix.h,v
retrieving revision 1.14
diff -p -u -r1.14 tc-mmix.h
--- config/tc-mmix.h	2 Sep 2009 07:24:20 -0000	1.14
+++ config/tc-mmix.h	1 Sep 2012 17:02:03 -0000
@@ -194,7 +194,18 @@ extern fragS *mmix_opcode_frag;
    fixups are done and relocs are output.  Similarly for each unknown
    symbol.  */
 extern void mmix_frob_file (void);
-#define tc_frob_file_before_fix mmix_frob_file
+#define tc_frob_file_before_fix()					\
+  do									\
+    {									\
+      int i = 0;							\
+									\
+      /* It's likely mmix_frob_file changed (removed) sections, so make	\
+	 sure sections are correctly numbered as per renumber_sections,	\
+	 (static to write.c where this macro is called).  */		\
+      mmix_frob_file ();						\
+      bfd_map_over_sections (stdoutput, renumber_sections, &i);		\
+    }									\
+  while (0)

 /* Used by mmix_frob_file.  Hangs on section symbols and unknown symbols.  */
 struct mmix_symbol_gregs;

brgds, H-P

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