[patch] Merge m68k libgloss bits to mainline.

Kazu Hirata kazu@codesourcery.com
Mon Aug 21 18:09:00 GMT 2006


Hi,

Attached is a patch to merge m68k libgloss bits to mainline.
Specifically, this patch adds semi-hosting support to some ColdFire
targets.

Tested by running a "Hello, world" program and verifying "Hello,
world" on m68k-elf-gdb.  OK to apply?

Kazu Hirata

2006-08-21  Kazu Hirata  <nathan@codesourcery.com>

	Merge from newlib-csl-20060320-branch:
	2006-07-24  Nathan Sidwell  <nathan@codesourcery.com>

	Bug 844
	libgloss/
	* m68k/cf.sc: Set entry point to _start.
	* m68k/crt0.X (_start): New name for entrypoint
	(start): Weak alias for start.

	2006-06-09  Nathan Sidwell  <nathan@codesourcery.com>

	libgloss/
	* m68k/bdm-system.c (_system): Support system(NULL).

	2006-06-08  Nathan Sidwell  <nathan@codesourcery.com>

	* libgloss/m68k/bdm-system.c (_system): Properly encode non
	failure exit code.

	2006-06-05  Nathan Sidwell  <nathan@codesourcery.com>

	* libgloss/m68k/Makefile.in (BDM_SYSOBJS): Remove bdm-inbyte.o.
	Add bdm-time.o.
	* libgloss/m68k/bdm-close.c: Add copyright notice.
	* libgloss/m68k/bdm-fstat.c: Add copyright notice.
	* libgloss/m68k/bdm-gettimeofday.c: Add copyright notice.
	* libgloss/m68k/bdm-inbyte.c: Remove.
	* libgloss/m68k/bdm-isatty.c: Add copyright notice.
	* libgloss/m68k/bdm-lseek.c: Add copyright notice. Fix &/|
	thinko.
	* libgloss/m68k/bdm-open.c: Add copyright notice.
	* libgloss/m68k/bdm-read.c: Add copyright notice.
	* libgloss/m68k/bdm-rename.c: Add copyright notice.
	* libgloss/m68k/bdm-stat.c: Add copyright notice.
	* libgloss/m68k/bdm-system.c: Add copyright notice.
	* libgloss/m68k/bdm-time.c: New.
	* libgloss/m68k/bdm-unlink.c: Add copyright notice.
	* libgloss/m68k/bdm-write.c: Add copyright notice.

	2006-05-25  Nathan Sidwell  <nathan@codesourcery.com>

	* libgloss/m68k/Makefile.in (m52235-dbug.ld, m52235-bdm.ld): New
	scripts.

	2006-05-24  Nathan Sidwell  <nathan@codesourcery.com>

	* libgloss/m68k/Makefile.in (BDM_SYSOBJS): Remove bdm-outbyte.o
	* libgloss/m68k/bdm-outbyte.c: Delete.
	* libgloss/m68k/bdm-semihost.h (BDM_OUTBYTE): Mark as obsolete.

	2006-05-22  Sandra Loosemore <sandra@codesourcery.com>

	* libgloss/m68k/bdm-semihost.h: Add new constants for additional
	semihosting functions.  Add new BDM_TRAP macro to encapsulate
	inline asm.
	* libgloss/m68k/bdm-exit.c (_exit): Use new BDM_TRAP macro.
	* libgloss/m68k/bdm-outbyte.c (outbyte): Ditto.
	* libgloss/m68k/bdm-isrs.c, libgloss/m68k/bdm-isv.c: Former BDM_TRAP
	now called BDM_TRAPNUM.
	* libgloss/m68k/bdm-gdb.h, libgloss/m68k/bdm-gdb.c: New files
	containing declarations and conversion functions for GDB's fileio
	protocol.
	* libgloss/m68k/bdm-close.c: New file to define corresponding function.
	* libgloss/m68k/bdm-fstat.c: Ditto.
	* libgloss/m68k/bdm-gettimeofday.c: Ditto.
	* libgloss/m68k/bdm-isatty.c: Ditto.
	* libgloss/m68k/bdm-lseek.c: Ditto.
	* libgloss/m68k/bdm-open.c: Ditto.
	* libgloss/m68k/bdm-read.c: Ditto.
	* libgloss/m68k/bdm-rename.c: Ditto.
	* libgloss/m68k/bdm-stat.c: Ditto.
	* libgloss/m68k/bdm-system.c: Ditto.
	* libgloss/m68k/bdm-unlink.c: Ditto.
	* libgloss/m68k/bdm-write.c Ditto.
	* libgloss/m68k/Makefile.in: Add dependencies for new files.
	* newlib/configure.host: Tell it we have _rename and _system when
	building m68k-unknown-elf.

	2006-03-29  Nathan Sidwell  <nathan@codesourcery.com>

	* libgloss/m68k/bdm-isv.c (software_init_hook): Fix trap numbering.

	* libgloss/m68k/Makefile.in (CF_SCRIPTS): Add m5329 board.
	Reorder.
	(*-dbug.ld, *-bdm.ld): Add appropriate IO definition.
	(m5329evb-dbug.ld, m5329evb-bdm.ld): New.
	* cf.sc (GROUP): Revert previous change.  Add IO library.

	* libgloss/m68k/Makefile.in (BDM_BSP, BDM_OBJS, BDM_ISRS): New.
	(CF_SCRIPTS): Rename dbug scripts.  Add bdm scripts. Add m5485
	scripts.
	(all): Add new targets.
	(BDM_BSP): New target.
	(bdm-isv.o, bdm-exit.o, bdm-outbyte.o, bdm-semihost.o): New
	targets.
	(BDM_ISRS): New targets.
	(m5208evb.ld, m5213evb.ld, m5235evb.ld, m5272c3.ld, m5282evb.ld):
	Rename and adjust.
	(m5485evb-dbug): New.
	(m5208evb-bdm.ld, m5213evb-bdm.ld, m5235evb-bdm.ld,
	m5272c3-bdm.ld, m5282evb-bdm.ld, m5485evb-bdm.ld): New.
	(install): Add BDM_BSP.
	* libgloss/m68k/bdm-exit.c: New
	* libgloss/m68k/bdm-inbyte.c: New
	* libgloss/m68k/bdm-outbyte.c: New
	* libgloss/m68k/bdm-semihost.c: New
	* libgloss/m68k/bdm-semihost.h: New
	* libgloss/m68k/bdm-isrs.c: New.
	* libgloss/m68k/bdm-isv.c: New.
	* dbug-cf.sc: Renamed to ...
	* cf.sc: ... here.  Add bdm flexibility. Remove GROUP

Index: libgloss/m68k/Makefile.in
===================================================================
RCS file: /cvs/src/src/libgloss/m68k/Makefile.in,v
retrieving revision 1.5
retrieving revision 1.5.2.6
diff -u -r1.5 -r1.5.2.6
--- libgloss/m68k/Makefile.in	22 Feb 2006 18:02:54 -0000	1.5
+++ libgloss/m68k/Makefile.in	5 Jun 2006 14:22:26 -0000	1.5.2.6
@@ -123,7 +123,35 @@
 DBUG_BSP=	libdbug.a
 DBUG_OBJS=	dbug-exit.o dbug-inbyte.o dbug-outbyte.o
 
