This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

3.4 PATCH: IRIX 6 configuration cleanup and O32 ABI integration


This is revised version the mips-specific bits of

	http://gcc.gnu.org/ml/gcc-patches/2003-09/msg01065.html

Those pieces of the patch to common parts of the compiler have been
submitted separately, although not all of them have been reviewed yet:

	http://gcc.gnu.org/ml/gcc-patches/2003-09/msg01904.html

and two new parts have only just been submitted:

	http://gcc.gnu.org/ml/gcc-patches/2003-09/msg02049.html
	http://gcc.gnu.org/ml/gcc-patches/2003-09/msg02054.html

Compared to the previous version of the patch, this one has been greatly
improved and simplified due to very helpful comments from Richard Sandiford
(Thanks!).

Richard pointed out that the patch could be clarified by always defining
new target macros TARGET_IRIX and TARGET_SGI_O32_AS (which captures both
the IRIX 5 native assembler and the IRIX 6 O32 one, which behave the same)
and using that throughout.

I've verified the patch as follows:

* Bootstrapped unmodified mainline for mips-sgi-irix6.5 and
  mips-sgi-irix6.5o32, both with native as and gas, and then ran the
  testsuite for the N32, N64 (mips-sgi-irix6.5) and O32
  (mips-sgi-irix6.5o32) ABIs separately.

* Bootstrapped with my patches for mips-sgi-irix6.5 and again ran the
  testsuite for all three ABIs separately.

The results are here:

Before the patch:

* mips-sgi-irix6.5, native as, N32:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01108.html

* mips-sgi-irix6.5, native as, N64:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01109.html

* mips-sgi-irix6.5o32, native as, O32:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01110.html

* mips-sgi-irix6.5, GNU as 2.14.90, N32:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01111.html

* mips-sgi-irix6.5, GNU as 2.14.90, N64:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01112.html

* mips-sgi-irix6.5o32, GNU as 2.14.90, O32:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01113.html

After the patch:

* mips-sgi-irix6.5, native as, N32:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01114.html

* mips-sgi-irix6.5, native as, N64:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01116.html

* mips-sgi-irix6.5, native as, O32:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01115.html

* mips-sgi-irix6.5, GNU as 2.14.90, N32:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01117.html

* mips-sgi-irix6.5, GNU as 2.14.90, N64:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01119.html

* mips-sgi-irix6.5, GNU as 2.14.90, O32:

	http://gcc.gnu.org/ml/gcc-testresults/2003-09/msg01118.html

There's one group of failures that look like regressions: for the O32 ABI
with native as, we get this:

+FAIL: gcc.dg/debug/debug-1.c scan-assembler xyzzy

This change is due to the fact that the debug tests weren't run for the
mips-sgi-irix6.5o32 configuration: gcc/testsuite/lib/gcc-dg.exp
(gcc-dg-debug-runtest) explicitly handles the

	target system does not support the * debug format

warning, but gcc with -mabi=32 gives this instead:

	-g is only supported using GNU as with -mabi=32,
	-g option disabled

These are filtered out by dejagnu to avoid lots of spurious failures, so
the disabling doesn't happen.

Another new failure is this one (for the O32 ABI with gas):

+FAIL: gcc.dg/compat/sdata-1 c_compat_y_tst.o compile

sdata-1_y.s:4: Fatal error: unrecognized .section attribute: want a,w,x,M,S,G,T

+++ sdata-1_y.s Tue Sep 23 01:09:57 2003
@@ -1,7 +1,7 @@
        .file   1 "sdata-1_y.c"
        .option pic2
        .globl  small_struct
-       .section        .sdata,"aw",@progbits
+       .section        .sdata,"aws",@progbits
        .align  2
 small_struct:
        .space  20

's' is SECTION_SMALL in varasm.c (default_elf_asm_named_section)

The message comes from gas/config/obj-elf.c
(obj_elf_parse_section_letters).  This didn't occur before since the
mips-sgi-irix6o32 configuration didn't use irix_section_type_flags which
sets SECTION_SMALL for .sdata.  It seems to me that this is a gas bug: if
gcc emits the 's' section attribute for .sdata, gas should be able to
handle this, probably in md_elf_section_letter (like gas/config/tc-alpha.c
(alpha_elf_section_letter) does).

There's certainly potential for more cleanup of the IRIX 5/6
configurations, like modularizing the various specs (especially LINK_SPEC),
which are only slight variations of one another, but this has to wait for a
followup patch.

There's one round of testing still to do, namely building with
--enable-libgcj which is off by default: I've left this out for the current
round to first get the basic configuration right.  This will happen as soon
as the base patch is in.

Ok for mainline?

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University



