--- gcc-2.7.2.2/config/m68k/linux.h.~1~	Sat Sep 16 14:44:29 1995
+++ gcc-2.7.2.2/config/m68k/linux.h	Sun Jun  1 11:44:22 1997
@@ -31,6 +31,11 @@
 /* 68020 with 68881 */
 #define TARGET_DEFAULT 7
 
+/* for 68k machines this only needs to be TRUE for the 68000 */
+
+#undef STRICT_ALIGNMENT     
+#define STRICT_ALIGNMENT 0
+
 #undef SUBTARGET_SWITCHES
 #define SUBTARGET_SWITCHES	{"ieee-fp", 0},
 
@@ -142,6 +147,7 @@
 /* If ELF is the default format, we should not use /lib/elf. */
 
 #undef	LINK_SPEC
+#ifdef LIBC_VERSION_1
 #ifndef LINUX_DEFAULT_ELF
 #define LINK_SPEC "-m m68kelf %{shared} %{symbolic:-shared -Bsymbolic} \
   %{!shared:%{!symbolic: \
@@ -157,6 +163,21 @@
       %{!dynamic-linker*:-dynamic-linker /lib/ld-linux.so.1}} \
     %{static}}}"
 #endif
+#else /* not LIBC_VERSION_1 */
+#define LINK_SPEC "-m m68kelf %{shared} \
+  %{!shared: \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
+    %{static}}"
+#endif /* not LIBC_VERSION_1 */
+
+#ifndef LIBC_VERSION_1
+#undef LIB_SPEC
+#define LIB_SPEC \
+  "%{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
+	%{profile:-lc_p} %{!profile: -lc}}"
+#endif /* not LIBC_VERSION_1 */
 
 /* For compatibility with linux/a.out */
 
@@ -259,7 +280,8 @@
 
 #undef LIBCALL_VALUE
 #define LIBCALL_VALUE(MODE)						\
-  (((MODE) == SFmode || (MODE) == DFmode) && TARGET_68881		\
+  ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode)		\
+    && TARGET_68881)							\
    ? gen_rtx (REG, (MODE), 16)						\
    : gen_rtx (REG, (MODE), 0))
 
@@ -267,7 +289,10 @@
    an operand of a function call. */
 #undef LEGITIMATE_PIC_OPERAND_P
 #define LEGITIMATE_PIC_OPERAND_P(X) \
-  (! symbolic_operand (X, VOIDmode) \
+  ((! symbolic_operand (X, VOIDmode) \
+    && ! (GET_CODE (X) == CONST_DOUBLE && CONST_DOUBLE_MEM (X)	\
+	  && GET_CODE (CONST_DOUBLE_MEM (X)) == MEM		\
+	  && symbolic_operand (XEXP (CONST_DOUBLE_MEM (X), 0), VOIDmode))) \
    || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)))
 
 /* Turn off function cse if we are doing PIC. We always want function
@@ -283,3 +308,38 @@
    technique. */
 #undef PCC_STATIC_STRUCT_RETURN
 #define DEFAULT_PCC_STRUCT_RETURN 0
+
+/* Finalize the trampoline by flushing the insn cache.  */
+
+#undef FINALIZE_TRAMPOLINE
+#define FINALIZE_TRAMPOLINE(TRAMP)					\
+  emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__clear_cache"),	\
+		     0, VOIDmode, 2, TRAMP, Pmode,			\
+		     plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);
+
+/* Clear the instruction cache from `beg' to `end'.  This makes an
+   inline system call to SYS_cacheflush.  The arguments are as
+   follows:
+
+	cacheflush (addr, scope, cache, len)
+
+   addr	  - the start address for the flush
+   scope  - the scope of the flush (see the cpush insn)
+   cache  - which cache to flush (see the cpush insn)
+   len    - a factor relating to the number of flushes to perform:
+   	    len/16 lines, or len/4096 pages.  */
+
+#define CLEAR_INSN_CACHE(BEG, END)					\
+{									\
+  register unsigned long _beg __asm ("%d1") = (unsigned long) (BEG);	\
+  unsigned long _end = (unsigned long) (END);				\
+  register unsigned long _len __asm ("%d4") = (_end - _beg + 32);	\
+  __asm __volatile							\
+    ("move%.l %#123, %/d0\n\t"	/* system call nr */			\
+     "move%.l %#1, %/d2\n\t"	/* clear lines */			\
+     "move%.l %#3, %/d3\n\t"	/* insn+data caches */			\
+     "trap %#0"								\
+     : /* no outputs */							\
+     : "d" (_beg), "d" (_len)						\
+     : "%d0", "%d2", "%d3");						\
+}
--- gcc-2.7.2.2/config/m68k/m68k.h.~1~	Mon Nov 20 18:46:11 1995
+++ gcc-2.7.2.2/config/m68k/m68k.h	Sun Jun  1 11:42:35 1997
@@ -935,41 +935,36 @@
    of a trampoline, leaving space for the variable parts.  */
 
 /* On the 68k, the trampoline looks like this:
-     mov  @#.,a0
-     jsr  @#___trampoline
-     jsr  @#___trampoline
-     .long STATIC
-     .long FUNCTION
-The reason for having three jsr insns is so that an entire line
-of the instruction cache is filled in a predictable way
-that will always be the same.
+     movl #STATIC,a0
+     jmp  FUNCTION
 
-We always use the assembler label ___trampoline
-regardless of whether the system adds underscores.  */
+   WARNING: Targets that may run on 68040+ cpus must arrange for
+   the instruction cache to be flushed.  Previous incarnations of
+   the m68k trampoline code attempted to get around this by either
+   using an out-of-line transfer function or pc-relative data, but
+   the fact remains that the code to jump to the transfer function
+   or the code to load the pc-relative data needs to be flushed
+   just as much as the "variable" portion of the trampoline.  
+   Recognizing that a cache flush is going to be required anyway,
+   dispense with such notions and build a smaller trampoline.  */
 