-CF_SCRIPTS=   m5208evb.ld m5213evb.ld m5235evb.ld m5272c3.ld m5282evb.ld
+#
+# here's all the BDM semihosting stuff
+#
+BDM_BSP=	libbdm.a
+BDM_OBJS=	bdm-isv.o bdm-semihost.o $(BDM_SYSOBJS) \
+		$(patsubst %,bdm-%.o,${BDM_ISRS})
+BDM_OTHER_OBJS=	getpid.o kill.o sbrk.o print.o putnum.o
+BDM_SYSOBJS= 	bdm-close.o bdm-exit.o bdm-fstat.o bdm-gdb.o \
+		bdm-gettimeofday.o bdm-isatty.o bdm-lseek.o \
+		bdm-open.o bdm-read.o bdm-rename.o \
+		bdm-stat.o bdm-system.o bdm-time.o bdm-unlink.o bdm-write.o
+BDM_ISRS=	other_interrupt reset access_error address_error \
+	illegal_instruction divide_by_zero privilege_violation \
+	trace unimplemented_line_a_opcode unimplemented_line_f_opcode \
+	non_pc_breakpoint_debug_interrupt pc_breakpoint_debug_interrupt \
+	format_error spurious_interrupt trap0 trap1 trap2 trap3 trap4 \
+	trap5 trap6 trap7 trap8 trap9 trap10 trap11 trap12 trap13 trap14 \
+	trap15 fp_branch_unordered fp_inexact_result fp_divide_by_zero \
+	fp_underflow fp_operand_error fp_overflow fp_input_not_a_number \
+	fp_input_denormalized_number unsupported_instruction
+
+CF_SCRIPTS=   m5208evb-dbug.ld 	m5208evb-bdm.ld \
+	m5213evb-dbug.ld m5213evb-bdm.ld \
+	m52235evb-dbug.ld m52235evb-bdm.ld \
+	m5235evb-dbug.ld m5235evb-bdm.ld \
+	m5272c3-dbug.ld m5272c3-bdm.ld \
+	m5282evb-dbug.ld m5282evb-bdm.ld \
+	m5329evb-dbug.ld m5329evb-bdm.ld \
+	m5485evb-dbug.ld m5485evb-bdm.ld
 
 # Host specific makefile fragment comes in here.
 @host_makefile_frag@
@@ -132,7 +160,7 @@
 # build a test program for each target board. Just trying to get
 # it to link is a good test, so we ignore all the errors for now.
 #
-all: ${SIM_CRT0} ${SIM_BSP} ${CRT0} ${BCC_BSP} ${IDP_BSP} ${IDPGDB_BSP} ${MVME135_BSP} ${MVME162_BSP} ${DBUG_BSP} ${CF_SCRIPTS}
+all: ${SIM_CRT0} ${SIM_BSP} ${CRT0} ${BCC_BSP} ${IDP_BSP} ${IDPGDB_BSP} ${MVME135_BSP} ${MVME162_BSP} ${DBUG_BSP} ${BDM_BSP} ${CF_SCRIPTS}
 
 #
 # here's where we build the board support packages for each target
@@ -157,6 +185,10 @@
 	${AR} ${ARFLAGS} $@ $(OBJS) ${DBUG_OBJS}
 	${RANLIB} $@
 
+${BDM_BSP}: $(BDM_OTHER_OBJS) ${BDM_OBJS}
+	${AR} ${ARFLAGS} $@ $(BDM_OTHER_OBJS) ${BDM_OBJS}
+	${RANLIB} $@
+
 ${MVME135_BSP}: $(OBJS) ${MVME135_OBJS}
 	${AR} ${ARFLAGS} $@ $(OBJS) ${MVME135_OBJS}
 	${RANLIB} $@
@@ -165,20 +197,64 @@
 	${AR} ${ARFLAGS} $@ $(OBJS) ${MVME162_OBJS}
 	${RANLIB} $@
 
-m5208evb.ld: dbug-cf.sc Makefile
-	RAMSTART=1024M RAMSIZE=16M RAMDBUG=128K ${SHELL} $< > $@
 
-m5213evb.ld: dbug-cf.sc Makefile
-	RAMSTART=512M RAMSIZE=32K RAMDBUG=8K ${SHELL} $< > $@
+$(BDM_SYSOBJS): %.o: %.c bdm-semihost.h bdm-gdb.h
+	$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@ 
+bdm-isv.o : bdm-isv.c bdm-semihost.h
+bdm-semihost.o : bdm-semihost.c
+	$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@ -fomit-frame-pointer
+
+$(patsubst %,bdm-%.o,${BDM_ISRS}) : bdm-isrs.c
+	$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@ \
+	  -DL_$(patsubst bdm-%.o,%,$@) -fno-omit-frame-pointer
+
+m5208evb-dbug.ld: cf.sc Makefile
+	IO=dbug RAMSTART=1024M RAMSIZE=16M RAMDBUG=128K ${SHELL} $< > $@
+
+m5208evb-bdm.ld: cf.sc Makefile
+	IO=bdm ISV=1 RAMSTART=1024M RAMSIZE=16M ${SHELL} $< > $@
+
+m5213evb-dbug.ld: cf.sc Makefile
+	IO=dbug RAMSTART=512M RAMSIZE=32K RAMDBUG=8K ${SHELL} $< > $@
+
+m5213evb-bdm.ld: cf.sc Makefile
+	IO=bdm ISV=1 RAMSTART=512M RAMSIZE=32K ${SHELL} $< > $@
+
+m52235evb-dbug.ld: cf.sc Makefile
+	IO=dbug RAMSTART=512M RAMSIZE=32K RAMDBUG=8K ${SHELL} $< > $@
 
-m5235evb.ld: dbug-cf.sc Makefile
-	RAMSTART=0M RAMSIZE=16M RAMDBUG=64K ${SHELL} $< > $@
+m52235evb-bdm.ld: cf.sc Makefile
+	IO=bdm ISV=1 RAMSTART=512M RAMSIZE=32K ${SHELL} $< > $@
 
-m5272c3.ld: dbug-cf.sc Makefile
-	RAMSTART=0M RAMSIZE=4M RAMDBUG=128K ${SHELL} $< > $@
+m5235evb-dbug.ld: cf.sc Makefile
+	IO=dbug RAMSTART=0M RAMSIZE=16M RAMDBUG=64K ${SHELL} $< > $@
 
-m5282evb.ld: dbug-cf.sc Makefile
-	RAMSTART=0M RAMSIZE=16M RAMDBUG=64K ${SHELL} $< > $@
+m5235evb-bdm.ld: cf.sc Makefile
+	IO=bdm ISV=1 RAMSTART=0M RAMSIZE=16M ${SHELL} $< > $@
+
+m5272c3-dbug.ld: cf.sc Makefile
+	IO=dbug RAMSTART=0M RAMSIZE=4M RAMDBUG=128K ${SHELL} $< > $@
+
+m5272c3-bdm.ld: cf.sc Makefile
+	IO=bdm ISV=1 RAMSTART=0M RAMSIZE=4M ${SHELL} $< > $@
+
+m5282evb-dbug.ld: cf.sc Makefile
+	IO=dbug RAMSTART=0M RAMSIZE=16M RAMDBUG=64K ${SHELL} $< > $@
+
+m5282evb-bdm.ld: cf.sc Makefile
+	IO=bdm ISV=1 RAMSTART=0M RAMSIZE=16M ${SHELL} $< > $@
+
+m5329evb-dbug.ld: cf.sc Makefile
+	IO=dbug RAMSTART=1024M RAMSIZE=32M RAMDBUG=128K ${SHELL} $< > $@
+
+m5329evb-bdm.ld: cf.sc Makefile
+	IO=bdm ISV=1 RAMSTART=1024M RAMSIZE=32M RAMDBUG=128K ${SHELL} $< > $@
+
+m5485evb-dbug.ld: cf.sc Makefile
+	IO=dbug RAMSTART=0M RAMSIZE=64M RAMDBUG=128K ${SHELL} $< > $@
+
+m5485evb-bdm.ld: cf.sc Makefile
+	IO=bdm ISV=1 RAMSTART=0M RAMSIZE=64M ${SHELL} $< > $@
 
 leds.o: ${srcdir}/leds.c
 	$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
