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]

patches for mips-linux


Ralf Baechle recently gave me some patches for egcs 1.0 to 
support mips-linux.  The following is a partial reorg by
myself, reasoning that some of the bits really belong in
mips/elf.h, rather than in a linux-specific file.

I have had some success reports from a mips-linux guinea pig,
but I'd like Jim to comment on the bits that affect mips-elf
(in that why was mips relying on collect2/gld rather than
using a .ctors section like everyone else) and Ralf to double
check that I've not left out anything.

And while I once had a GNU account, it seems to have been
deactivated, so someone should double check that Ralf's
paperwork is proper.


r~
Toplevel Changelog

	* config.guess (mips-linux): Detect endianness via machine properties
	not compiler defines.
	* config.sub (mips-*-linux): Default middle triple to unknown.
	* configure.in (enable_shared): Default mips-linux on.

GCC Changelog

	* configure.in (mips*-*-linux*): New entries.
	* gcc.1 (mips options): Delete obsolete -mlonglong128.
	* mips/elf.h (ASM_OUTPUT_ALIGNED_COMMON): New.
	(ASM_OUTPUT_ALIGNED_LOCAL): New.
	(EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Redefine, adding ctors
	and dtors bits.
	(ASM_OUTPUT_CONSTRUCTOR, ASM_OUTPUT_DESTRUCTOR): New.
	* mips/linux.h, mips/t-linux: New files.

Index: config.guess
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/config.guess,v
retrieving revision 1.11
diff -c -p -d -r1.11 config.guess
*** config.guess	1998/05/11 22:36:06	1.11
--- config.guess	1998/06/17 02:02:53
*************** main(argc, argv)
*** 534,540 ****
  #if defined(__GLIBC__)
    printf("%s %s\n", __libc_version, __libc_release);
  #else
!   printf("unkown\n");
  #endif
    return 0;
  }
--- 534,540 ----
  #if defined(__GLIBC__)
    printf("%s %s\n", __libc_version, __libc_release);
  #else
!   printf("unknown\n");
  #endif
    return 0;
  }
*************** EOF
*** 600,621 ****
  		rm -f dummy.s dummy
  		echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
  	elif test "${UNAME_MACHINE}" = "mips" ; then
! 	  cat >dummy.c <<EOF
! main(argc, argv)
!      int argc;
!      char *argv[];
! {
! #ifdef __MIPSEB__
!   printf ("%s-unknown-linux-gnu\n", argv[1]);
! #endif
! #ifdef __MIPSEL__
!   printf ("%sel-unknown-linux-gnu\n", argv[1]);
! #endif
!   return 0;
! }
  EOF
! 	  ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
! 	  rm -f dummy.c dummy
  	else
  	  # Either a pre-BFD a.out linker (linux-gnuoldld)
  	  # or one that does not give us useful --help.
--- 600,620 ----
  		rm -f dummy.s dummy
  		echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
  	elif test "${UNAME_MACHINE}" = "mips" ; then
! 		sed 's/^		//'  <<EOF >dummy.c
! 		int main()
! 		{
! 			int x = 1;
! 			return !*(char *)&x; /* Exit 1 for big-endian */
! 		}
  EOF
! 		${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy
! 		if test "$?" = 1 ; then
! 			echo mips-unknown-linux-gnu
! 		else
! 			echo mipsel-unknown-linux-gnu
! 		fi
! 		rm -f dummy.c dummy
! 		exit 0
  	else
  	  # Either a pre-BFD a.out linker (linux-gnuoldld)
  	  # or one that does not give us useful --help.
Index: config.sub
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/config.sub,v
retrieving revision 1.10
diff -c -p -d -r1.10 config.sub
*** config.sub	1998/04/03 16:21:57	1.10
--- config.sub	1998/06/17 02:02:53
*************** case $basic_machine in
*** 816,826 ****
  		basic_machine=hppa1.1-oki
  		;;
  	mips)
! 		if [ x$os = x-linux-gnu ]; then
! 			basic_machine=mips-unknown
! 		else
! 			basic_machine=mips-mips
! 		fi
  		;;
  	romp)
  		basic_machine=romp-ibm
--- 816,825 ----
  		basic_machine=hppa1.1-oki
  		;;
  	mips)
! 		case x$os in
! 		  x-linux*) basic_machine=mips-unknown ;;
! 		  *) basic_machine=mips-mips;;
! 		esac
  		;;
  	romp)
  		basic_machine=romp-ibm
