3.3 PATCH: Support DWARF-2 EH on IRIX 6 O32

Rainer Orth ro@TechFak.Uni-Bielefeld.DE
Fri Jul 19 12:20:00 GMT 2002


While debugging a large number of C++ EH failures on the
mips-sgi-irix6.[25]o32 configuration with gas 2.12.1 and stabs-in-mdebug
debug information, I noticed that I see almost no information on the
affected routines in libstdc++.so and libgcc_s.so, so stabs support in gdb
5.2 seems to suffer from severe bitrot (or intrinsic limitations of the
format).  To get a handle on what's going on, I decided to try switching to
DWARF-2 debugging.  Trying to use gas 2.12.1 initially, bootstrap failed
since that version generates invalid object files (with sections completely
beyond the end of the object file, something the IRIX 6 O32 ld correctly
chokes on).  Switching to gas 2.12.90 allowed me to bootstrap with DWARF-2
debugging the default (by configuring with --without-stabs to override the
default provided by the toplevel configure.in) and find the cause of the
observed EH failures: the configuration didn't include crt{begin, end}.o,
thus __register_frame_info wasn't called and unwind-dw2-fde.c
unseen_objects and seen_objects in unwind-dw2-fde.c remained uninitialized,
so _Unwind_Find_FDE returned NULL, causing __cxa_throw to fail and crash
the program.

Fixing this (and a follow-up patch to handle the new -mdebug switch in gas
2.12.90) gave me testsuite results for this configuration with only 10
additional failures compared to the mips-sgi-irix6.2 (i.e. N32 ABI)
results.  I'll post an analysis (and hopefully fixes) of those failures
when I return from vacation in three weeks.

The following trivial patch implements this:

* It makes DWARF-2 debugging the default for the mips-sgi-irix5 and
  mips-sgi-irix6*o32 configurations with gas (this is currently overridden
  as described above).

* It builds and includes crt{begin, end}.o for the gas configurations only.
  Since the IRIX 6 O32 as doesn't handle named sections (despite being an
  ELF assembler, it's mainly a port of the old IRIX 5 one), this must not
  be turned on when as is in use.

Bootstrapped successfully on mips-sgi-irix6.5o32.

Ok for mainline?

	Rainer


Wed Jul 17 20:41:46 2002  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* config/mips/iris5gas.h (DWARF2_DEBUGGING_INFO): Define.
	(PREFERRED_DEBUGGING_TYPE): Use DWARF2_DEBUG.
	(LINK_SPEC): Define.
	(STARTFILE_SPEC): Define.
	(ENDFILE_SPEC): Define.

	* config/mips/iris6-o32.h (LINK_SPEC): Move ...
	* config/mips/iris6-o32-as.h (LINK_SPEC): ... here.

	* config/mips/iris6-o32-gas.h: New file.
	* config.gcc (mips-sgi-irix6*o32): Use it.

	* config/mips/t-iris5-gas: New file.
	* config.gcc (mips-sgi-irix6*o32, mips-sgi-irix5*): Use it.

Index: gcc/config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.224
diff -u -p -r1.224 config.gcc
--- gcc/config.gcc	14 Jul 2002 07:01:35 -0000	1.224
+++ gcc/config.gcc	19 Jul 2002 17:03:37 -0000
@@ -1748,11 +1748,12 @@ mcore-*-pe*)
 mips-sgi-irix6*o32)		# SGI System V.4., IRIX 6, O32 ABI
 	if test x$gas = xyes
 	then
-		tm_file="mips/iris5.h mips/iris5gas.h"
+		tm_file="mips/iris5.h mips/iris5gas.h mips/iris6-o32-gas.h"
 		if test x$stabs = xyes
 		then
 			tm_file="${tm_file} dbx.h"
 		fi
+		tmake_file=mips/t-iris5-gas
 	else
 		tm_file="mips/iris5.h mips/iris6-o32-as.h"
 		tmake_file=mips/t-iris5-as
@@ -1826,6 +1827,7 @@ mips-sgi-irix5*)		# SGI System V.4., IRI
 		then
 			tm_file="${tm_file} dbx.h"
 		fi
+		tmake_file=mips/t-iris5-gas
 	else
 		tm_file=mips/iris5.h
 		tmake_file=mips/t-iris5-as
Index: gcc/config/mips/iris5gas.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris5gas.h,v
retrieving revision 1.8
diff -u -p -r1.8 iris5gas.h
--- gcc/config/mips/iris5gas.h	11 Jul 2002 18:56:56 -0000	1.8
+++ gcc/config/mips/iris5gas.h	19 Jul 2002 17:03:45 -0000
@@ -2,13 +2,43 @@
 
 /* Enable debugging.  */
 #define DBX_DEBUGGING_INFO
+#define DWARF2_DEBUGGING_INFO
 #define SDB_DEBUGGING_INFO
 #define MIPS_DEBUGGING_INFO
-#define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
 
 /* GNU as does handle DWARF2 directives.  */
 #undef DWARF2_UNWIND_INFO
 #define DWARF2_UNWIND_INFO 1