Mon Sep 29 21:45:21 2003  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* config.gcc (mips-sgi-irix6*o32): Only enable use_collect2
	without gas.
	(mips-sgi-irix6*): Likewise.

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

	* config/mips/mips.h (TARGET_IRIX): Provide default.
	(TARGET_IRIX5): Likewise.
	(TARGET_SGI_O32_AS): Likewise.
	* config/mips/iris5.h (TARGET_IRIX): Redefine as 1.
	(TARGET_IRIX5): Likewise.
	* config/mips/iris6.h (TARGET_IRIX6): Remove.
	(TARGET_IRIX5): Redefine as 0.

	* config/mips/mips.c (mips_output_external): Test for IRIX 6 O32
	linker workaround with TARGET_IRIX and mips_abi instead of
	ASM_OUTPUT_UNDEF_FUNCTION.
	(mips_file_end): Inline old ASM_OUTPUT_UNDEF_FUNCTION definition,
	testing TARGET_IRIX and mips_abi explicitly.
	* config/mips/iris5.h (ASM_OUTPUT_UNDEF_FUNCTION): Remove.
	* config/mips/iris6.h (ASM_OUTPUT_UNDEF_FUNCTION): Remove undef.

	* config/mips/mips.c (irix_output_external_libcall): Renamed from
	mips_output_external_libcall.
	Use new TARGET_IRIX in guard.
	* config/mips/mips-protos.h (irix_output_external_libcall): Match
	this.
	* config/mips/iris5.h (TARGET_ASM_EXTERNAL_LIBCALL): Likewise.

	* config/mips/iris5gas.h (HAVE_GAS_SHF_MERGE): Update comment.
	Define as 0.

	* config/mips/iris6.h (FUNCTION_NAME_ALREADY_DECLARED): Define
	depending on mips_abi. 
	* config/mips/linux.h (FUNCTION_NAME_ALREADY_DECLARED): Define as 1.
	* config/mips/mips.c (mips_output_function_prologue): Test
	FUNCTION_NAME_ALREADY_DECLARED at runtime.
	(mips_output_function_epilogue): Likewise.
	(build_mips16_function_stub): Likewise.
	(build_mips16_call_stub): Likewise.
	* config/mips/mips.h (FUNCTION_NAME_ALREADY_DECLARED): Provide
	default.
	
	* config/mips/iris6.h (DWARF2_UNWIND_INFO): Don't define for native
	IRIX 6 O32 assembler.
	(SUBTARGET_CC1_SPEC): Enforce mips2 ISA with O32 ABI.
	(TARGET_OS_CPP_BUILTINS): Define _ABIO32, use it to define
	_MIPS_SIM for O32 ABI.
	(DWARF2_FRAME_INFO): Don't define for native IRIX 6 O32 assembler.
	(ASM_DECLARE_FUNCTION_NAME): Integrate mips.h version.
	(ASM_DECLARE_FUNCTION_SIZE): Move undef before redefinition.
	Integrate O32 version.
	(SUBTARGET_ASM_SPEC): Handle -mabi=32.
	(SUBTARGET_ASM_DEBUGGING_SPEC): Add mdebug_asm_spec for gas with
	O32 ABI.
	(BSS_SECTION_ASM_OP_32): Define.
	(BSS_SECTION_ASM_OP_64): Likewise.
	(BSS_SECTION_ASM_OP): Define differently for O32 and N32/N64 ABIs
	using them.
	(TARGET_ASM_NAMED_SECTION): Reflect renaming.
	Move up to allow override for O32 ABI without GNU as.
	(EH_FRAME_SECTION_NAME): Define explicitly.
	(MUST_USE_SJLJ_EXCEPTIONS): Define.
	[_MIPS_SIM == _ABIO32 && !GAS] (CTORS_SECTION_ASM_OP,
	DTORS_SECTION_ASM_OP): Dummy definitions.
	(TARGET_ASM_NAMED_SECTION): Undef statically. 
	(EH_FRAME_SECTION_NAME): Likewise.
	(ASM_OUTPUT_FILENAME): Integrate mips.h version.
	(LINK_SPEC): Only use default options -call_shared -no_unresolved
	without -r.
	Don't pass -init, -fini with -mabi=32.
	(COLLECT_PARSE_FLAG): Define.

	* config/mips/mips.c (iris6_asm_named_section_1): Changed guard to
	TARGET_IRIX.
	Renamed to use irix_ prefix.
	(iris6_asm_named_section): Likewise.
	(iris_section_align_entry_eq): Likewise.
	(iris_section_align_entry_hash): Likewise.
	(iris6_file_start): Likewise.
	(iris6_section_align_1): Likewise.
	(iris6_file_end): Likewise.
	(iris6_section_type_flags): Likewise.
	(iris_section_align_htab): Likewise.
	(iris_orig_asm_out_file): Likewise.
	[TARGET_IRIX] (TARGET_ASM_FILE_START): Reflect rename.
	(TARGET_ASM_FILE_END): Likewise.
	(TARGET_SECTION_TYPE_FLAGS): Likewise.

	* config/mips/mips.c [TARGET_IRIX5 && !TARGET_IRIX6]
	(TARGET_ASM_UNALIGNED_HI_OP): Use runtime initialization in
	override_options instead.
	(TARGET_ASM_UNALIGNED_SI_OP): Likewise.
	(TARGET_ASM_UNALIGNED_DI_OP): Likewise.
	* config/mips/mips.c (override_options) [USE_COLLECT2]: Restore
	flag_gnu_linker to defaults without USE_COLLECT2 for non-IRIX O32
	assemblers.
	Likewise for constructor/destructor handling.
	(override_options): Handle IRIX O32 assembler quirks.
	[TARGET_IRIX] (irix_asm_named_section): Handle O32 ABI with and
	without gas.
	(mips_file_start): Use new TARGET_IRIX.
	(mips_declare_object_name): No special processing for IRIX O32
	assembler.
	(mips_finish_declare_object): Likewise.
	(irix_asm_output_align): Renamed from iris6_asm_output_align.
	Don't record alignment for O32 ABI.
	(irix_file_start): Renamed from iris6_file_start.
	Return early for O32 ABI.
	(irix_file_end): Renamed from iris6_file_end.
	Don't emit .section directives for O32 ABI.
	* config/mips/iris6.h (ASM_OUTPUT_ALIGN): Reflect renaming.
	* config/mips/mips-protos.h (irix_asm_output_align): Likewise.

	* config/mips/t-iris6 (MULTILIB_OPTIONS): Add mabi=32.
	(MULTILIB_OSDIRNAMES): Likewise.

Index: gcc/config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.387
diff -u -p -b -r1.387 config.gcc
--- gcc/config.gcc	27 Sep 2003 22:27:10 -0000	1.387
+++ gcc/config.gcc	29 Sep 2003 19:42:02 -0000
@@ -1398,13 +1398,20 @@ mips-sgi-irix6*o32)		# SGI System V.4., 
 	target_cpu_default="MASK_ABICALLS"
 	# mips-tfile doesn't work yet
 	# See comment in mips/iris5.h file.
+	if test x$gas = xno
+	then
 	use_collect2=yes
+	fi
 #	if test x$enable_threads = xyes; then
 #		thread_file='irix'
 #	fi
 	;;
 mips-sgi-irix6*)		# SGI System V.4., IRIX 6
 	tm_file="${tm_file} mips/iris5.h mips/iris6.h"
+	if test x$gas = xyes
+	then
+		tm_file="${tm_file} mips/iris6gas.h"
+	fi
 	if test "x$gnu_ld" = xyes
 	then
 		tm_file="${tm_file} mips/iris6gld.h"
@@ -1412,6 +1419,12 @@ mips-sgi-irix6*)		# SGI System V.4., IRI
 	tmake_file="mips/t-iris mips/t-iris5-6 mips/t-iris6"
 	target_cpu_default="MASK_ABICALLS|MASK_FLOAT64|MASK_64BIT"
 	tm_defines="MIPS_ISA_DEFAULT=3 MIPS_ABI_DEFAULT=ABI_N32"
+	# See comment in mips/iris5.h file.  Only enabled for O32 ABI
+	# without GNU as.
+	if test x$gas = xno
+	then
+		use_collect2=yes
+	fi
 #	if test x$enable_threads = xyes; then
 #		thread_file='irix'
 #	fi
Index: gcc/config/mips/iris5.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris5.h,v
retrieving revision 1.23
diff -u -p -b -r1.23 iris5.h
--- gcc/config/mips/iris5.h	27 Sep 2003 04:48:25 -0000	1.23
+++ gcc/config/mips/iris5.h	29 Sep 2003 19:42:09 -0000
@@ -19,6 +19,12 @@ along with GCC; see the file COPYING.  I
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+/* We are compiling for IRIX now.  */
+#undef TARGET_IRIX
+#define TARGET_IRIX 1
+
+/* Allow some special handling for IRIX 5.  */
+#undef TARGET_IRIX5
 #define TARGET_IRIX5 1
 
 #define ABICALLS_ASM_OP "\t.option pic2"
@@ -203,20 +209,9 @@ do {								\
   fputs ("\n", (FILE));						\
 } while (0)
 