-#define TRAMPOLINE_TEMPLATE(FILE)					\
-{									\
-  ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x207c));	\
-  ASM_OUTPUT_SHORT (FILE, const0_rtx);					\
-  ASM_OUTPUT_SHORT (FILE, const0_rtx);					\
-  ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x4eb9));	\
-  ASM_OUTPUT_INT (FILE, gen_rtx (SYMBOL_REF, SImode, "*___trampoline"));\
-  ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x4eb9));	\
-  ASM_OUTPUT_INT (FILE, gen_rtx (SYMBOL_REF, SImode, "*___trampoline"));\
-  ASM_OUTPUT_SHORT (FILE, const0_rtx);					\
-  ASM_OUTPUT_SHORT (FILE, const0_rtx);					\
-  ASM_OUTPUT_SHORT (FILE, const0_rtx);					\
-  ASM_OUTPUT_SHORT (FILE, const0_rtx);					\
-}
+/* Since more instructions are required to move a template into
+   place than to create it on the spot, don't use a template.  */
 
 /* Length in units of the trampoline for entering a nested function.  */
 
-#define TRAMPOLINE_SIZE 26
+#define TRAMPOLINE_SIZE 12
+
+/* Alignment required for a trampoline in bytes.  */
 
-/* Alignment required for a trampoline.  16 is used to find the
-   beginning of a line in the instruction cache.  */
+#define TRAMPOLINE_ALIGNMENT 2
 
-#define TRAMPOLINE_ALIGN 16
+/* Targets redefine this to invoke code to either flush the cache,
+   or enable stack execution (or both).  */
+
+#ifndef FINALIZE_TRAMPOLINE
+#define FINALIZE_TRAMPOLINE(TRAMP)
+#endif
 
 /* Emit RTL insns to initialize the variable parts of a trampoline.
    FNADDR is an RTX for the address of the function's pure code.
@@ -977,14 +972,20 @@
 
 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)			\
 {									\
-  emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 2)), TRAMP); \
-  emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 18)), CXT); \
-  emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 22)), FNADDR); \
+  emit_move_insn (gen_rtx (MEM, HImode, TRAMP), GEN_INT(0x207C));	\
+  emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 2)), CXT); \
+  emit_move_insn (gen_rtx (MEM, HImode, plus_constant (TRAMP, 6)),	\
+		  GEN_INT(0x4EF9));					\
+  emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 8)), FNADDR); \
+  FINALIZE_TRAMPOLINE(TRAMP);						\
 }
 
 /* This is the library routine that is used
    to transfer control from the trampoline
-   to the actual nested function.  */
+   to the actual nested function.
+   It is defined for backward compatibility,
+   for linking with object code that used the old
+   trampoline definition.  */
 
 /* A colon is used with no explicit operands
    to cause the template string to be scanned for %-constructs.  */
--- gcc-2.7.2.2/config/m68k/t-linux.~1~	Wed Jul 19 18:03:37 1995
+++ gcc-2.7.2.2/config/m68k/t-linux	Tue Apr 15 19:26:18 1997
@@ -3,3 +3,8 @@
 CROSS_LIBGCC1 =
 # On Linux we can print long double
 ENQUIRE_CFLAGS = -DNO_MEM -O0
+# Don't install "assert.h" in gcc. We use the one in glibc.
+INSTALL_ASSERT_H =
+
+# Compile libgcc2.a with pic.
+TARGET_LIBGCC2_CFLAGS = -fPIC
--- /dev/null	Fri Apr 29 15:43:48 1994
+++ gcc-2.7.2.2/config/m68k/t-linux-libc1	Thu Feb 13 18:10:33 1997
@@ -0,0 +1,10 @@
+# Don't make libgcc1.a
+LIBGCC1 =
+CROSS_LIBGCC1 =
+# On Linux we can print long double
+ENQUIRE_CFLAGS = -DNO_MEM -O0
+# Don't install "assert.h" in gcc. We use the one in glibc.
+INSTALL_ASSERT_H =
+# This file is used for GNU/Linux systems using
+# version 1 of the GNU C Library (Linux libc version 5).
+T_CFLAGS = -DLIBC_VERSION_1
--- gcc-2.7.2.2/configure.~1~	Tue Feb 11 19:50:29 1997
+++ gcc-2.7.2.2/configure	Thu Feb 13 17:28:52 1997
@@ -1544,6 +1544,17 @@
 		extra_headers=math-68881.h
 		gnu_ld=yes
 		;;