Index: configure.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/configure.in,v
retrieving revision 1.19
diff -c -p -d -r1.19 configure.in
*** configure.in	1998/04/28 04:36:17	1.19
--- configure.in	1998/06/17 02:02:53
*************** if false && [ "${host}" = "${target}" ] 
*** 249,254 ****
--- 249,255 ----
      alpha*-dec-osf*)	enable_shared=yes ;;
      alpha*-*-linux*)	enable_shared=yes ;;
      mips-sgi-irix5*)	enable_shared=yes ;;
+     mips*-*-linux*)	enable_shared=yes ;;
      *)			enable_shared=no ;;
    esac
  fi
Index: gcc/configure
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/configure,v
retrieving revision 1.111
diff -c -p -d -r1.111 configure
*** configure	1998/06/10 12:58:41	1.111
--- configure	1998/06/17 02:02:53
*************** for machine in $build $host $target; do
*** 3957,3962 ****
--- 3957,3980 ----
  			use_collect2=yes
  		fi
  		;;
+ 	mips*el-*-linux*)		# Little endian MIPS w/ Linux & ELF
+ 		tm_file="mips/elfl.h mips/linux.h"
+ 		tmake_file="mips/t-linux"
+ 		xm_file="mips/xm-mips.h xm-linux.h"
+                 xmake_file=none
+ 		gnu_ld=yes gas=yes
+ 		extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+                 fixincludes=Makefile.in
+ 		;;
+ 	mips*-*-linux*)			# Big endian MIPS w/ Linux & ELF
+ 		tm_file="mips/elf.h mips/linux.h"
+ 		tmake_file="mips/t-linux"
+ 		xm_file="mips/xm-mips.h xm-linux.h"
+                 xmake_file=none
+ 		gnu_ld=yes gas=yes
+ 		extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+                 fixincludes=Makefile.in
+ 		;;
  	mips-*-gnu*)
  		;;
  	mipsel-*-ecoff*)
*************** fi
*** 5126,5132 ****
  
  # Figure out what assembler alignment features are present.
  echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6
! echo "configure:5130: checking assembler alignment features" >&5
  gcc_cv_as=
  gcc_cv_as_alignment_features=
  if [ -x as$host_exeext ]; then
--- 5144,5150 ----
  
  # Figure out what assembler alignment features are present.
  echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6
! echo "configure:5148: checking assembler alignment features" >&5
  gcc_cv_as=
  gcc_cv_as_alignment_features=
  if [ -x as$host_exeext ]; then
Index: gcc/configure.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/configure.in,v
retrieving revision 1.112
diff -c -p -d -r1.112 configure.in
*** configure.in	1998/06/10 12:58:40	1.112
--- configure.in	1998/06/17 02:02:54
*************** for machine in $build $host $target; do
*** 2113,2118 ****
--- 2113,2136 ----
  			use_collect2=yes
  		fi
  		;;
+ 	mips*el-*-linux*)		# Little endian MIPS w/ Linux & ELF
+ 		tm_file="mips/elfl.h mips/linux.h"
+ 		tmake_file="mips/t-linux"
+ 		xm_file="mips/xm-mips.h xm-linux.h"
+                 xmake_file=none
+ 		gnu_ld=yes gas=yes
+ 		extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+                 fixincludes=Makefile.in
+ 		;;
+ 	mips*-*-linux*)			# Big endian MIPS w/ Linux & ELF
+ 		tm_file="mips/elf.h mips/linux.h"
+ 		tmake_file="mips/t-linux"
+ 		xm_file="mips/xm-mips.h xm-linux.h"
+                 xmake_file=none
+ 		gnu_ld=yes gas=yes
+ 		extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+                 fixincludes=Makefile.in
+ 		;;
  	mips-*-gnu*)
  		;;
  	mipsel-*-ecoff*)
Index: gcc/gcc.1
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/gcc.1,v
retrieving revision 1.5
diff -c -p -d -r1.5 gcc.1
*** gcc.1	1998/04/03 16:35:03	1.5
--- gcc.1	1998/06/17 02:02:54
*************** in the following sections.
*** 419,425 ****
  \-mips3
  \-mint64
  \-mlong64
- \-mlonglong128
  \-mmips\-as
  \-mgas
  \-mrnames