-/* In IRIX 5, we must output a `.global name .text' directive for every used
-   but undefined function.  If we don't, the linker may perform an optimization
-   (skipping over the insns that set $gp) when it is unsafe.  This is used
-   indirectly by ASM_OUTPUT_EXTERNAL.  */
-#define ASM_OUTPUT_UNDEF_FUNCTION(FILE, NAME)	\
-do {						\
-  fputs ("\t.globl ", FILE);			\
-  assemble_name (FILE, NAME);			\
-  fputs (" .text\n", FILE);			\
-} while (0)
-
 /* Also do this for libcalls.  */
 #undef TARGET_ASM_EXTERNAL_LIBCALL
-#define TARGET_ASM_EXTERNAL_LIBCALL mips_output_external_libcall
+#define TARGET_ASM_EXTERNAL_LIBCALL irix_output_external_libcall
 
 /* This does for functions what ASM_DECLARE_OBJECT_NAME does for variables.
    This is used indirectly by ASM_OUTPUT_EXTERNAL.  */
Index: gcc/config/mips/iris5gas.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris5gas.h,v
retrieving revision 1.14
diff -u -p -b -r1.14 iris5gas.h
--- gcc/config/mips/iris5gas.h	14 Jul 2003 20:09:19 -0000	1.14
+++ gcc/config/mips/iris5gas.h	29 Sep 2003 19:42:09 -0000
@@ -76,5 +76,8 @@ do {							\
 #define NM_FLAGS "-Bng"
 
 /* Disable SHF_MERGE support.  Even if gas supports it, the IRIX ld does not
-   without a special elspec(5) file.  */
+   without a special elspec(5) file.
+
+   FIXME: Only do this if not using GNU ld.  */
 #undef HAVE_GAS_SHF_MERGE
+#define HAVE_GAS_SHF_MERGE 0
Index: gcc/config/mips/iris6.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris6.h,v
retrieving revision 1.69
diff -u -p -b -r1.69 iris6.h
--- gcc/config/mips/iris6.h	27 Sep 2003 04:48:25 -0000	1.69
+++ gcc/config/mips/iris6.h	29 Sep 2003 19:42:09 -0000
@@ -19,16 +19,18 @@ along with GCC; see the file COPYING.  I
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Let mips.c know we need the IRIX 6 functions.  */
-#define TARGET_IRIX6 1
+/* No more special IRIX 5 handling.  */
+#undef TARGET_IRIX5
+#define TARGET_IRIX5 0
 
 /* Default to -mabi=n32 and -mips3.  */
 #undef MULTILIB_DEFAULTS
 #define MULTILIB_DEFAULTS { "mabi=n32" }
 
-/* IRIX 6 assembler does handle DWARF2 directives.  Override setting in
-   iris5.h file.  */
+/* The IRIX 6 O32 assembler cannot calculate label differences, while both
+   the N32/N64 assembler and gas can.  Override setting in iris5.h file.  */
 #undef DWARF2_UNWIND_INFO
+#define DWARF2_UNWIND_INFO !TARGET_SGI_O32_AS
 
 /* The IRIX 6 assembler will sometimes assign labels to the wrong
    section unless the labels are within .ent/.end blocks.  Therefore,
@@ -54,8 +56,9 @@ Boston, MA 02111-1307, USA.  */
 /* For IRIX 6, -mabi=64 implies TARGET_LONG64.  */
 /* This is handled in override_options.  */
 
+/* Default to the mips2 ISA for the O32 ABI.  */
 #undef SUBTARGET_CC1_SPEC
-#define SUBTARGET_CC1_SPEC ""
+#define SUBTARGET_CC1_SPEC "%{mabi=32: %{!mips*: -mips2}}"
 
 /* We must pass -D_LONGLONG always, even when -ansi is used, because IRIX 6
    system header files require it.  This is OK, because gcc never warns
@@ -86,7 +89,8 @@ Boston, MA 02111-1307, USA.  */
 							\
      if (mips_abi == ABI_32)				\
       {							\
-	builtin_define ("_MIPS_SIM=_MIPS_SIM_ABI32");	\
+	builtin_define ("_ABIO32=1");			\
+	builtin_define ("_MIPS_SIM=_ABIO32");		\
 	builtin_define ("_MIPS_SZLONG=32");		\
 	builtin_define ("_MIPS_SZPTR=32");		\
       }							\
@@ -146,7 +150,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* Force the generation of dwarf .debug_frame sections even if not
    compiling -g.  This guarantees that we can unwind the stack.  */
-#define DWARF2_FRAME_INFO 1
+#define DWARF2_FRAME_INFO !TARGET_SGI_O32_AS
 
 /* The size in bytes of a DWARF field indicating an offset or length
    relative to a debug info section, specified to be 4 bytes in the DWARF-2
@@ -175,11 +179,6 @@ Boston, MA 02111-1307, USA.  */
 #undef MACHINE_TYPE
 #define MACHINE_TYPE "SGI running IRIX 6.x"
 
-/* IRIX 5 stuff that we don't need for IRIX 6.  */
-/* ??? We do need this for the -mabi=32 switch though.  */
-#undef ASM_OUTPUT_UNDEF_FUNCTION
-#undef ASM_DECLARE_FUNCTION_SIZE
-
 /* Stuff we need for IRIX 6 that isn't in IRIX 5.  */
 
 /* The SGI assembler doesn't like labels before the .ent, so we must output
@@ -188,25 +187,38 @@ Boston, MA 02111-1307, USA.  */
 #undef ASM_DECLARE_FUNCTION_NAME
 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)			\
   do {									\
+    if (mips_abi != ABI_32)						\
+      {									\
     fputs ("\t.ent\t", STREAM);						\
     assemble_name (STREAM, NAME);					\
     fputs ("\n", STREAM);						\
     assemble_name (STREAM, NAME);					\
     fputs (":\n", STREAM);						\
+      }									\
   } while (0)
 
 /* Likewise, the SGI assembler doesn't like labels after the .end, so we
    must output the .end here.  */
+#undef ASM_DECLARE_FUNCTION_SIZE
 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)			\
   do {									\
+    if (mips_abi == ABI_32)						\
+      {									\
+        tree name_tree = get_identifier (NAME);				\
+        TREE_ASM_WRITTEN (name_tree) = 1;				\
+      } 								\
+    else								\
+      {									\
     fputs ("\t.end\t", STREAM);						\
     assemble_name (STREAM, NAME);					\
     fputs ("\n", STREAM);						\
+      }									\
   } while (0)
 
 /* Tell function_prologue in mips.c that we have already output the .ent/.end
    pseudo-ops.  */
-#define FUNCTION_NAME_ALREADY_DECLARED
+#undef FUNCTION_NAME_ALREADY_DECLARED
+#define FUNCTION_NAME_ALREADY_DECLARED (mips_abi != ABI_32)
 
 #undef SET_ASM_OP	/* Has no equivalent.  See ASM_OUTPUT_DEF below.  */
 