@@ -298,6 +374,9 @@
 	$(INSTALL_DATA) ${srcdir}/mvme162.ld $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/mvme162.ld
 	# install DBUG stuff
 	$(INSTALL_PROGRAM) $(DBUG_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(DBUG_BSP)
+	# install BDM stuff
+	$(INSTALL_PROGRAM) $(BDM_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(BDM_BSP)
+
 	$(INSTALL_DATA) ${srcdir}/sbc5204.ld $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/sbc5204.ld
 	$(INSTALL_DATA) ${srcdir}/sbc5206.ld $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/sbc5206.ld
 	for script in $(CF_SCRIPTS) ; \
Index: libgloss/m68k/bdm-close.c
===================================================================
RCS file: libgloss/m68k/bdm-close.c
diff -N libgloss/m68k/bdm-close.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-close.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,38 @@
+/*
+ * bdm-close.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * close -- close a file descriptor.
+ * input parameters:
+ *   0 : file descriptor
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+int close (int fd)
+{
+  gdb_parambuf_t parameters;
+  parameters[0] = (uint32_t) fd;
+  BDM_TRAP (BDM_CLOSE, (uint32_t)parameters);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/bdm-exit.c
===================================================================
RCS file: libgloss/m68k/bdm-exit.c
diff -N libgloss/m68k/bdm-exit.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-exit.c	22 May 2006 22:26:09 -0000	1.1.2.3
@@ -0,0 +1,30 @@
+/*
+ * bdm-exit.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+
+/* 
+ * _exit -- Exit from the application.  
+ */
+
+void __attribute__ ((noreturn)) _exit (int code)
+{
+  while (1)
+    {
+      BDM_TRAP (BDM_EXIT, code);
+    }
+}
Index: libgloss/m68k/bdm-fstat.c
===================================================================
RCS file: libgloss/m68k/bdm-fstat.c
diff -N libgloss/m68k/bdm-fstat.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-fstat.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,44 @@
+/*
+ * bdm-fstat.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * fstat -- get file information
+ * input parameters:
+ *   0 : file descriptor
+ *   1 : stat buf ptr
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+int fstat (int fd, struct stat *buf)
+{
+  gdb_parambuf_t parameters;
+  struct gdb_stat gbuf;
+  parameters[0] = (uint32_t) fd;
+  parameters[1] = (uint32_t) &gbuf;
+  BDM_TRAP (BDM_FSTAT, (uint32_t)parameters);
+  convert_from_gdb_stat (&gbuf, buf);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/bdm-gdb.c
===================================================================
RCS file: libgloss/m68k/bdm-gdb.c
diff -N libgloss/m68k/bdm-gdb.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-gdb.c	22 May 2006 22:29:17 -0000	1.1.2.1
@@ -0,0 +1,140 @@
+/*
+ * bdm support for GDB's remote fileio protocol
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-gdb.h"
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+gdb_mode_t
+convert_to_gdb_mode_t (mode_t m)
+{
+  gdb_mode_t result = 0;
+  if (m & S_IFREG)
+    result |= GDB_S_IFREG;
+  if (m & S_IFDIR)
+    result |= GDB_S_IFDIR;
+  if (m & S_IRUSR)
+    result |= GDB_S_IRUSR;
+  if (m & S_IWUSR)
+    result |= GDB_S_IWUSR;
+  if (m & S_IXUSR)
+    result |= GDB_S_IXUSR;
+  if (m & S_IRGRP)
+    result |= GDB_S_IRGRP;
+  if (m & S_IWGRP)
+    result |= GDB_S_IWGRP;
+  if (m & S_IXGRP)
+    result |= GDB_S_IXGRP;
+  if (m & S_IROTH)
+    result |= GDB_S_IROTH;
+  if (m & S_IWOTH)
+    result |= GDB_S_IWOTH;
+  if (m & S_IXOTH)
+    result |= GDB_S_IXOTH;
+  return result;
+}
+
+int32_t
+convert_to_gdb_open_flags (int f)
+{
+  int32_t result = 0;
+  if (f & O_RDONLY)
+    result |= GDB_O_RDONLY;
+  if (f & O_WRONLY)
+    result |= GDB_O_WRONLY;
+  if (f & O_RDWR)
+    result |= GDB_O_RDWR;
+  if (f & O_APPEND)
+    result |= GDB_O_APPEND;
+  if (f & O_CREAT)
+    result |= GDB_O_CREAT;
+  if (f & O_TRUNC)
+    result |= GDB_O_TRUNC;
+  if (f & O_EXCL)
+    result |= GDB_O_EXCL;
+  return result;
+}
+
+int32_t
+convert_to_gdb_lseek_flags (int f)
+{
+  if (f == SEEK_CUR)
+    return GDB_SEEK_CUR;
+  else if (f == SEEK_END)
+    return GDB_SEEK_END;
+  else
+    return GDB_SEEK_SET;
+}
+
+void
+convert_from_gdb_stat (const struct gdb_stat *gs,
+		       struct stat *s)
+{
+  s->st_dev = gs->st_dev;
+  s->st_ino = gs->st_ino;
+  s->st_mode = gs->st_mode;
+  s->st_nlink = gs->st_nlink;
+  s->st_uid = gs->st_uid;
+  s->st_gid = gs->st_gid;
+  s->st_rdev = gs->st_rdev;
+  s->st_size = gs->st_size;
+  s->st_blksize = gs->st_blksize;
+  s->st_blocks = gs->st_blocks;
+  s->st_atime = gs->st_atime;
+  s->st_mtime = gs->st_mtime;
+  s->st_ctime = gs->st_ctime;
+}
+
+void
+convert_from_gdb_timeval (const struct gdb_timeval *gt,
+			  struct timeval *t)
+{
+  t->tv_sec = gt->tv_sec;
+  t->tv_usec = gt->tv_usec;
+}
+
+int
+convert_from_gdb_errno (int32_t err)
+{
+  switch (err)
+    {
+    case 0: 		return 0;
+    case GDB_EPERM: 	return EPERM;
+    case GDB_ENOENT: 	return ENOENT;
+    case GDB_EINTR: 	return EINTR;
+    case GDB_EBADF: 	return EBADF;
+    case GDB_EACCES: 	return EACCES;
+    case GDB_EFAULT: 	return EFAULT;
+    case GDB_EBUSY: 	return EBUSY;
+    case GDB_EEXIST: 	return EEXIST;
+    case GDB_ENODEV: 	return ENODEV;
+    case GDB_ENOTDIR: 	return ENOTDIR;
+    case GDB_EISDIR: 	return EISDIR;
+    case GDB_EINVAL: 	return EINVAL;
+    case GDB_ENFILE: 	return ENFILE;
+    case GDB_EMFILE: 	return EMFILE;
+    case GDB_EFBIG: 	return EFBIG;
+    case GDB_ENOSPC: 	return ENOSPC;
+    case GDB_ESPIPE: 	return ESPIPE;
+    case GDB_EROFS: 	return EROFS;
+    case GDB_ENAMETOOLONG: 	return ENAMETOOLONG;
+    case GDB_EUNKNOWN:
+    default:
+      return EIO;
+    }
+}
+
Index: libgloss/m68k/bdm-gdb.h
===================================================================
RCS file: libgloss/m68k/bdm-gdb.h
diff -N libgloss/m68k/bdm-gdb.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-gdb.h	22 May 2006 22:29:17 -0000	1.1.2.1
@@ -0,0 +1,128 @@
+/*
+ * bdm support for GDB's remote fileio protocol
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+
+/* Protocol specific representation of datatypes, as specified in D.9.11
+ * of the GDB manual.
+ * Note that since the m68k is big-endian, we can use native
+ * representations of integer datatypes in structured datatypes. */
+
+typedef uint32_t gdb_mode_t;
+typedef uint32_t gdb_time_t;
+
+struct gdb_stat {
+  uint32_t    st_dev;     /* device */
+  uint32_t    st_ino;     /* inode */
+  gdb_mode_t  st_mode;    /* protection */
+  uint32_t    st_nlink;   /* number of hard links */
+  uint32_t    st_uid;     /* user ID of owner */
+  uint32_t    st_gid;     /* group ID of owner */
+  uint32_t    st_rdev;    /* device type (if inode device) */
+  uint64_t    st_size;    /* total size, in bytes */
+  uint64_t    st_blksize; /* blocksize for filesystem I/O */
+  uint64_t    st_blocks;  /* number of blocks allocated */
+  gdb_time_t  st_atime;   /* time of last access */
+  gdb_time_t  st_mtime;   /* time of last modification */
+  gdb_time_t  st_ctime;   /* time of last change */
+};
+
+struct gdb_timeval {
+  gdb_time_t tv_sec;  /* second */
+  uint64_t tv_usec;   /* microsecond */
+};
+
+
+/* Parameters are passed between the library and the debugging stub
+ * in a fixed-size buffer.
+ */
+
+typedef uint32_t gdb_parambuf_t[4];
+
+
+/* open flags */
+
+#define GDB_O_RDONLY   0x0
+#define GDB_O_WRONLY   0x1
+#define GDB_O_RDWR     0x2
+#define GDB_O_APPEND   0x8
+#define GDB_O_CREAT  0x200
+#define GDB_O_TRUNC  0x400
+#define GDB_O_EXCL   0x800
+
+/* mode_t values */
+
+#define GDB_S_IFREG 0100000
+#define GDB_S_IFDIR  040000
+#define GDB_S_IRUSR    0400
+#define GDB_S_IWUSR    0200
+#define GDB_S_IXUSR    0100
+#define GDB_S_IRGRP     040
+#define GDB_S_IWGRP     020
+#define GDB_S_IXGRP     010
+#define GDB_S_IROTH      04
+#define GDB_S_IWOTH      02
+#define GDB_S_IXOTH      01
+
+/* errno values */
+
+#define GDB_EPERM         1
+#define GDB_ENOENT        2
+#define GDB_EINTR         4
+#define GDB_EBADF         9
+#define GDB_EACCES       13
+#define GDB_EFAULT       14
+#define GDB_EBUSY        16
+#define GDB_EEXIST       17
+#define GDB_ENODEV       19
+#define GDB_ENOTDIR      20
+#define GDB_EISDIR       21
+#define GDB_EINVAL       22
+#define GDB_ENFILE       23
+#define GDB_EMFILE       24
+#define GDB_EFBIG        27
+#define GDB_ENOSPC       28
+#define GDB_ESPIPE       29
+#define GDB_EROFS        30
+#define GDB_ENAMETOOLONG 91
+#define GDB_EUNKNOWN     9999
+
+/* lseek flags */
+
+#define GDB_SEEK_SET 0
+#define GDB_SEEK_CUR 1
+#define GDB_SEEK_END 2
+
+
+/* conversion functions */
+
+extern gdb_mode_t convert_to_gdb_mode_t (mode_t m);
+extern int32_t convert_to_gdb_open_flags (int f);
+extern int32_t convert_to_gdb_lseek_flags (int f);
+
+extern void convert_from_gdb_stat (const struct gdb_stat *gs,
+				   struct stat *s);
+extern void convert_from_gdb_timeval (const struct gdb_timeval *gt,
+				      struct timeval *t);
+extern int convert_from_gdb_errno (int32_t err);
+
+
+
+
+
Index: libgloss/m68k/bdm-gettimeofday.c
===================================================================
RCS file: libgloss/m68k/bdm-gettimeofday.c
diff -N libgloss/m68k/bdm-gettimeofday.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-gettimeofday.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,47 @@
+/*
+ * bdm-gettimeofday.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <sys/time.h>
+#include <errno.h>
+
+/*
+ * gettimeofday -- get the current time
+ * input parameters:
+ *   0 : timeval ptr
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+int gettimeofday (struct timeval *tv, struct timezone *tz)
+{
+  gdb_parambuf_t parameters;
+  struct gdb_timeval gtv;
+  if (!tv)
+    return 0;
+  if (tz)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+  parameters[0] = (uint32_t) >v;
+  BDM_TRAP (BDM_GETTIMEOFDAY, (uint32_t)parameters);
+  convert_from_gdb_timeval (&gtv, tv);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/bdm-isatty.c
===================================================================
RCS file: libgloss/m68k/bdm-isatty.c
diff -N libgloss/m68k/bdm-isatty.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-isatty.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,38 @@
+/*
+ * bdm-isatty.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * isatty -- check if fd is a terminal
+ * input parameters:
+ *   0 : file descriptor
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+int isatty (int fd)
+{
+  gdb_parambuf_t parameters;
+  parameters[0] = (uint32_t) fd;
+  BDM_TRAP (BDM_ISATTY, (uint32_t)parameters);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/bdm-isrs.c
===================================================================
RCS file: libgloss/m68k/bdm-isrs.c
diff -N libgloss/m68k/bdm-isrs.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-isrs.c	22 May 2006 22:26:09 -0000	1.1.2.3
@@ -0,0 +1,192 @@
+/*
+ * bdm-isv.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+/* This file contains default interrupt handlers code for the
+   interrupt vector.  All but one of the interrupts are user
+   replaceable.
+
+   These interrupt handlers are entered whenever the associated
+   interrupt occurs.  All they do is stop the debugger to give the user
+   the opportunity to determine where the problem was.
+  
+   User trap BDM_TRAPNUM (15) is used for semi hosting support.
+   If you replace this one, semihosting will cease to function. */
+
+
+/* Each ISR is a loop containing a halt instruction  */
+#define ISR_DEFINE(NAME) 					\
+void __attribute__((interrupt_handler)) NAME (void)		\
+{								\
+  while (1)							\
+    __asm__ __volatile__ ("halt" ::: "memory");			\
+}								\
+struct eat_trailing_semicolon
+
+#if defined (L_other_interrupt)
+ISR_DEFINE (__other_interrupt);
+#endif
+
+#if defined (L_reset)
+ISR_DEFINE (__reset);
+#endif
+
+#if defined (L_access_error)
+ISR_DEFINE (__access_error);
+#endif
+
+#if defined (L_address_error)
+ISR_DEFINE (__address_error);
+#endif
+
+#if defined (L_illegal_instruction)
+ISR_DEFINE (__illegal_instruction);
+#endif
+
+#if defined (L_divide_by_zero)
+ISR_DEFINE (__divide_by_zero);
+#endif
+
+#if defined (L_privilege_violation)
+ISR_DEFINE (__privilege_violation);
+#endif
+
+#if defined (L_trace)
+ISR_DEFINE (__trace);
+#endif
+
+#if defined (L_unimplemented_line_a_opcode)
+ISR_DEFINE (__unimplemented_line_a_opcode);
+#endif
+
+#if defined (L_unimplemented_line_f_opcode)
+ISR_DEFINE (__unimplemented_line_f_opcode);
+#endif
+
+#if defined (L_non_pc_breakpoint_debug_interrupt)
+ISR_DEFINE (__non_pc_breakpoint_debug_interrupt);
+#endif
+
+#if defined (L_pc_breakpoint_debug_interrupt)
+ISR_DEFINE (__pc_breakpoint_debug_interrupt);
+#endif
+
+#if defined (L_format_error)
+ISR_DEFINE (__format_error);
+#endif
+
+#if defined (L_spurious_interrupt)
+ISR_DEFINE (__spurious_interrupt);
+#endif
+
+#if defined (L_trap0)
+ISR_DEFINE (__trap0);
+#endif
+
+#if defined (L_trap1)
+ISR_DEFINE (__trap1);
+#endif
+
+#if defined (L_trap2)
+ISR_DEFINE (__trap2);
+#endif
+
+#if defined (L_trap3)
+ISR_DEFINE (__trap3);
+#endif
+
+#if defined (L_trap4)
+ISR_DEFINE (__trap4);
+#endif
+
+#if defined (L_trap5)
+ISR_DEFINE (__trap5);
+#endif
+
+#if defined (L_trap6)
+ISR_DEFINE (__trap6);
+#endif
+
+#if defined (L_trap7)
+ISR_DEFINE (__trap7);
+#endif
+
+#if defined (L_trap8)
+ISR_DEFINE (__trap8);
+#endif
+
+#if defined (L_trap9)
+ISR_DEFINE (__trap9);
+#endif
+
+#if defined (L_trap10)
+ISR_DEFINE (__trap10);
+#endif
+
+#if defined (L_trap11)
+ISR_DEFINE (__trap11);
+#endif
+
+#if defined (L_trap12)
+ISR_DEFINE (__trap12);
+#endif
+
+#if defined (L_trap13)
+ISR_DEFINE (__trap13);
+#endif
+
+#if defined (L_trap14)
+ISR_DEFINE (__trap14);
+#endif
+
+#if defined (L_trap15)
+ISR_DEFINE (__trap15);
+#endif
+
+#if defined (L_fp_branch_unordered)
+ISR_DEFINE (__fp_branch_unordered);
+#endif
+
+#if defined (L_fp_inexact_result)
+ISR_DEFINE (__fp_inexact_result);
+#endif
+
+#if defined (L_fp_divide_by_zero)
+ISR_DEFINE (__fp_divide_by_zero);
+#endif
+
+#if defined (L_fp_underflow)
+ISR_DEFINE (__fp_underflow);
+#endif
+
+#if defined (L_fp_operand_error)
+ISR_DEFINE (__fp_operand_error);
+#endif
+
+#if defined (L_fp_overflow)
+ISR_DEFINE (__fp_overflow);
+#endif
+
+#if defined (L_fp_input_not_a_number)
+ISR_DEFINE (__fp_input_not_a_number);
+#endif
+
+#if defined (L_fp_input_denormalized_number)
+ISR_DEFINE (__fp_input_denormalized_number);
+#endif
+
+#if defined (L_unsupported_instruction)
+ISR_DEFINE (__unsupported_instruction);
+#endif
Index: libgloss/m68k/bdm-isv.c
===================================================================
RCS file: libgloss/m68k/bdm-isv.c
diff -N libgloss/m68k/bdm-isv.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-isv.c	22 May 2006 22:26:09 -0000	1.1.2.4
@@ -0,0 +1,148 @@
+/*
+ * bdm-isv.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+/* This file contains default interrupt handlers and initialization
+   code for the interrupt vector.  All but one of the interrupts are
+   user replaceable.
+
+   User trap BDM_TRAPNUM (15) is used for semi hosting support.
+   If you replace this one, semihosting will cease to function. */
+
+#include "bdm-semihost.h"
+
+#define NUM_VECTORS 256
+
+#define ISR_DECLARE(NAME) void __attribute__((interrupt_handler)) NAME (void)
+
+ISR_DECLARE (__other_interrupt);
+ISR_DECLARE (__reset);
+ISR_DECLARE (__access_error);
+ISR_DECLARE (__address_error);
+ISR_DECLARE (__illegal_instruction);
+ISR_DECLARE (__divide_by_zero);
+ISR_DECLARE (__privilege_violation);
+ISR_DECLARE (__trace);
+ISR_DECLARE (__unimplemented_line_a_opcode);
+ISR_DECLARE (__unimplemented_line_f_opcode);
+ISR_DECLARE (__non_pc_breakpoint_debug_interrupt);
+ISR_DECLARE (__pc_breakpoint_debug_interrupt);
+ISR_DECLARE (__format_error);
+ISR_DECLARE (__spurious_interrupt);
+ISR_DECLARE (__trap0);
+ISR_DECLARE (__trap1);
+ISR_DECLARE (__trap2);
+ISR_DECLARE (__trap3);
+ISR_DECLARE (__trap4);
+ISR_DECLARE (__trap5);
+ISR_DECLARE (__trap6);
+ISR_DECLARE (__trap7);
+ISR_DECLARE (__trap8);
+ISR_DECLARE (__trap9);
+ISR_DECLARE (__trap10);
+ISR_DECLARE (__trap11);
+ISR_DECLARE (__trap12);
+ISR_DECLARE (__trap13);
+ISR_DECLARE (__trap14);
+ISR_DECLARE (__trap15);
+ISR_DECLARE (__fp_branch_unordered);
+ISR_DECLARE (__fp_inexact_result);
+ISR_DECLARE (__fp_divide_by_zero);
+ISR_DECLARE (__fp_underflow);
+ISR_DECLARE (__fp_operand_error);
+ISR_DECLARE (__fp_overflow);
+ISR_DECLARE (__fp_input_not_a_number);
+ISR_DECLARE (__fp_input_denormalized_number);
+ISR_DECLARE (__unsupported_instruction);
+
+/* The trap used for semihosting by the debugger.  This must have a
+   particular assembly signature, so we don't generate it with the
+   compiler.   */
+ISR_DECLARE (__bdm_semihosting);
+
+/* The interrupt vector itself must be provided by the linker script
+   as it requires 1MB alignment. */
+extern void (*__interrupt_vector[NUM_VECTORS])(void);
+
+/* The linker script sets the stack pointer too.  */
+extern int  __attribute__ ((weak)) __stack;
+
+/* This hook is called during crt startup and installs and initializes
+   the vector table.  It is overridable by a user provided routine.
+   If the user routine fails to install the __bdm_semihosting routine,
+   semihosting will cease to function.   */
+
+void  software_init_hook (void)
+{
+  unsigned ix;
+
+  /* Don't set it if it's -1 (zero is a valid value) */
+  if ((long)&__interrupt_vector == -1)
+    return;
+  
+  for (ix = 0; ix != NUM_VECTORS; ix++)
+    __interrupt_vector[ix] = &__other_interrupt;
+  
+  /* Set the VBR. */
+  __asm__ __volatile__ ("movec.l %0,%/vbr" :: "r" (&__interrupt_vector));
+
+  /* Set an initial stack and reset vector, in case we unexpectedly get
+     reset.  */
+  __interrupt_vector[0] = (&__stack ? (void (*)(void))&__stack
+			   : (void (*)(void))&__interrupt_vector[NUM_VECTORS]);
+  __interrupt_vector[1] = &__reset;
+  
+  /* Store the known interrupt vectors */
+  __interrupt_vector[2] = &__access_error;
+  __interrupt_vector[3] = &__address_error;
+  __interrupt_vector[4] = &__illegal_instruction;
+  __interrupt_vector[5] = &__divide_by_zero;
+  __interrupt_vector[8] = &__privilege_violation;
+  __interrupt_vector[9] = &__trace;
+  __interrupt_vector[10] = &__unimplemented_line_a_opcode;
+  __interrupt_vector[11] = &__unimplemented_line_f_opcode;
+  __interrupt_vector[12] = &__non_pc_breakpoint_debug_interrupt;
+  __interrupt_vector[13] = &__pc_breakpoint_debug_interrupt;
+  __interrupt_vector[14] = &__format_error;
+  __interrupt_vector[24] = &__spurious_interrupt;
+  __interrupt_vector[32] = &__trap0;
+  __interrupt_vector[33] = &__trap1;
+  __interrupt_vector[34] = &__trap2;
+  __interrupt_vector[35] = &__trap3;
+  __interrupt_vector[36] = &__trap4;
+  __interrupt_vector[37] = &__trap5;
+  __interrupt_vector[38] = &__trap6;
+  __interrupt_vector[39] = &__trap7;
+  __interrupt_vector[40] = &__trap8;
+  __interrupt_vector[41] = &__trap9;
+  __interrupt_vector[42] = &__trap10;
+  __interrupt_vector[43] = &__trap11;
+  __interrupt_vector[44] = &__trap12;
+  __interrupt_vector[45] = &__trap13;
+  __interrupt_vector[46] = &__trap14;
+  __interrupt_vector[47] = &__trap15;
+  __interrupt_vector[48] = &__fp_branch_unordered;
+  __interrupt_vector[49] = &__fp_inexact_result;
+  __interrupt_vector[50] = &__fp_divide_by_zero;
+  __interrupt_vector[51] = &__fp_underflow;
+  __interrupt_vector[52] = &__fp_operand_error;
+  __interrupt_vector[53] = &__fp_overflow;
+  __interrupt_vector[54] = &__fp_input_not_a_number;
+  __interrupt_vector[55] = &__fp_input_denormalized_number;
+  __interrupt_vector[61] = &__unsupported_instruction;
+
+  /* Install the special handler. */
+  __interrupt_vector[0x20 + BDM_TRAPNUM] = &__bdm_semihosting;
+}
Index: libgloss/m68k/bdm-lseek.c
===================================================================
RCS file: libgloss/m68k/bdm-lseek.c
diff -N libgloss/m68k/bdm-lseek.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-lseek.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,46 @@
+/*
+ * bdm-lseek.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * lseek -- reposition a file descriptor
+ * input parameters:
+ *   0 : file descriptor
+ *   1 : high word of offset
+ *   2 : low word of offset
+ *   3 : seek flag
+ * output parameters:
+ *   0 : high word of result
+ *   1 : low word of result
+ *   2 : errno
+ */
+
+off_t lseek (int fd, off_t offset, int whence)
+{
+  gdb_parambuf_t parameters;
+  parameters[0] = (uint32_t) fd;
+  parameters[1] = (uint32_t) ((offset >> 32) & 0xffffffff);
+  parameters[2] = (uint32_t) (offset & 0xffffffff);
+  parameters[3] = convert_to_gdb_lseek_flags (whence);
+  BDM_TRAP (BDM_LSEEK, (uint32_t)parameters);
+  errno = convert_from_gdb_errno (parameters[2]);
+  return ((uint64_t)parameters[0] << 32) | ((uint64_t)parameters[1]);
+}
Index: libgloss/m68k/bdm-open.c
===================================================================
RCS file: libgloss/m68k/bdm-open.c
diff -N libgloss/m68k/bdm-open.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-open.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,56 @@
+/*
+ * bdm-open.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * open -- Open a file.
+ * input parameters:
+ *   0 : fname ptr
+ *   1 : fname length
+ *   2 : flags
+ *   3 : mode
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+int open (const char *fname, int flags, ...)
+{
+  gdb_parambuf_t parameters;
+  parameters[0] = (uint32_t) fname;
+  parameters[1] = strlen (fname) + 1;
+  parameters[2] = convert_to_gdb_open_flags (flags);
+  if (flags & O_CREAT)
+    {
+      va_list ap;
+      va_start (ap, flags);
+      parameters[3] = convert_to_gdb_mode_t (va_arg (ap, mode_t));
+      va_end (ap);
+    }
+  else
+    parameters[3] = 0;
+  BDM_TRAP (BDM_OPEN, (uint32_t)parameters);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/bdm-read.c
===================================================================
RCS file: libgloss/m68k/bdm-read.c
diff -N libgloss/m68k/bdm-read.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-read.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,42 @@
+/*
+ * bdm-read.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * read -- read from a file descriptor
+ * input parameters:
+ *   0 : file descriptor
+ *   1 : buf ptr
+ *   2 : count
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+ssize_t read (int fd, void *buf, size_t count)
+{
+  gdb_parambuf_t parameters;
+  parameters[0] = (uint32_t) fd;
+  parameters[1] = (uint32_t) buf;
+  parameters[2] = (uint32_t) count;
+  BDM_TRAP (BDM_READ, (uint32_t)parameters);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/bdm-rename.c
===================================================================
RCS file: libgloss/m68k/bdm-rename.c
diff -N libgloss/m68k/bdm-rename.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-rename.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,45 @@
+/*
+ * bdm-rename.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * rename -- rename a file
+ * input parameters:
+ *   0 : oldname ptr
+ *   1 : oldname length
+ *   2 : newname ptr
+ *   3 : newname length
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+int _rename (const char *oldpath, const char *newpath)
+{
+  gdb_parambuf_t parameters;
+  parameters[0] = (uint32_t) oldpath;
+  parameters[1] = (uint32_t) strlen (oldpath) + 1;
+  parameters[2] = (uint32_t) newpath;
+  parameters[3] = (uint32_t) strlen (newpath) + 1;
+  BDM_TRAP (BDM_RENAME, (uint32_t)parameters);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/bdm-semihost.c
===================================================================
RCS file: libgloss/m68k/bdm-semihost.c
diff -N libgloss/m68k/bdm-semihost.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-semihost.c	29 Mar 2006 07:29:11 -0000	1.1.2.2
@@ -0,0 +1,25 @@
+/*
+ * bdm-semihost.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+/* Semihosting trap.  The debugger intercepts this and
+   performs the semihosting action.  Then the program resumes as
+   usual.  This function must be compiled without a frame pointer, so
+   we know the halt instruction is the very first instuction.  */
+	
+void __attribute__ ((interrupt_handler)) __bdm_semihosting (void) 
+{
+  __asm__ __volatile__ ("halt" ::: "memory");
+}
Index: libgloss/m68k/bdm-semihost.h
===================================================================
RCS file: libgloss/m68k/bdm-semihost.h
diff -N libgloss/m68k/bdm-semihost.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-semihost.h	24 May 2006 07:54:51 -0000	1.1.2.4
@@ -0,0 +1,57 @@
+/*
+ * bdm semihosting support.
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+/* Semihosting uses a user trap handler containing a HALT
+   instruction.  This wakes the debugger to perform some action.  */
+
+/* This is the semihosting trap hander */
+#define BDM_TRAPNUM 15
+
+/* This register holds the function enumeration for a semihosting
+   command.  */
+#define BDM_FUNC_REG "d0"
+
+/* This register holds the argument for the semihosting call.  For most
+   functions, this is a pointer to a block of memory that holds the input
+   and output parameters for the remote file i/o operation.  */
+#define BDM_ARG_REG  "d1"
+
+/* Codes for BDM_FUNC_REG.  */
+
+#define BDM_EXIT  0
+#define BDM_PUTCHAR 1 /* Obsolete */
+#define BDM_OPEN 2
+#define BDM_CLOSE 3
+#define BDM_READ 4
+#define BDM_WRITE 5
+#define BDM_LSEEK 6
+#define BDM_RENAME 7
+#define BDM_UNLINK 8
+#define BDM_STAT 9
+#define BDM_FSTAT 10
+#define BDM_GETTIMEOFDAY 11
+#define BDM_ISATTY 12
+#define BDM_SYSTEM 13
+
+/* Here is the macro that generates the trap. */
+
+#define BDM_TRAP(func, arg) \
+  __asm__ __volatile__ ("move.l %0,%/" BDM_ARG_REG "\n" \
+			"moveq %1,%/" BDM_FUNC_REG "\n" \
+			"trap %2" \
+			:: "rmi" (arg), "n" (func), "n" (BDM_TRAPNUM) \
+			: BDM_FUNC_REG,BDM_ARG_REG,"memory")
+
Index: libgloss/m68k/bdm-stat.c
===================================================================
RCS file: libgloss/m68k/bdm-stat.c
diff -N libgloss/m68k/bdm-stat.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-stat.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,48 @@
+/*
+ * bdm-stat.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * stat -- get file information
+ * input parameters:
+ *   0 : filename ptr
+ *   1 : filename length
+ *   2 : stat buf ptr
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+
+int stat (const char *filename, struct stat *buf)
+{
+  gdb_parambuf_t parameters;
+  struct gdb_stat gbuf;
+  parameters[0] = (uint32_t) filename;
+  parameters[1] = (uint32_t) strlen (filename) + 1;
+  parameters[2] = (uint32_t) &gbuf;
+  BDM_TRAP (BDM_STAT, (uint32_t)parameters);
+  convert_from_gdb_stat (&gbuf, buf);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/bdm-system.c
===================================================================
RCS file: libgloss/m68k/bdm-system.c
diff -N libgloss/m68k/bdm-system.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-system.c	9 Jun 2006 20:31:19 -0000	1.1.2.4
@@ -0,0 +1,55 @@
+/*
+ * bdm-system.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/wait.h>
+/*
+ * system: execute command on (remote) host
+ * input parameters:
+ *   0 : command ptr
+ *   1 : command length
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+int _system (const char *command)
+{
+  int e;
+  gdb_parambuf_t parameters;
+  
+  parameters[0] = (uint32_t) command;
+  parameters[1] = command ? (uint32_t) strlen (command) + 1 : 0;
+  BDM_TRAP (BDM_SYSTEM, (uint32_t)parameters);
+  errno = convert_from_gdb_errno (parameters[1]);
+  e = parameters[0];
+  if (e >= 0 && command)
+    {
+      /* We have to convert e, an exit status to the encoded status of
+	 the command.  To avoid hard coding the exit status, we simply
+	 loop until we find the right position.  */
+      int exit_code;
+
+      for (exit_code = e; e && WEXITSTATUS (e) != exit_code; e <<= 1)
+	continue;
+    }
+  
+  return e;
+}
Index: libgloss/m68k/bdm-time.c
===================================================================
RCS file: libgloss/m68k/bdm-time.c
diff -N libgloss/m68k/bdm-time.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-time.c	5 Jun 2006 14:22:26 -0000	1.1.2.1
@@ -0,0 +1,21 @@
+#include <sys/time.h>
+
+/*
+ * time -- get the current time
+ * input parameters:
+ *   0 : timeval ptr
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+time_t time (time_t *t)
+{
+  struct timeval tv;
+
+  if (gettimeofday (&tv, NULL))
+    return -1;
+  if (t)
+    *t = tv.tv_sec;
+  return tv.tv_sec;
+}
Index: libgloss/m68k/bdm-unlink.c
===================================================================
RCS file: libgloss/m68k/bdm-unlink.c
diff -N libgloss/m68k/bdm-unlink.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-unlink.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,41 @@
+/*
+ * bdm-unlink.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * unlink -- unlink (delete) a file
+ * input parameters:
+ *   0 : filename ptr
+ *   1 : filename length
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+int unlink (const char *path)
+{
+  gdb_parambuf_t parameters;
+  parameters[0] = (uint32_t) path;
+  parameters[1] = (uint32_t) strlen (path) + 1;
+  BDM_TRAP (BDM_UNLINK, (uint32_t)parameters);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/bdm-write.c
===================================================================
RCS file: libgloss/m68k/bdm-write.c
diff -N libgloss/m68k/bdm-write.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/bdm-write.c	5 Jun 2006 14:22:26 -0000	1.1.2.2
@@ -0,0 +1,42 @@
+/*
+ * bdm-write.c -- 
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * write -- write to a file descriptor
+ * input parameters:
+ *   0 : file descriptor
+ *   1 : buf ptr
+ *   2 : count
+ * output parameters:
+ *   0 : result
+ *   1 : errno
+ */
+
+ssize_t write (int fd, const void *buf, size_t count)
+{
+  gdb_parambuf_t parameters;
+  parameters[0] = (uint32_t) fd;
+  parameters[1] = (uint32_t) buf;
+  parameters[2] = (uint32_t) count;
+  BDM_TRAP (BDM_WRITE, (uint32_t)parameters);
+  errno = convert_from_gdb_errno (parameters[1]);
+  return parameters[0];
+}
Index: libgloss/m68k/cf.sc
===================================================================
RCS file: libgloss/m68k/cf.sc
diff -N libgloss/m68k/cf.sc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libgloss/m68k/cf.sc	24 Jul 2006 16:49:07 -0000	1.1.2.3
@@ -0,0 +1,112 @@
+# a linker script template.
+# RAMSTART - start of board's ram
+# RAMSIZE - size of board's ram
+# RAMDBUG - bytes at start of RAM for DBUG use
+# ISV - nonnull if interrupt service vector should be provided.
+# IO - io library
+
+cat <<EOF
+STARTUP(crt0.o)
+OUTPUT_ARCH(m68k)
+ENTRY(_start)
+SEARCH_DIR(.)
+GROUP(-lc -l${IO})
+__DYNAMIC  =  0;
+
+MEMORY
+{
+  ram (rwx) : ORIGIN = ${RAMSTART} + ${RAMDBUG:-0},
+		 LENGTH = ${RAMSIZE} - ${RAMDBUG:-0}
+}
+
+/* Place the stack at the end of memory, unless specified otherwise. */
+PROVIDE (__stack = ${RAMSTART} + ${RAMSIZE});
+
+/* Inhibit an interrupt vector, if one is not specified.  */
+PROVIDE (__interrupt_vector = -1);
+
+/*
+ * Initalize some symbols to be zero so we can reference them in the
+ * crt0 without core dumping. These functions are all optional, but
+ * we do this so we can have our crt0 always use them if they exist. 
+ */
+PROVIDE (hardware_init_hook = 0);
+PROVIDE (software_init_hook = 0);
+/*
+ * stick everything in ram (of course)
+ */
+SECTIONS
+{
+  .text :
+  {
+    CREATE_OBJECT_SYMBOLS
+    ${ISV+__interrupt_vector = .; . += 256 * 4;}
+    *(.text .text.*)
+
+    . = ALIGN(0x4);
+    /* These are for running static constructors and destructors under ELF.  */
+    KEEP (*crtbegin.o(.ctors))
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+    KEEP (*crtbegin.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+
+    *(.rodata .rodata.*)
+
+    . = ALIGN(0x4);
+    *(.gcc_except_table) 
+
+    . = ALIGN(0x4);
+    *(.eh_frame)
+
+    . = ALIGN(0x4);
+    __INIT_SECTION__ = . ;
+    LONG (0x4e560000)	/* linkw %fp,#0 */
+    *(.init)
+    SHORT (0x4e5e)	/* unlk %fp */
+    SHORT (0x4e75)	/* rts */
+
+    . = ALIGN(0x4);
+    __FINI_SECTION__ = . ;
+    LONG (0x4e560000)	/* linkw %fp,#0 */
+    *(.fini)
+    SHORT (0x4e5e)	/* unlk %fp */
+    SHORT (0x4e75)	/* rts */
+
+    _etext = .;
+    *(.lit)
+  } > ram
+
+  .data :
+  {
+    *(.got.plt) *(.got)
+    *(.shdata)
+    *(.data .data.*)
+    _edata = .;
+  } > ram
+
+  .bss :
+  {
+    . = ALIGN(0x4);
+    __bss_start = . ;
+    *(.shbss)
+    *(.bss .bss.*)
+    *(COMMON)
+    _end =  ALIGN (0x8);
+    __end = _end;
+  } > ram
+
+  .stab 0 (NOLOAD) :
+  {
+    *(.stab)
+  }
+
+  .stabstr 0 (NOLOAD) :
+  {
+    *(.stabstr)
+  }
+}
+EOF
Index: libgloss/m68k/crt0.S
===================================================================
RCS file: /cvs/src/src/libgloss/m68k/crt0.S,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- libgloss/m68k/crt0.S	22 Feb 2006 18:02:54 -0000	1.3
+++ libgloss/m68k/crt0.S	24 Jul 2006 16:49:07 -0000	1.3.2.1
@@ -52,11 +52,17 @@
 	.extern _end
 
 /*
- * set things up so the application will run. This *must* be called start.
+ * Set things up so the application will run. For historical reasons
+ * this is called 'start'.  We set things up to provide '_start'
+ * as with other systems, but also provide a weak alias called
+ * 'start' for compatibility with existing linker scripts.
  */
 	.global SYM (start)
+	.weak SYM (start)
+	.set SYM (start),SYM(_start)
 
-SYM (start):
+	.global SYM (_start)
+SYM (_start):
 	/*
 	 * put any hardware init code here
 	 */
Index: libgloss/m68k/dbug-cf.sc
===================================================================
RCS file: libgloss/m68k/dbug-cf.sc
diff -N libgloss/m68k/dbug-cf.sc
--- libgloss/m68k/dbug-cf.sc	22 Feb 2006 18:02:54 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,112 +0,0 @@
-# a linker script template.
-# RAMSTART - start of board's ram
-# RAMSIZE - size of board's ram
-# RAMDBUG - bytes at start of RAM for DBUG use
-
-cat <<EOF
-STARTUP(crt0.o)
-OUTPUT_ARCH(m68k)
-/* DBUG loads SREC files */
-/*OUTPUT_FORMAT(srec)*/
-ENTRY(start)
-SEARCH_DIR(.)
-GROUP(-ldbug -lc -lgcc -ldbug)
-__DYNAMIC  =  0;
-
-MEMORY
-{
-  ram (rwx) : ORIGIN = ${RAMSTART} + ${RAMDBUG:-0},
-		 LENGTH = ${RAMSIZE} - ${RAMDBUG:-0}
-}
-
-PROVIDE (__stack = ${RAMSTART} + ${RAMSIZE});
-
-/*
- * Initalize some symbols to be zero so we can reference them in the
- * crt0 without core dumping. These functions are all optional, but
- * we do this so we can have our crt0 always use them if they exist. 
- * This is so BSPs work better when using the crt0 installed gcc.
- * We have to initalize them twice, so we cover a.out (which prepends
- * an underscore) and coff object file formats.
- */
-PROVIDE (hardware_init_hook = 0);
-PROVIDE (_hardware_init_hook = 0);
-PROVIDE (software_init_hook = 0);
-PROVIDE (_software_init_hook = 0);
-/*
- * stick everything in ram (of course)
- */
-SECTIONS
-{
-  .text :
-  {
-    CREATE_OBJECT_SYMBOLS
-    *(.text .text.*)
-
-    . = ALIGN(0x4);
-    /* These are for running static constructors and destructors under ELF.  */
-    KEEP (*crtbegin.o(.ctors))
-    KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
-    KEEP (*(SORT(.ctors.*)))
-    KEEP (*(.ctors))
-    KEEP (*crtbegin.o(.dtors))
-    KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
-    KEEP (*(SORT(.dtors.*)))
-    KEEP (*(.dtors))
-
-    *(.rodata .rodata.*)
-
-    . = ALIGN(0x4);
-    *(.gcc_except_table) 
-
-    . = ALIGN(0x4);
-    *(.eh_frame)
-
-    . = ALIGN(0x4);
-    __INIT_SECTION__ = . ;
-    LONG (0x4e560000)	/* linkw %fp,#0 */
-    *(.init)
-    SHORT (0x4e5e)	/* unlk %fp */
-    SHORT (0x4e75)	/* rts */
-
-    . = ALIGN(0x4);
-    __FINI_SECTION__ = . ;
-    LONG (0x4e560000)	/* linkw %fp,#0 */
-    *(.fini)
-    SHORT (0x4e5e)	/* unlk %fp */
-    SHORT (0x4e75)	/* rts */
-
-    _etext = .;
-    *(.lit)
-  } > ram
-
-  .data :
-  {
-    *(.got.plt) *(.got)
-    *(.shdata)
-    *(.data .data.*)
-    _edata = .;
-  } > ram
-
-  .bss :
-  {
-    . = ALIGN(0x4);
-    __bss_start = . ;
-    *(.shbss)
-    *(.bss .bss.*)
-    *(COMMON)
-    _end =  ALIGN (0x8);
-    __end = _end;
-  } > ram
-
-  .stab 0 (NOLOAD) :
-  {
-    *(.stab)
-  }
-
-  .stabstr 0 (NOLOAD) :
-  {
-    *(.stabstr)
-  }
-}
-EOF



More information about the Newlib mailing list