Xplatform C

Michael Meissner meissner@cygnus.com
Thu Jul 13 11:23:00 GMT 2000


On Thu, Jul 13, 2000 at 11:09:20AM -0700, Mike Stump wrote:
> > Date: Thu, 13 Jul 2000 04:15:57 -0400 (EDT)
> > From: Paton Wong <patonw@mail.com>
> 
> > I was wondering if it would be possible to build a system to compile
> > C code into some binary format and have it run on any system and
> > even have a gui toolkit with widgets and stuff and a plug-in for
> > netscape.
> 
> Yes.  Most of the pieces are there.  But, if you aren't going to
> champion it, who will?  gcc can be configured, as for PowerPC, and we
> have a PowerPC simulator, so you just always compile up for one, and
> then simulate it on the local machine.  You can wire in local GUI
> libraries and hook into Java and Tcl and what-not just fine...

With the MISC format support under Linux you can even tell the kernel to
automatically execute the simulator when it is told to run a given binary.  I
install this script as /etc/rc.d/rc{3,4,5}.d/S82binfmt and
/etc/rc.d/init.d/binfmt, and it automatically installs whatever simulators I
happen to have installed at the time:

#!/bin/sh

# Source function library.
. /etc/rc.d/init.d/functions

# See how we were called.
case "$1" in
  start)
	if [ -d /proc/sys/fs/binfmt_misc ]; then
		sims=""
		/bin/echo -1 > /proc/sys/fs/binfmt_misc/status

		if [ -x /usr/cygnus/work-powerpc/bin/powerpc-eabisim_big-run ]; then
			sims="$sims ppc"
			/bin/echo ":ppc-big:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14::/usr/cygnus/work-powerpc/bin/powerpc-eabisim_big-run:" > /proc/sys/fs/binfmt_misc/register

		elif [ -x /usr/cygnus/work-powerpc/bin/powerpc-eabisim-run ]; then
			sims="$sims ppc"
			/bin/echo ":ppc-big:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14::/usr/cygnus/work-powerpc/bin/powerpc-eabisim-run:" > /proc/sys/fs/binfmt_misc/register

		fi

		if [ -x /usr/cygnus/work-powerpc/bin/powerpc-eabisim_little-run ]; then
			sims="$sims ppcle"
			/bin/echo ":ppc-little:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00::/usr/cygnus/work-powerpc/bin/powerpc-eabisim_little-run:" > /proc/sys/fs/binfmt_misc/register

		elif [ -x /usr/cygnus/work-powerpc/bin/powerpc-eabisim-run ]; then
			sims="$sims ppcle"
			/bin/echo ":ppc-little:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00::/usr/cygnus/work-powerpc/bin/powerpc-eabisim-run:" > /proc/sys/fs/binfmt_misc/register

		fi

		if [ -x /usr/cygnus/work-d10v/bin/d10v-elf-run ]; then
			sims="$sims d10v"
			/bin/echo ":d10v:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x76\x50::/usr/cygnus/work-d10v/bin/d10v-elf-run:" > /proc/sys/fs/binfmt_misc/register
		fi

		if [ -x /usr/cygnus/work-d30v/bin/d30v-elf-run ]; then
			sims="$sims d30v"
			/bin/echo ":d30v:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x76\x76::/usr/cygnus/work-d30v/bin/d30v-elf-run:" > /proc/sys/fs/binfmt_misc/register
		fi

		if [ -x /usr/cygnus/work-m32r/bin/m32r-elf-run ]; then
			sims="$sims m32r"
			/bin/echo ":m32r:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x90\x41::/usr/cygnus/work-m32r/bin/m32r-elf-run:" > /proc/sys/fs/binfmt_misc/register
		fi

		if [ -x /usr/cygnus/work-tic80/bin/tic80-coff-run ]; then
			sims="$sims tic80"
			/bin/echo ":tic80:M::\xc1\x00::/usr/cygnus/work-tic80/bin/tic80-coff-run:" > /proc/sys/fs/binfmt_misc/register
		fi

		if [ -x /usr/cygnus/work-v850/bin/v850-elf-run ]; then
			sims="$sims v850"
			/bin/echo ":v850:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x80\x90::/usr/cygnus/work-v850/bin/v850-elf-run:" > /proc/sys/fs/binfmt_misc/register
		fi
	fi
	;;

  stop)
	;;

  *)
	echo "Usage: binfmt {start|stop}"
	exit 1
esac

exit 0


-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482


More information about the Gcc mailing list