@@ -243,7 +255,7 @@ Boston, MA 02111-1307, USA.  */
    on the mipsX option.  */
 /* If no mips[3,4] option given, give the appropriate default for mabi=X */
 #undef SUBTARGET_ASM_SPEC
-#define SUBTARGET_ASM_SPEC "%{!mabi*:-n32} %{!mips*: %{!mabi*:-mips3} %{mabi=n32|mabi=64:-mips3}}"
+#define SUBTARGET_ASM_SPEC "%{!mabi*:-n32} %{mabi=32:-32} %{!mips*: %{!mabi*:-mips3} %{mabi=32:-mips2} %{mabi=n32|mabi=64:-mips3}}"
 
 /* Must pass -g0 to the assembler, otherwise it may overwrite our
    debug info with its own debug info.  */
@@ -257,7 +269,7 @@ Boston, MA 02111-1307, USA.  */
 #define SUBTARGET_MIPS_AS_ASM_SPEC "%{v:-show} -G 0 -w"
 
 #undef SUBTARGET_ASM_DEBUGGING_SPEC
-#define SUBTARGET_ASM_DEBUGGING_SPEC "-g0"
+#define SUBTARGET_ASM_DEBUGGING_SPEC "-g0 %(mdebug_asm_spec)"
 
 /* The MIPS assembler occasionally misoptimizes.  Since GCC should be
    doing scheduling anyhow, just turn off optimization in the assembler.  */
@@ -270,7 +282,12 @@ Boston, MA 02111-1307, USA.  */
    and dtor lists this way, so we use -init and -fini to invoke the
    do_global_* functions instead of running collect2.  */
 
-#define BSS_SECTION_ASM_OP	"\t.section\t.bss"
+#define BSS_SECTION_ASM_OP_32	"\t.data"
+#define BSS_SECTION_ASM_OP_64	"\t.section\t.bss"
+#define BSS_SECTION_ASM_OP			\
+  (mips_abi != ABI_32 && mips_abi != ABI_O64	\
+   ? BSS_SECTION_ASM_OP_64			\
+   : BSS_SECTION_ASM_OP_32)
 
 #undef READONLY_DATA_SECTION_ASM_OP
 #define READONLY_DATA_SECTION_ASM_OP_32	"\t.rdata"
@@ -280,8 +297,41 @@ Boston, MA 02111-1307, USA.  */
    ? READONLY_DATA_SECTION_ASM_OP_64		\
    : READONLY_DATA_SECTION_ASM_OP_32)
 
+/* Switch into a generic section.  */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION  irix_asm_named_section
+
+/* The default definition in defaults.h cannot cope with the runtime-variable
+   definition of DWARF2_UNWIND_INFO above, so define here explicitly.  */
+#define EH_FRAME_SECTION_NAME ".eh_frame"
+
+/* MUST_USE_SJLJ_EXCEPTIONS has the same problem.  */
+#define MUST_USE_SJLJ_EXCEPTIONS (DWARF2_UNWIND_INFO == 0)
+
+/* The native IRIX 6 O32 assembler doesn't support named sections, while
+   the N32/N64 assembler does.  We need crt{begin, end}.o for the N32/N64
+   ABIs, but there's no way to disable them for just one multilib.
+   Therefore we provide dummy definitions to allow crtstuff.c to compile,
+   but the resulting files are not used for the O32 ABI.  */
+
+#if (defined _ABIO32 && _MIPS_SIM == _ABIO32) \
+  && ((TARGET_CPU_DEFAULT | TARGET_DEFAULT) & MASK_GAS) == 0
+
+/* Provide dummy definitions.  */
+#define CTORS_SECTION_ASM_OP ""
+#define DTORS_SECTION_ASM_OP ""
+
+/* Undef so JCR_SECTION_NAME isn't defined and __JCR_{LIST, END}__ are not
+   used.  */
+#undef TARGET_ASM_NAMED_SECTION
+
+/* Undef so __EH_FRAME_BEGIN__/__FRAME_END__ are not used.  */
+#undef EH_FRAME_SECTION_NAME
+
+#endif /* _MIPS_SIM == _ABIO32 && !GAS */
+
 /* Define functions to read the name and flags of the current section.
-   They are used by iris6_asm_output_align.  */
+   They are used by irix_asm_output_align.  */
 
 #undef EXTRA_SECTION_FUNCTIONS
 #define EXTRA_SECTION_FUNCTIONS						\
@@ -320,13 +370,9 @@ current_section_flags (void)						\
   abort ();								\
 }
 
-/* Switch into a generic section.  */
-#undef TARGET_ASM_NAMED_SECTION
-#define TARGET_ASM_NAMED_SECTION  iris6_asm_named_section
-
 /* SGI assembler needs all sorts of extra help to do alignment properly.  */
 #undef ASM_OUTPUT_ALIGN
-#define ASM_OUTPUT_ALIGN iris6_asm_output_align
+#define ASM_OUTPUT_ALIGN irix_asm_output_align
 
 #undef MAX_OFILE_ALIGNMENT
 #define MAX_OFILE_ALIGNMENT (32768*8)