+	m68k-*-linux*libc1)		# Motorola m68k's running GNU/Linux
+		xm_file=m68k/xm-linux.h	# with ELF format, using GNU libc v1.
+		xmake_file=x-linux
+		tm_file=m68k/linux.h
+		tmake_file=m68k/t-linux-libc1
+		fixincludes=Makefile.in # The headers are ok already.
+		extra_headers=math-68881.h
+		gnu_ld=yes
+		# GNU libc v1 supplies these.
+		#extra_parts="crtbegin.o crtend.o"
+		;;
 	m68k-*-linux*)			# Motorola m68k's running GNU/Linux
 		xm_file=m68k/xm-linux.h	# with ELF format
 		xmake_file=x-linux
@@ -1552,7 +1563,9 @@
 		fixincludes=Makefile.in # The headers are ok already.
 		extra_headers=math-68881.h
 		gnu_ld=yes
-		extra_parts="crtbegin.o crtend.o"
+		# GNU libc version 2 does not supply these;
+		# we want them from GCC.
+		extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
 		;;
 	m88k-dg-dgux*)
 		case $machine in
--- gcc-2.7.2.2/crtstuff.c.~1~	Mon Jun 19 21:06:09 1995
+++ gcc-2.7.2.2/crtstuff.c	Sun Oct 27 03:25:40 1996
@@ -247,12 +247,12 @@
 #endif
   asm (TEXT_SECTION_ASM_OP);
 
-/* This is a kludge. The Linux dynamic linker needs  ___brk_addr, __environ
-   and atexit (). We have to make sure they are in the .dynsym section. We
-   accomplish it by making a dummy call here. This
+/* This is a kludge. The i386 Linux dynamic linker needs  ___brk_addr,
+   __environ and atexit (). We have to make sure they are in the .dynsym
+   section. We accomplish it by making a dummy call here. This
    code is never reached. */
  
-#if defined(__linux__) && defined(__PIC__)
+#if defined(__linux__) && defined(__PIC__) && defined(__i386__)
   {
     extern void *___brk_addr;
     extern char **__environ;
--- gcc-2.7.2.2/function.c.~1~	Fri Dec  1 17:26:57 1995
+++ gcc-2.7.2.2/function.c	Sun Jun  1 11:40:22 1997
@@ -5229,7 +5229,9 @@
   register int i;
   tree link;
 
+#ifdef TRAMPOLINE_TEMPLATE
   static rtx initial_trampoline;
+#endif
 
   if (output_bytecode)
     {
@@ -5262,8 +5264,10 @@
       tree function = TREE_PURPOSE (link);
       rtx context = lookup_static_chain (function);
       rtx tramp = RTL_EXPR_RTL (TREE_VALUE (link));
+      rtx blktramp;
       rtx seq;
 
+#ifdef TRAMPOLINE_TEMPLATE
       /* First make sure this compilation has a template for
 	 initializing trampolines.  */
       if (initial_trampoline == 0)
@@ -5273,15 +5277,18 @@
 	    = gen_rtx (MEM, BLKmode, assemble_trampoline_template ());
 	  resume_temporary_allocation ();
 	}
+#endif
 
       /* Generate insns to initialize the trampoline.  */
       start_sequence ();
-      tramp = change_address (initial_trampoline, BLKmode,
-			      round_trampoline_addr (XEXP (tramp, 0)));
-      emit_block_move (tramp, initial_trampoline, GEN_INT (TRAMPOLINE_SIZE),
+      tramp = round_trampoline_addr (XEXP (tramp, 0));
+#ifdef TRAMPOLINE_TEMPLATE
+      blktramp = change_address (initial_trampoline, BLKmode, tramp);
+      emit_block_move (blktramp, initial_trampoline,
+		       GEN_INT (TRAMPOLINE_SIZE),
 		       FUNCTION_BOUNDARY / BITS_PER_UNIT);
-      INITIALIZE_TRAMPOLINE (XEXP (tramp, 0),
-			     XEXP (DECL_RTL (function), 0), context);
+#endif
+      INITIALIZE_TRAMPOLINE (tramp, XEXP (DECL_RTL (function), 0), context);
       seq = get_insns ();
       end_sequence ();
 
--- gcc-2.7.2.2/varasm.c.~1~	Mon Nov 20 18:52:46 1995
+++ gcc-2.7.2.2/varasm.c	Sun Jun  1 11:47:50 1997
@@ -1640,6 +1640,7 @@
    This is done at most once per compilation.
    Returns an RTX for the address of the template.  */
 
+#ifdef TRAMPOLINE_TEMPLATE
 rtx
 assemble_trampoline_template ()
 {
@@ -1673,6 +1674,7 @@
     = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
   return gen_rtx (SYMBOL_REF, Pmode, name);
 }
+#endif
 
 /* Assemble the integer constant X into an object of SIZE bytes.
    X must be either a CONST_INT or CONST_DOUBLE.