--- 419,424 ----
Index: gcc/config/mips/elf.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/mips/elf.h,v
retrieving revision 1.6
diff -c -p -d -r1.6 elf.h
*** elf.h	1998/06/09 02:41:28	1.6
--- elf.h	1998/06/17 02:02:57
*************** do {									 \
*** 169,171 ****
--- 169,245 ----
    fputc ('\n', FILE);				\
   } while (0)
  
+ /* This says how to output assembler code to declare an uninitialized
+    external linkage data object.  Under ELF, we want the alignment of
+    data objects to depend on their types.  We do exactly that here.  */
+ 
+ #define COMMON_ASM_OP  ".comm"
+ 
+ #undef ASM_OUTPUT_ALIGNED_COMMON
+ #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
+ do {									\
+   fprintf ((FILE), "\t%s\t", COMMON_ASM_OP);				\
+   assemble_name ((FILE), (NAME));					\
+   fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);	\
+ } while (0)
+ 
+ /* Similar to above, this says how to output assembler code to declare
+    an uninitialized external linkage data object. */
+ 
+ #define LOCAL_ASM_OP   ".local"
+ 
+ #undef ASM_OUTPUT_ALIGNED_LOCAL
+ #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)		\
+ do {									\
+   fprintf ((FILE), "\t%s\t", LOCAL_ASM_OP);				\
+   assemble_name ((FILE), (NAME));					\
+   fprintf ((FILE), "\n");						\
+   ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);			\
+ } while (0)
+ 
+ /* Support const sections and the ctors and dtors sections for g++.  */
+ 
+ #define CTORS_SECTION_ASM_OP    ".section\t.ctors,\"aw\""
+ #define DTORS_SECTION_ASM_OP    ".section\t.dtors,\"aw\""
+ 
+ /* We must redefine a few bits we are overriding from mips.h.  */
+ 
+ #undef EXTRA_SECTIONS
+ #define EXTRA_SECTIONS in_sdata, in_rdata, in_ctors, in_dtors
+ 
+ #undef EXTRA_SECTION_FUNCTIONS
+ #define EXTRA_SECTION_FUNCTIONS                                         \
+   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP)
+ 
+ #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)				\
+ void FN ()								\
+ {									\
+   if (in_section != ENUM)						\
+     {									\
+       fprintf (asm_out_file, "%s\n", OP);				\
+       in_section = ENUM;						\
+     }									\
+ }
+ 
+ /* A C statement (sans semicolon) to output an element in the table of
+    global constructors.  */
+ #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)				\
+   do {									\
+     ctors_section ();							\
+     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word");	\
+     assemble_name (FILE, NAME);						\
+     fprintf (FILE, "\n");						\
+   } while (0)
+ 
+ /* A C statement (sans semicolon) to output an element in the table of
+    global destructors.  */
+ #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)				\
+   do {									\
+     dtors_section ();							\
+     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word");	\
+     assemble_name (FILE, NAME);						\
+     fprintf (FILE, "\n");						\
+   } while (0)
Index: gcc/config/mips/linux.h
===================================================================
RCS file: linux.h
diff -N linux.h
*** /dev/null	Mon Dec 31 20:00:00 1979
--- linux.h	Tue Jun 16 19:02:57 1998
***************
*** 0 ****
--- 1,122 ----
+ /* Definitions of target machine for GNU compiler,
+    for MIPS Linux-based GNU systems.
+    Copyright (C) 1998 Free Software Foundation, Inc.
+    Contributed by by Ralf Baechle (ralf@gnu.org)
+ 
+ This file is part of GNU CC.
+ 
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+ 
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING.  If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+ 
+ #undef TARGET_DEFAULT
+ #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
+ 
+ #undef MACHINE_TYPE
+ #if TARGET_ENDIAN_DEFAULT == 0
+ #define MACHINE_TYPE "(MIPSEL Linux/ELF)"
+ #else
+ #define MACHINE_TYPE "(MIPS Linux/ELF)"
+ #endif
+ 
+ #undef CPP_PREDEFINES
+ #if TARGET_ENDIAN_DEFAULT == 0
+ #define CPP_PREDEFINES "\
+ -D__ELF__ -D_MIPS_SIM=_MIPS_SIM_ABI32 \
+ -D__PIC__ -D__pic__ -Dunix -Dmips -DR3000 -DMIPSEL -Dlinux \
+ -Asystem(linux) -Asystem(posix) -Acpu(mips) -Amachine(mips)"
+ #else
+ #define CPP_PREDEFINES "\
+ -D__ELF__ -D_MIPS_SIM=_MIPS_SIM_ABI32 \
+ -D__PIC__ -D__pic__ -Dunix -Dmips -DR3000 -DMIPSEB -Dlinux \
+ -Asystem(linux) -Asystem(posix) -Acpu(mips) -Amachine(mips)"
+ #endif
+ 
+ #undef SUBTARGET_CPP_SPEC
+ #define SUBTARGET_CPP_SPEC "\
+ %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
+ %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
+ %{-D__HAVE_FPU__} \
+ %{posix:-D_POSIX_SOURCE}"
+ 
+ #undef SUBTARGET_ASM_SPEC
+ #define SUBTARGET_ASM_SPEC "\
+ %{!fno-PIC:%{!fno-pic:-KPIC}} %{fPIC:-KPIC} %{fpic:-KPIC} \
+ %{fno-PIC:-non_shared} %{fno-pic:-non_shared} \
+ %{membedded-pic}"
+ 
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
+ %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
+ %{bestGnum} %{shared} %{non_shared} \
+ %{call_shared} %{no_archive} %{exact_version} \
+   %{!shared: \
+       %{!static: \
+        %{rdynamic:-export-dynamic} \
+        %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
+        %{static:-static}}"
+ 
+ #undef STARTFILE_SPEC
+ #define STARTFILE_SPEC \
+ "%{!shared:%{pg:gcrt1.o%s}%{!pg:%{p:gcrt1.o%s}\
+    %{!p:%{profile:gcrt1.o%s}%{!profile:crt1.o%s}}}} \
+ crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+ 
+ #undef ENDFILE_SPEC
+ #define ENDFILE_SPEC \
+ "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+ 
+ 
+ /*
+  * We don't need no stinkin' coff.
+  */
+ #undef OBJECT_FORMAT_COFF
+ 
+ /*
+  * -G is incompatible with -KPIC which is the default, so only allow objects
+  * in the small data section if the user explicitly asks for it.
+  */
+ #undef MIPS_DEFAULT_GVALUE
+ #define MIPS_DEFAULT_GVALUE 0
+ 
+ /*
+  * Since gas and gld are standard on Linux, we don't need these
+  */
+ #undef MD_EXEC_PREFIX
+ #undef MD_STARTFILE_PREFIX
+ #undef ASM_FINAL_SPEC
+ 
+ /*
+  * No need for these since gcc is the only c/c++/objc compiler for Linux/MIPS
+  */
+ #undef PCC_BITFIELD_TYPE_MATTERS
+ #define PCC_BITFIELD_TYPE_MATTERS 1
+ #undef PCC_STATIC_STRUCT_RETURN
+ 
+ /* Don't assume anything about the header files. */
+ #define NO_IMPLICIT_EXTERN_C
+ 
+ #undef HAVE_ATEXIT
+ #define HAVE_ATEXIT
+ 
+ /* Generate calls to memcpy, etc., not bcopy, etc. */
+ #define TARGET_MEM_FUNCTIONS
+ 
+ /* Specify wchar_t types.  */
+ #undef  WCHAR_TYPE
+ #undef  WCHAR_TYPE_SIZE
+ #undef  MAX_WCHAR_TYPE_SIZE
+ 
+ #define WCHAR_TYPE      "long int"
+ #define WCHAR_TYPE_SIZE LONG_TYPE_SIZE
+ #define MAX_WCHAR_TYPE_SIZE     MAX_LONG_TYPE_SIZE
Index: gcc/config/mips/t-linux
===================================================================
RCS file: t-linux
diff -N t-linux
*** /dev/null	Mon Dec 31 20:00:00 1979
--- t-linux	Tue Jun 16 19:02:57 1998
***************
*** 0 ****
--- 1,20 ----
+ # Suppress building libgcc1.a, since the MIPS compiler port is complete
+ # and does not need anything from libgcc1.a.
+ LIBGCC1 = 
+ CROSS_LIBGCC1 = 
+ 
+ # Don't run fixproto
+ STMP_FIXPROTO =
+ 
+ # Don't install "assert.h" in gcc. We use the one in glibc.
+ INSTALL_ASSERT_H =
+ 
+ # This results in far to many libs ...  Unfortunately we need them at
+ # least for now.
+ MULTILIB_OPTIONS=EL/EB
+ MULTILIB_DIRNAMES=el eb
+ MULTILIB_MATCHES=
+ MULTILIB_EXCLUDE=
+ 
+ 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]