+
+/* Override iris5.h version to invoke [cd]tors and register eh frame
+   information.  */
+#undef LINK_SPEC
+#define LINK_SPEC "\
+%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} \
+%{bestGnum} %{shared} %{non_shared} \
+%{call_shared} %{no_archive} %{exact_version} \
+%{static: -non_shared} \
+%{!static: \
+  %{!shared:%{!non_shared:%{!call_shared: -call_shared -no_unresolved}}}} \
+%{rpath} -init __do_global_ctors -fini __do_global_dtors \
+%{shared:-hidden_symbol __do_global_ctors,__do_global_ctors_1,__do_global_dtors} \
+-_SYSTYPE_SVR4"
+
+/* Override iris5.h versions to include crtbegin.o and crtend.o.  */
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "\
+%{!static: \
+  %{!shared:%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s libprof1.a%s}%{!p:crt1.o%s}}}} \
+%{static: \
+  %{pg:gcrt1.o%s} \
+  %{!pg:%{p:/usr/lib/nonshared/mcrt1.o%s libprof1.a%s} \
+  %{!p:/usr/lib/nonshared/crt1.o%s}}} \
+crtbegin.o%s"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "crtend.o%s %{!shared:crtn.o%s}"
 
 /* Irix 5 does not have some strange restrictions that Irix 3 had.  */
 #undef SET_FILE_NUMBER
Index: gcc/config/mips/iris6-o32-as.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris6-o32-as.h,v
retrieving revision 1.1
diff -u -p -r1.1 iris6-o32-as.h
--- gcc/config/mips/iris6-o32-as.h	11 Jul 2002 18:56:56 -0000	1.1
+++ gcc/config/mips/iris6-o32-as.h	19 Jul 2002 17:03:45 -0000
@@ -11,3 +11,19 @@
 #define SUBTARGET_ASM_OPTIMIZING_SPEC "\
 %{noasmopt:-O0} \
 %{!noasmopt:%{O|O1|O2|O3:-O2}}"
+
+/* Enforce use of O32 linker, irrespective of SGI_ABI environment variable
+   and machine type (e.g., R8000 systems default to -64).  Copied from
+   iris5.h, only adding -32.  The default options -call_shared -no_unresolved
+   are only passed if not invoked with -r.  */
+#undef LINK_SPEC
+#define LINK_SPEC "\
+%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} \
+%{bestGnum} %{shared} %{non_shared} \
+%{call_shared} %{no_archive} %{exact_version} \
+%{static: -non_shared} \
+%{!static: \
+  %{!shared:%{!non_shared:%{!call_shared:%{!r: -call_shared -no_unresolved}}}}} \
+%{rpath} \
+-_SYSTYPE_SVR4 \
+-32"
Index: gcc/config/mips/iris6-o32-gas.h
===================================================================
RCS file: gcc/config/mips/iris6-o32-gas.h
diff -N gcc/config/mips/iris6-o32-gas.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/config/mips/iris6-o32-gas.h	19 Jul 2002 17:03:45 -0000
@@ -0,0 +1,19 @@
+/* Definitions of target machine for GNU compiler, for MIPS running IRIX 6
+   (O32 ABI) using the GNU assembler.  */
+
+/* Enforce use of O32 linker, irrespective of SGI_ABI environment variable
+   and machine type (e.g., R8000 systems default to -64).  Copied from
+   iris5gas.h, only adding -32.  The default options -call_shared
+   -no_unresolved are only passed if not invoked with -r.  */
+#undef LINK_SPEC
+#define LINK_SPEC "\
+%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} \
+%{bestGnum} %{shared} %{non_shared} \
+%{call_shared} %{no_archive} %{exact_version} \
+%{static: -non_shared} \
+%{!static: \
+  %{!shared:%{!non_shared:%{!call_shared:%{!r: -call_shared -no_unresolved}}}}} \
+%{rpath} -init __do_global_ctors -fini __do_global_dtors \
+%{shared:-hidden_symbol __do_global_ctors,__do_global_ctors_1,__do_global_dtors} \
+-_SYSTYPE_SVR4 \
+-32"
Index: gcc/config/mips/iris6-o32.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris6-o32.h,v
retrieving revision 1.1
diff -u -p -r1.1 iris6-o32.h
--- gcc/config/mips/iris6-o32.h	11 Jul 2002 18:56:56 -0000	1.1
+++ gcc/config/mips/iris6-o32.h	19 Jul 2002 17:03:45 -0000
@@ -66,19 +66,3 @@
    to -mips1 if no ISA is specified.  */
 #undef SUBTARGET_ASM_SPEC
 #define SUBTARGET_ASM_SPEC "-32 %{!mips*:-mips2}"
-
-/* Enforce use of O32 linker, irrespective of SGI_ABI environment variable
-   and machine type (e.g., R8000 systems default to -64).  Copied from
-   iris5.h, only adding -32.  The default options -call_shared -no_unresolved
-   are only passed if not invoked with -r.  */
-#undef LINK_SPEC
-#define LINK_SPEC "\
-%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} \
-%{bestGnum} %{shared} %{non_shared} \
-%{call_shared} %{no_archive} %{exact_version} \
-%{static: -non_shared} \
-%{!static: \
-  %{!shared:%{!non_shared:%{!call_shared:%{!r: -call_shared -no_unresolved}}}}} \
-%{rpath} \
--_SYSTYPE_SVR4 \
--32"
Index: gcc/config/mips/t-iris5-gas
===================================================================
RCS file: gcc/config/mips/t-iris5-gas
diff -N gcc/config/mips/t-iris5-gas
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/config/mips/t-iris5-gas	19 Jul 2002 17:03:47 -0000
@@ -0,0 +1,5 @@
+# For svr4 we build crtbegin.o and crtend.o which serve to add begin and
+# end labels to the .ctors and .dtors section when we link using gcc.
+
+EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o
+CRTSTUFF_T_CFLAGS=-g1



More information about the Gcc-patches mailing list