@@ -338,6 +384,9 @@ current_section_flags (void)						\
 #define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME) \
 do								\
   {								\
+    if (mips_abi == ABI_32)					\
+      fprintf (STREAM, "\t.file\t%d ", NUM_SOURCE_FILENAMES);	\
+    else							\
     fprintf (STREAM, "\t#.file\t%d ", NUM_SOURCE_FILENAMES);	\
     output_quoted_string (STREAM, NAME);			\
     fputs ("\n", STREAM);					\
@@ -452,10 +501,19 @@ while (0)
 %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
 %{bestGnum} %{shared} %{non_shared} \
 %{call_shared} %{no_archive} %{exact_version} %{w} \
-%{!shared: %{!non_shared: %{!call_shared: -call_shared -no_unresolved}}} \
-%{rpath} -init __do_global_ctors -fini __do_global_dtors \
+%{!shared: %{!non_shared: %{!call_shared:%{!r: -call_shared -no_unresolved}}}} \
+%{rpath} %{!mabi=32: -init __do_global_ctors -fini __do_global_dtors} \
 %{shared:-hidden_symbol __do_global_ctors,__do_global_ctors_1,__do_global_dtors} \
 -_SYSTYPE_SVR4 -woff 131 \
 %{mabi=32: -32}%{mabi=n32: -n32}%{mabi=64: -64}%{!mabi*: -n32}"
+
+/* We need to disable collecting for the N32 and N64 ABIs.  */
+#define COLLECT_PARSE_FLAG(FLAG)				\
+do {								\
+  if (! strcmp (FLAG, "-n32") || ! strcmp (FLAG, "-64"))	\
+    do_collecting = 0;						\
+  if (! strcmp (FLAG, "-32") || ! strcmp (FLAG, "-o32"))	\
+    do_collecting = 1;						\
+} while (0)
 
 #define MIPS_TFMODE_FORMAT mips_extended_format
Index: gcc/config/mips/iris6gas.h
===================================================================
RCS file: gcc/config/mips/iris6gas.h
diff -N gcc/config/mips/iris6gas.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/config/mips/iris6gas.h	29 Sep 2003 19:42:09 -0000
@@ -0,0 +1,32 @@
+/* Definitions of target machine for GNU compiler.  IRIX 6 with GNU as.  */
+
+/* Override mips.h version to match DWARF 2 default.  */
+#undef MDEBUG_ASM_SPEC
+#define MDEBUG_ASM_SPEC "%{gstabs*|gcoff*:-mdebug} \
+%{!gstabs*:%{!gcoff*:-no-mdebug}}"
+
+/* Override iris6.h version to always use -init/-fini.
+
+   FIXME: integrate those use separate spec/define for this?  */
+#undef LINK_SPEC
+#define LINK_SPEC "\
+%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
+%{bestGnum} %{shared} %{non_shared} \
+%{call_shared} %{no_archive} %{exact_version} %{w} \
+%{!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 -woff 131 \
+%{mabi=32: -32}%{mabi=n32: -n32}%{mabi=64: -64}%{!mabi*: -n32}"
+
+/* Disable SHF_MERGE support.  Even if gas supports it, the IRIX 6 O32 ld
+   does not without a special elspec(5) file.
+
+   FIXME: Only do this if not using GNU ld.  */
+#if HAVE_GAS_SHF_MERGE
+#undef HAVE_GAS_SHF_MERGE
+#define HAVE_GAS_SHF_MERGE (mips_abi != ABI_32)
+#endif /* HAVE_GAS_SHF_MERGE */
+
+/* There's no need to perform collecting with GNU as.  */
+#undef COLLECT_PARSE_FLAG
Index: gcc/config/mips/linux.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/linux.h,v
retrieving revision 1.67
diff -u -p -b -r1.67 linux.h
--- gcc/config/mips/linux.h	27 Sep 2003 04:48:25 -0000	1.67
+++ gcc/config/mips/linux.h	29 Sep 2003 19:42:09 -0000
@@ -171,7 +171,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* Tell function_prologue in mips.c that we have already output the .ent/.end
    pseudo-ops.  */
-#define FUNCTION_NAME_ALREADY_DECLARED
+#define FUNCTION_NAME_ALREADY_DECLARED 1
 
 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL)       		\
   (flag_pic								\
Index: gcc/config/mips/mips-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips-protos.h,v
retrieving revision 1.52
diff -u -p -b -r1.52 mips-protos.h
--- gcc/config/mips/mips-protos.h	28 Sep 2003 07:38:07 -0000	1.52
+++ gcc/config/mips/mips-protos.h	29 Sep 2003 19:42:09 -0000
@@ -98,8 +98,8 @@ extern HOST_WIDE_INT mips_debugger_offse
 extern void print_operand (FILE *, rtx, int);
 extern void print_operand_address (FILE *, rtx);
 extern int mips_output_external (FILE *, tree, const char *);
-#if TARGET_IRIX5 || TARGET_IRIX6
-extern void mips_output_external_libcall (rtx);
+#if TARGET_IRIX
+extern void irix_output_external_libcall (rtx);
 #endif
 extern void mips_output_filename (FILE *, const char *);
 extern void mips_output_lineno (FILE *, int);
@@ -141,7 +141,7 @@ extern unsigned int mips_hard_regno_nreg
 extern int mips_return_in_memory (tree);
 extern const char *mips_emit_prefetch (rtx *);
 
-extern void iris6_asm_output_align (FILE *, unsigned);
+extern void irix_asm_output_align (FILE *, unsigned);
 extern const char *current_section_name (void);
 extern unsigned int current_section_flags (void);
 
Index: gcc/config/mips/mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.316
diff -u -p -b -r1.316 mips.c
--- gcc/config/mips/mips.c	28 Sep 2003 07:39:30 -0000	1.316
+++ gcc/config/mips/mips.c	29 Sep 2003 19:42:09 -0000
@@ -256,17 +256,17 @@ static int mips_adjust_cost (rtx, rtx, r
 static int mips_issue_rate (void);
 static int mips_use_dfa_pipeline_interface (void);
 
-#ifdef TARGET_IRIX6
-static void iris6_asm_named_section_1 (const char *, unsigned int,
+#if TARGET_IRIX
+static void irix_asm_named_section_1 (const char *, unsigned int,
 				       unsigned int);
-static void iris6_asm_named_section (const char *, unsigned int);
-static int iris_section_align_entry_eq (const void *, const void *);
-static hashval_t iris_section_align_entry_hash (const void *);
-static void iris6_file_start (void);
-static int iris6_section_align_1 (void **, void *);
+static void irix_asm_named_section (const char *, unsigned int);
+static int irix_section_align_entry_eq (const void *, const void *);
+static hashval_t irix_section_align_entry_hash (const void *);
+static void irix_file_start (void);
+static int irix_section_align_1 (void **, void *);
 static void copy_file_data (FILE *, FILE *);
-static void iris6_file_end (void);
-static unsigned int iris6_section_type_flags (tree, const char *, int);
+static void irix_file_end (void);
+static unsigned int irix_section_type_flags (tree, const char *, int);
 #endif
 
 /* Structure to be filled in by compute_frame_size with register
@@ -725,17 +725,6 @@ const struct mips_cpu_info mips_cpu_info
 #undef TARGET_ASM_INTEGER
 #define TARGET_ASM_INTEGER mips_assemble_integer
 
-#if TARGET_IRIX5 && !TARGET_IRIX6
-#undef TARGET_ASM_UNALIGNED_HI_OP
-#define TARGET_ASM_UNALIGNED_HI_OP "\t.align 0\n\t.half\t"
-#undef TARGET_ASM_UNALIGNED_SI_OP
-#define TARGET_ASM_UNALIGNED_SI_OP "\t.align 0\n\t.word\t"
-/* The IRIX 6 O32 assembler gives an error for `align 0; .dword', contrary
-   to the documentation, so disable it.  */
-#undef TARGET_ASM_UNALIGNED_DI_OP
-#define TARGET_ASM_UNALIGNED_DI_OP NULL
-#endif
-
 #undef TARGET_ASM_FUNCTION_PROLOGUE
 #define TARGET_ASM_FUNCTION_PROLOGUE mips_output_function_prologue
 #undef TARGET_ASM_FUNCTION_EPILOGUE
@@ -772,9 +761,9 @@ const struct mips_cpu_info mips_cpu_info
 
 #undef TARGET_ASM_FILE_START
 #undef TARGET_ASM_FILE_END
-#ifdef TARGET_IRIX6
-#define TARGET_ASM_FILE_START iris6_file_start
-#define TARGET_ASM_FILE_END iris6_file_end
+#if TARGET_IRIX
+#define TARGET_ASM_FILE_START irix_file_start
+#define TARGET_ASM_FILE_END irix_file_end
 #else
 #define TARGET_ASM_FILE_START mips_file_start
 #define TARGET_ASM_FILE_END mips_file_end
@@ -782,9 +771,9 @@ const struct mips_cpu_info mips_cpu_info
 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
 
-#ifdef TARGET_IRIX6
+#if TARGET_IRIX
 #undef TARGET_SECTION_TYPE_FLAGS
-#define TARGET_SECTION_TYPE_FLAGS iris6_section_type_flags
+#define TARGET_SECTION_TYPE_FLAGS irix_section_type_flags
 #endif
 
 struct gcc_target targetm = TARGET_INITIALIZER;
@@ -4663,6 +4652,60 @@ override_options (void)
   if (mips_abi != ABI_32 && mips_abi != ABI_O64)
     flag_pcc_struct_return = 0;
 
+#if defined(USE_COLLECT2)
+  /* For IRIX 5 or IRIX 6 with integrated O32 ABI support, USE_COLLECT2 is
+     always defined when GNU as is not in use, but collect2 is only used
+     for the O32 ABI, so override the toplev.c and target-def.h defaults
+     for flag_gnu_linker, TARGET_ASM_{CONSTRUCTOR, DESTRUCTOR} and
+     TARGET_HAVE_CTORS_DTORS.
+
+     Since the IRIX 5 and IRIX 6 O32 assemblers cannot handle named
+     sections, constructor/destructor handling depends on the ABI in use.
+
+     Since USE_COLLECT2 is defined, we only need to restore the non-collect2
+     defaults for the N32/N64 ABIs.  */
+  if (TARGET_IRIX && !TARGET_SGI_O32_AS)
+    {
+      flag_gnu_linker = 1;
+
+      targetm.have_ctors_dtors = true;
+      targetm.asm_out.constructor = default_named_section_asm_out_constructor;
+      targetm.asm_out.destructor = default_named_section_asm_out_destructor;
+    }
+#endif
+
+  /* Handle some quirks of the IRIX 5 and IRIX 6 O32 assemblers.  */
+
+  if (TARGET_SGI_O32_AS)
+    {
+      /* They don't recognize `.[248]byte'. */
+      targetm.asm_out.unaligned_op.hi = "\t.align 0\n\t.half\t";
+      targetm.asm_out.unaligned_op.si = "\t.align 0\n\t.word\t";
+      /* The IRIX 6 O32 assembler gives an error for `align 0; .dword',
+	 contrary to the documentation, so disable it.  */
+      targetm.asm_out.unaligned_op.di = NULL;
+
+      /* They cannot handle named sections.  */
+      targetm.have_named_sections = false;
+      /* Therefore, EH_FRAME_SECTION_NAME isn't defined and we must use
+	 collect2.  */
+      targetm.terminate_dw2_eh_frame_info = true;
+      targetm.asm_out.eh_frame_section = collect2_eh_frame_section;
+
+      /* They cannot handle debug information.  */
+      if (write_symbols != NO_DEBUG)
+	{
+	  /* Adapt wording to IRIX version: IRIX 5 only had a single ABI,
+	     so -mabi=32 isn't usually specified.  */
+	  if (TARGET_IRIX5)
+	    warning ("-g is only supported using GNU as,");
+	  else
+	    warning ("-g is only supported using GNU as with -mabi=32,");
+	  warning ("-g option disabled");
+	  write_symbols = NO_DEBUG;
+	}
+    }
+
   if ((target_flags_explicit & MASK_BRANCHLIKELY) == 0)
     {
       /* If neither -mbranch-likely nor -mno-branch-likely was given
@@ -5546,8 +5589,8 @@ mips_output_external (FILE *file ATTRIBU
       extern_head = p;
     }
 
-#ifdef ASM_OUTPUT_UNDEF_FUNCTION
-  if (TREE_CODE (decl) == FUNCTION_DECL
+  if (TARGET_IRIX && mips_abi == ABI_32
+      && TREE_CODE (decl) == FUNCTION_DECL
       /* ??? Don't include alloca, since gcc will always expand it
 	 inline.  If we don't do this, the C++ library fails to build.  */
       && strcmp (name, "alloca")
@@ -5561,14 +5604,13 @@ mips_output_external (FILE *file ATTRIBU
       p->size = -1;
       extern_head = p;
     }
-#endif
 
   return 0;
 }
 
-#if TARGET_IRIX5 || TARGET_IRIX6
+#if TARGET_IRIX
 void
-mips_output_external_libcall (rtx fun)
+irix_output_external_libcall (rtx fun)
 {
   register struct extern_list *p;
 
@@ -5738,7 +5780,7 @@ mips_file_start (void)
 
   if (TARGET_GAS)
     {
-#if defined(OBJECT_FORMAT_ELF) && !(TARGET_IRIX5 || TARGET_IRIX6)
+#if defined(OBJECT_FORMAT_ELF) && !TARGET_IRIX
       /* Generate a special section to describe the ABI switches used to
 	 produce the resultant binary.  This used to be done by the assembler
 	 setting bits in the ELF header's flags field, but we have run out of
@@ -5828,11 +5870,18 @@ mips_file_end (void)
 	  if (! TREE_ASM_WRITTEN (name_tree))
 	    {
 	      TREE_ASM_WRITTEN (name_tree) = 1;
-#ifdef ASM_OUTPUT_UNDEF_FUNCTION
-	      if (p->size == -1)
-		ASM_OUTPUT_UNDEF_FUNCTION (asm_out_file, p->name);
+	      /* In IRIX 5 or IRIX 6 for the O32 ABI, we must output a
+		 `.global name .text' directive for every used but
+		 undefined function.  If we don't, the linker may perform
+		 an optimization (skipping over the insns that set $gp)
+		 when it is unsafe.  */
+	      if (TARGET_IRIX && mips_abi == ABI_32 && p->size == -1)
+		{
+		  fputs ("\t.globl ", asm_out_file);		       
+		  assemble_name (asm_out_file, p->name);
+		  fputs (" .text\n", asm_out_file);
+		}
 	      else
-#endif
 		{
 		  fputs ("\t.extern\t", asm_out_file);
 		  assemble_name (asm_out_file, p->name);
@@ -5872,6 +5921,8 @@ void
 mips_declare_object_name (FILE *stream, const char *name,
 			  tree decl ATTRIBUTE_UNUSED)
 {
+  if (!TARGET_SGI_O32_AS)
+    {
 #ifdef ASM_OUTPUT_TYPE_DIRECTIVE
   ASM_OUTPUT_TYPE_DIRECTIVE (stream, name, "object");
 #endif
@@ -5885,6 +5936,7 @@ mips_declare_object_name (FILE *stream, 
       size = int_size_in_bytes (TREE_TYPE (decl));
       ASM_OUTPUT_SIZE_DIRECTIVE (stream, name, size);
     }
+    }
 
   mips_declare_object (stream, name, "", ":\n", 0);
 }
@@ -5897,7 +5949,8 @@ mips_finish_declare_object (FILE *stream
   const char *name;
 
   name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
-  if (!flag_inhibit_size_directive
+  if (!TARGET_SGI_O32_AS
+      && !flag_inhibit_size_directive
       && DECL_SIZE (decl) != 0
       && !at_end && top_level
       && DECL_INITIAL (decl) == error_mark_node
@@ -6548,9 +6601,7 @@ save_restore_insns (int store_p, rtx lar
 static void
 mips_output_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
 {
-#ifndef FUNCTION_NAME_ALREADY_DECLARED
   const char *fnname;
-#endif
   HOST_WIDE_INT tsize = cfun->machine->frame.total_size;
 
   /* ??? When is this really needed?  At least the GNU assembler does not
@@ -6572,7 +6623,8 @@ mips_output_function_prologue (FILE *fil
       && current_function_args_info.fp_code != 0)
     build_mips16_function_stub (file);
 
-#ifndef FUNCTION_NAME_ALREADY_DECLARED
+  if (!FUNCTION_NAME_ALREADY_DECLARED)
+    {
   /* Get the function name the same way that toplev.c does before calling
      assemble_start_function.  This is needed so that the name used here
      exactly matches the name used in ASM_DECLARE_FUNCTION_NAME.  */
@@ -6587,7 +6639,7 @@ mips_output_function_prologue (FILE *fil
 
   assemble_name (file, fnname);
   fputs (":\n", file);
-#endif
+    }
 
   if (!flag_inhibit_size_directive)
     {
@@ -7042,8 +7094,7 @@ mips_output_function_epilogue (FILE *fil
       set_noreorder = set_nomacro = 0;
     }
 
-#ifndef FUNCTION_NAME_ALREADY_DECLARED
-  if (!flag_inhibit_size_directive)
+  if (!FUNCTION_NAME_ALREADY_DECLARED && !flag_inhibit_size_directive)
     {
       const char *fnname;
 
@@ -7055,7 +7106,6 @@ mips_output_function_epilogue (FILE *fil
       assemble_name (file, fnname);
       fputs ("\n", file);
     }
-#endif
 
   while (string_constants != NULL)
     {
@@ -7949,11 +7999,12 @@ build_mips16_function_stub (FILE *file)
 
   /* ??? If FUNCTION_NAME_ALREADY_DECLARED is defined, then we are
      within a .ent, and we can not emit another .ent.  */
-#ifndef FUNCTION_NAME_ALREADY_DECLARED
+  if (!FUNCTION_NAME_ALREADY_DECLARED)
+    {
   fputs ("\t.ent\t", file);
   assemble_name (file, stubname);
   fputs ("\n", file);
-#endif
+    }
 
   assemble_name (file, stubname);
   fputs (":\n", file);
@@ -7979,11 +8030,12 @@ build_mips16_function_stub (FILE *file)
 
   fprintf (file, "\t.set\treorder\n");
 
-#ifndef FUNCTION_NAME_ALREADY_DECLARED
+  if (!FUNCTION_NAME_ALREADY_DECLARED)
+    {
   fputs ("\t.end\t", file);
   assemble_name (file, stubname);
   fputs ("\n", file);
-#endif
+    }
 
   fprintf (file, "\t.set\tmips16\n");
 
@@ -8178,14 +8230,15 @@ build_mips16_call_stub (rtx retval, rtx 
       fprintf (asm_out_file, "\t.set\tnomips16\n");
       assemble_start_function (stubdecl, stubname);
 
-#ifndef FUNCTION_NAME_ALREADY_DECLARED
+      if (!FUNCTION_NAME_ALREADY_DECLARED)
+	{
       fputs ("\t.ent\t", asm_out_file);
       assemble_name (asm_out_file, stubname);
       fputs ("\n", asm_out_file);
 
       assemble_name (asm_out_file, stubname);
       fputs (":\n", asm_out_file);
-#endif
+	}
 
       /* We build the stub code by hand.  That's the only way we can
 	 do it, since we can't generate 32 bit code during a 16 bit
@@ -8252,11 +8305,12 @@ build_mips16_call_stub (rtx retval, rtx 
       ASM_DECLARE_FUNCTION_SIZE (asm_out_file, stubname, stubdecl);
 #endif
 
-#ifndef FUNCTION_NAME_ALREADY_DECLARED
+      if (!FUNCTION_NAME_ALREADY_DECLARED)
+	{
       fputs ("\t.end\t", asm_out_file);
       assemble_name (asm_out_file, stubname);
       fputs ("\n", asm_out_file);
-#endif
+	}
 
       fprintf (asm_out_file, "\t.set\tmips16\n");
 
@@ -9609,11 +9663,11 @@ mips_emit_prefetch (rtx *operands)
 
 
 
-#ifdef TARGET_IRIX6
+#if TARGET_IRIX
 /* Output assembly to switch to section NAME with attribute FLAGS.  */
 
 static void
-iris6_asm_named_section_1 (const char *name, unsigned int flags,
+irix_asm_named_section_1 (const char *name, unsigned int flags,
 			   unsigned int align)
 {
   unsigned int sh_type, sh_flags, sh_entsize;
@@ -9646,57 +9700,64 @@ iris6_asm_named_section_1 (const char *n
 }
 
 static void
-iris6_asm_named_section (const char *name, unsigned int flags)
+irix_asm_named_section (const char *name, unsigned int flags)
 {
-  iris6_asm_named_section_1 (name, flags, 0);
+  if (TARGET_SGI_O32_AS)
+    default_no_named_section (name, flags);
+  else if (mips_abi == ABI_32 && TARGET_GAS)
+    default_elf_asm_named_section (name, flags);
+  else
+    irix_asm_named_section_1 (name, flags, 0);
 }
 
 /* In addition to emitting a .align directive, record the maximum
    alignment requested for the current section.  */
 
-struct GTY (()) iris_section_align_entry
+struct GTY (()) irix_section_align_entry
 {
   const char *name;
   unsigned int log;
   unsigned int flags;
 };
 
-static htab_t iris_section_align_htab;
-static FILE *iris_orig_asm_out_file;
+static htab_t irix_section_align_htab;
+static FILE *irix_orig_asm_out_file;
 
 static int
-iris_section_align_entry_eq (const void *p1, const void *p2)
+irix_section_align_entry_eq (const void *p1, const void *p2)
 {
-  const struct iris_section_align_entry *old = p1;
+  const struct irix_section_align_entry *old = p1;
   const char *new = p2;
 
   return strcmp (old->name, new) == 0;
 }
 
 static hashval_t
-iris_section_align_entry_hash (const void *p)
+irix_section_align_entry_hash (const void *p)
 {
-  const struct iris_section_align_entry *old = p;
+  const struct irix_section_align_entry *old = p;
   return htab_hash_string (old->name);
 }
 
 void
-iris6_asm_output_align (FILE *file, unsigned int log)
+irix_asm_output_align (FILE *file, unsigned int log)
 {
   const char *section = current_section_name ();
-  struct iris_section_align_entry **slot, *entry;
+  struct irix_section_align_entry **slot, *entry;
 
+  if (mips_abi != ABI_32)
+    {
   if (! section)
     abort ();
 
-  slot = (struct iris_section_align_entry **)
-    htab_find_slot_with_hash (iris_section_align_htab, section,
+      slot = (struct irix_section_align_entry **)
+	htab_find_slot_with_hash (irix_section_align_htab, section,
 			      htab_hash_string (section), INSERT);
   entry = *slot;
   if (! entry)
     {
-      entry = (struct iris_section_align_entry *)
-	xmalloc (sizeof (struct iris_section_align_entry));
+	  entry = (struct irix_section_align_entry *)
+	    xmalloc (sizeof (struct irix_section_align_entry));
       *slot = entry;
       entry->name = section;
       entry->log = log;
@@ -9704,34 +9765,38 @@ iris6_asm_output_align (FILE *file, unsi
     }
   else if (entry->log < log)
     entry->log = log;
+    }
 
   fprintf (file, "\t.align\t%u\n", log);
 }
 
-/* The Iris assembler does not record alignment from .align directives,
+/* The IRIX assembler does not record alignment from .align directives,
    but takes it from the first .section directive seen.  Play file
    switching games so that we can emit a .section directive at the
    beginning of the file with the proper alignment attached.  */
 
 static void
-iris6_file_start (void)
+irix_file_start (void)
 {
   mips_file_start ();
 
-  iris_orig_asm_out_file = asm_out_file;
+  if (mips_abi == ABI_32)
+    return;
+
+  irix_orig_asm_out_file = asm_out_file;
   asm_out_file = tmpfile ();
 
-  iris_section_align_htab = htab_create (31, iris_section_align_entry_hash,
-					 iris_section_align_entry_eq, NULL);
+  irix_section_align_htab = htab_create (31, irix_section_align_entry_hash,
+					 irix_section_align_entry_eq, NULL);
 }
 
 static int
-iris6_section_align_1 (void **slot, void *data ATTRIBUTE_UNUSED)
+irix_section_align_1 (void **slot, void *data ATTRIBUTE_UNUSED)
 {
-  const struct iris_section_align_entry *entry
-    = *(const struct iris_section_align_entry **) slot;
+  const struct irix_section_align_entry *entry
+    = *(const struct irix_section_align_entry **) slot;
 
-  iris6_asm_named_section_1 (entry->name, entry->flags, 1 << entry->log);
+  irix_asm_named_section_1 (entry->name, entry->flags, 1 << entry->log);
   return 1;
 }
 
@@ -9756,16 +9821,19 @@ copy_file_data (FILE *to, FILE *from)
 }
 
 static void
-iris6_file_end (void)
+irix_file_end (void)
 {
+  if (mips_abi != ABI_32)
+    {
   /* Emit section directives with the proper alignment at the top of the
      real output file.  */
   FILE *temp = asm_out_file;
-  asm_out_file = iris_orig_asm_out_file;
-  htab_traverse (iris_section_align_htab, iris6_section_align_1, NULL);
+      asm_out_file = irix_orig_asm_out_file;
+      htab_traverse (irix_section_align_htab, irix_section_align_1, NULL);
 
   /* Copy the data emitted to the temp file to the real output file.  */
   copy_file_data (asm_out_file, temp);
+    }
 
   mips_file_end ();
 }
@@ -9776,7 +9844,7 @@ iris6_file_end (void)
    default code.  */
 
 static unsigned int
-iris6_section_type_flags (tree decl, const char *section, int relocs_p)
+irix_section_type_flags (tree decl, const char *section, int relocs_p)
 {
   unsigned int flags;
 
@@ -9791,7 +9859,6 @@ iris6_section_type_flags (tree decl, con
   return flags;
 }
 
-
-#endif /* TARGET_IRIX6 */
+#endif /* TARGET_IRIX */
 
 #include "gt-mips.h"
Index: gcc/config/mips/mips.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.291
diff -u -p -b -r1.291 mips.h
--- gcc/config/mips/mips.h	28 Sep 2003 07:38:07 -0000	1.291
+++ gcc/config/mips/mips.h	29 Sep 2003 19:42:11 -0000
@@ -337,6 +337,11 @@ extern const struct mips_cpu_info *mips_
 
 #define TARGET_NEWABI		    (mips_abi == ABI_N32 || mips_abi == ABI_64)
 
+/* IRIX specific stuff.  */
+#define TARGET_IRIX	   0
+#define TARGET_IRIX5	   0
+#define TARGET_SGI_O32_AS  (TARGET_IRIX && mips_abi == ABI_32 && !TARGET_GAS)
+
 /* Define preprocessor macros for the -march and -mtune options.
    PREFIX is either _MIPS_ARCH or _MIPS_TUNE, INFO is the selected
    processor.  If INFO's canonical name is "foo", define PREFIX to
@@ -3285,7 +3290,6 @@ while (0)
 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
   mips_output_external(STREAM,DECL,NAME)
 
-
 /* This is how to declare a function name.  The actual work of
    emitting the label is moved to function_prologue, so that we can
    get the line number correctly emitted before the .ent directive,
@@ -3294,6 +3298,10 @@ while (0)
 
 #undef ASM_DECLARE_FUNCTION_NAME
 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL)
+
+#ifndef FUNCTION_NAME_ALREADY_DECLARED
+#define FUNCTION_NAME_ALREADY_DECLARED 0
+#endif
 
 /* This is how to store into the string LABEL
    the symbol_ref name of an internal numbered label where
Index: gcc/config/mips/t-iris6
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/t-iris6,v
retrieving revision 1.18
diff -u -p -b -r1.18 t-iris6
--- gcc/config/mips/t-iris6	1 Apr 2003 21:45:28 -0000	1.18
+++ gcc/config/mips/t-iris6	29 Sep 2003 19:42:11 -0000
@@ -1,10 +1,9 @@
 # ??? If no mabi=X option given, but a mipsX option is, then should deal
 # with that.
-# ??? mabi=32 is deliberately left off the list because it doesn't work yet.
-MULTILIB_OPTIONS=mabi=n32/mabi=64
+MULTILIB_OPTIONS=mabi=32/mabi=n32/mabi=64
 MULTILIB_DIRNAMES=
 MULTILIB_MATCHES=
-MULTILIB_OSDIRNAMES=. mabi=64
+MULTILIB_OSDIRNAMES=mabi=32 . mabi=64
 
 LIBGCC = stmp-multilib
 INSTALL_LIBGCC = install-multilib


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