Patch for DICE that fix issue with AMD64 host

Alexander Valitov valitov79 at mail.ru
Thu Mar 19 14:11:51 CET 2009


Hi,

I would like to submit path that fix problem when you use DICE to produce
code for i32 on 64bit OS.
Please see this thread for details:
http://www.nabble.com/Build-DROPS-on-64bit-Host-for-32bit-Target-td22563295.html

The root of problem was that DICE determines some data type's size as
sizeof(type). This is obviously wrong if DICE is a 64bit application and a
code is generated for 32bit system.

I would like to thank Roman I Khimov for spending his time for locating the
issue and kindly providing us with the following patch.

Patch is attached to the letter and repeated in the message text below.

Signed-off-by: Roman I Khimov, Altell Ltd. (http://www.altell-ltd.com/)

By signing my contribution to the TUD:OS project, I certify/agree that:

(a) The contribution may be distributed under the same licenses as the
TUD:OS
    project, as detailed in the COPYRIGHT file (called the file from here
on).
    
(b) The contribution was created in whole or in part by me and I have the
right
    to submit it under the open source licenses indicated in the file; or

(c) The contribution is based upon previous work that, to the best of my
knowledge,
    is covered under an appropriate open source license and I have the right
under
    that license to submit that work with modifications, whether created in
whole or
    in part by me, under the same open source licenses (unless I am
permitted to submit
    under a different license), as indicated in the file; or

(d) The contribution was provided directly to me by some other person who
certified
    (a) and (b), (c) or (d) and I have not modified it.

(e) In the case of each of (a) and (b), (c) or (d), I understand and agree
that
    this project and the contribution are public and that a record of the
contribution
    (including all personal information I submit with it, including my
sign-off) is
    maintained indefinitely and may be redistributed consistent with this
project or
    the open source license indicated in the file.

Index: dice/src/be/l4/fiasco/Makefile.am
===================================================================
--- dice.orig/src/be/l4/fiasco/Makefile.am	2009-03-10 15:26:43.000000000
+0300
+++ dice/src/be/l4/fiasco/Makefile.am	2009-03-19 09:31:47.669561915 +0300
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = amd64
+SUBDIRS = amd64 ia32
 
 noinst_LIBRARIES = libfiasco.a
 
Index: dice/src/be/l4/fiasco/ia32/L4FiascoIA32ClassFactory.cpp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dice/src/be/l4/fiasco/ia32/L4FiascoIA32ClassFactory.cpp	2009-03-19
09:31:47.669561915 +0300
@@ -0,0 +1,49 @@
+/**
+ *    \file    dice/src/be/l4/fiasco/ia32/L4FiascoIA32ClassFactory.cpp
+ *    \brief   contains the implementation of the class
CL4FiascoIA32BEClassFactory
+ *
+ *    \date    03/19/2009
+ *    \author  Roman Khimov <khimov at altell.ru>
+ */
+/*
+ * Copyright (C) 2009
+ * Dresden University of Technology, Operating Systems Research Group
+ *
+ * This file contains free software, you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2 as
+ * published by the Free Software Foundation (see the file COPYING).
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * For different licensing schemes please contact
+ * <contact at os.inf.tu-dresden.de>.
+ */
+
+#include "L4FiascoIA32ClassFactory.h"
+#include "L4FiascoIA32Sizes.h"
+#include "Compiler.h"
+
+CL4FiascoIA32BEClassFactory::CL4FiascoIA32BEClassFactory()
+: CL4FiascoBEClassFactory()
+{ }
+
+/**    \brief the destructor of this class */
+CL4FiascoIA32BEClassFactory::~CL4FiascoIA32BEClassFactory()
+{ }
+
+/** \brief creates a new sizes class
+ *  \return a reference to the new sizes object
+ */
+CBESizes * CL4FiascoIA32BEClassFactory::GetNewSizes()
+{
+    CCompiler::Verbose("CL4FiascoIA32BEClassFactory: created class
CL4FiascoBESizes\n");
+    return new CL4FiascoIA32BESizes();
+}
+
Index: dice/src/be/l4/fiasco/ia32/L4FiascoIA32ClassFactory.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dice/src/be/l4/fiasco/ia32/L4FiascoIA32ClassFactory.h	2009-03-19
09:31:47.670561788 +0300
@@ -0,0 +1,56 @@
+/**
+ *    \file    dice/src/be/l4/fiasco/ia32/L4FiascoIA32ClassFactory.h
+ *    \brief   contains the declaration of the class
CL4FiascoIA32BEClassFactory
+ *
+ *    \date    03/19/2009
+ *    \author  Roman Khimov <khimov at altell.ru>
+ */
+/*
+ * Copyright (C) 2009
+ * Dresden University of Technology, Operating Systems Research Group
+ *
+ * This file contains free software, you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2 as
+ * published by the Free Software Foundation (see the file COPYING).
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * For different licensing schemes please contact
+ * <contact at os.inf.tu-dresden.de>.
+ */
+
+/** preprocessing symbol to check header file */
+#ifndef __DICE_L4FIASCOIA32CLASSFACTORY_H__
+#define __DICE_L4FIASCOIA32CLASSFACTORY_H__
+
+#include "be/l4/fiasco/L4FiascoBEClassFactory.h"
+
+/** \class CL4FiascoIA32BEClassFactory
+ *  \ingroup backend
+ *  \brief the class factory for the back-end classes
+ *
+ * We use seperate functions for each class, because the alternative is to
use
+ * some sort of identifier to find out which class to generate. This
involves
+ * writing a big switch statement.
+ */
+class CL4FiascoIA32BEClassFactory : public CL4FiascoBEClassFactory
+{
+// Constructor
+public:
+    /** \brief constructor
+     */
+    CL4FiascoIA32BEClassFactory();
+    virtual ~CL4FiascoIA32BEClassFactory();
+
+public:
+    virtual CBESizes * GetNewSizes();
+};
+
+#endif // !__DICE_L4FIASCOIA32CLASSFACTORY_H__
Index: dice/src/be/l4/fiasco/ia32/L4FiascoIA32Sizes.cpp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dice/src/be/l4/fiasco/ia32/L4FiascoIA32Sizes.cpp	2009-03-19
13:05:32.104520424 +0300
@@ -0,0 +1,58 @@
+/**
+ *	\file	dice/src/be/l4/fiasco/ia32/L4FiascoIA32Sizes.cpp
+ *	\brief   contains the implementation of the class CL4FiascoIA32BESizes
+ *
+ *	\date	03/19/2009
+ *	\author  Roman Khimov <khimov at altell.ru>
+ */
+/*
+ * Copyright (C) 2009
+ * Dresden University of Technology, Operating Systems Research Group
+ *
+ * This file contains free software, you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2 as
+ * published by the Free Software Foundation (see the file COPYING).
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * For different licensing schemes please contact
+ * <contact at os.inf.tu-dresden.de>.
+ */
+
+#include "L4FiascoIA32Sizes.h"
+#include "TypeSpec-Type.h"
+
+CL4FiascoIA32BESizes::CL4FiascoIA32BESizes()
+{ }
+
+/** \brief destroys object of this class */
+CL4FiascoIA32BESizes::~CL4FiascoIA32BESizes()
+{ }
+
+/** \brief gets the size of a type
+ *  \param nFEType the type to look up
+ *  \param nFESize the size in the front-end
+ *  \return the size of the type in bytes
+ */
+int CL4FiascoIA32BESizes::GetSizeOfType(int nFEType, int nFESize)
+{
+	int nSize = 0;
+	switch (nFEType)
+	{
+	case TYPE_MWORD:
+		nSize = 4;
+		break;
+	default:
+		nSize = CL4FiascoBESizes::GetSizeOfType(nFEType, nFESize);
+		break;
+	}
+	return nSize;
+}
+
Index: dice/src/be/l4/fiasco/ia32/L4FiascoIA32Sizes.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dice/src/be/l4/fiasco/ia32/L4FiascoIA32Sizes.h	2009-03-19
09:31:47.671562080 +0300
@@ -0,0 +1,51 @@
+/**
+ *    \file    dice/src/be/l4/fiasco/ia32/L4FiascoIA32Sizes.h
+ *    \brief   contains the declaration of the class CL4FiascoIA32BESizes
+ *
+ *    \date    03/19/2009
+ *    \author  Roman Khimov <khimov at altell.ru>
+ */
+/*
+ * Copyright (C) 2009
+ * Dresden University of Technology, Operating Systems Research Group
+ *
+ * This file contains free software, you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2 as
+ * published by the Free Software Foundation (see the file COPYING).
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * For different licensing schemes please contact
+ * <contact at os.inf.tu-dresden.de>.
+ */
+
+/** preprocessing symbol to check header file */
+
+#ifndef __DICE_L4FIASCOIA32SIZES_H__
+#define __DICE_L4FIASCOIA32SIZES_H__
+
+#include <be/l4/fiasco/L4FiascoBESizes.h>
+
+/** \class CL4FiascoIA32BESizes
+ *  \ingroup backend
+ *  \brief contains the L4 version 2 specific sizes for IA32
+ */
+class CL4FiascoIA32BESizes : public CL4FiascoBESizes
+{
+public:
+    /** constructs a new object of this class */
+    CL4FiascoIA32BESizes();
+    virtual ~CL4FiascoIA32BESizes();
+
+public: // Public methods
+    virtual int GetSizeOfType(int nFEType, int nFESize = 0);
+};
+
+#endif
Index: dice/src/be/l4/fiasco/ia32/Makefile.am
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dice/src/be/l4/fiasco/ia32/Makefile.am	2009-03-19 13:10:43.300270769
+0300
@@ -0,0 +1,9 @@
+## Process this file with automake to produce Makefile.in
+
+noinst_LIBRARIES = libfiascoia32.a
+
+libfiascoia32_a_SOURCES = L4FiascoIA32ClassFactory.cpp
L4FiascoIA32Sizes.cpp
+
+noinst_HEADERS = L4FiascoIA32ClassFactory.h L4FiascoIA32Sizes.h
+
+AM_CXXFLAGS = @DICE_CXXFLAGS@
Index: dice/configure.in
===================================================================
--- dice.orig/configure.in	2009-03-10 15:26:55.000000000 +0300
+++ dice/configure.in	2009-03-19 09:31:47.672561882 +0300
@@ -172,6 +172,7 @@
 src/be/l4/v4/ia32/Makefile
 src/be/l4/fiasco/Makefile
 src/be/l4/fiasco/amd64/Makefile
+src/be/l4/fiasco/ia32/Makefile
 src/be/sock/Makefile
 include/Makefile
 include/dice/Makefile
Index: dice/src/Makefile.am
===================================================================
--- dice.orig/src/Makefile.am	2009-03-10 15:26:50.000000000 +0300
+++ dice/src/Makefile.am	2009-03-19 09:31:47.672561882 +0300
@@ -10,6 +10,7 @@
 		$(top_builddir)/src/be/l4/v4/ia32/libv4ia32.a \
 		$(top_builddir)/src/be/l4/fiasco/libfiasco.a \
 		$(top_builddir)/src/be/l4/fiasco/amd64/libfiascoamd64.a \
+		$(top_builddir)/src/be/l4/fiasco/ia32/libfiascoia32.a \
 		$(top_builddir)/src/be/sock/libsock.a \
 		$(top_builddir)/src/be/libbe.a \
 		$(top_builddir)/src/fe/libfe.a \
@@ -33,6 +34,7 @@
 		-L$(top_builddir)/src/be/l4/v4/ia32 -lv4ia32 \
 		-L$(top_builddir)/src/be/l4/fiasco -lfiasco \
 		-L$(top_builddir)/src/be/l4/fiasco/amd64 -lfiascoamd64 \
+		-L$(top_builddir)/src/be/l4/fiasco/ia32 -lfiascoia32 \
 		-L$(top_builddir)/src/be/l4 -ll4 \
 		-L$(top_builddir)/src/be/sock -lsock \
 		-L$(top_builddir)/src/be -lbe \
Index: dice/src/FactoryFactory.cpp
===================================================================
--- dice.orig/src/FactoryFactory.cpp	2009-03-10 15:26:50.000000000 +0300
+++ dice/src/FactoryFactory.cpp	2009-03-19 13:11:53.111290914 +0300
@@ -44,6 +44,8 @@
 // L4.Fiasco AMD64
 #include "be/l4/fiasco/amd64/L4FiascoAMD64ClassFactory.h"
 #include "be/l4/fiasco/amd64/L4FiascoAMD64NameFactory.h"
+// L4.Fiasco IA32
+#include "be/l4/fiasco/ia32/L4FiascoIA32ClassFactory.h"
 // L4V4
 #include "be/l4/v4/L4V4BEClassFactory.h"
 #include "be/l4/v4/ia32/L4V4IA32ClassFactory.h"
@@ -79,6 +81,8 @@
 	{
 		if (CCompiler::IsBackEndPlatformSet(PROGRAM_BE_AMD64))
 			pCF = new CL4FiascoAMD64BEClassFactory();
+		else if (CCompiler::IsBackEndPlatformSet(PROGRAM_BE_IA32))
+			pCF = new CL4FiascoIA32BEClassFactory();
 		else
 			pCF = new CL4FiascoBEClassFactory();
 	}


Best Regards,
  Alexander Valitov
    on behalf of Roman I Khimov

http://www.nabble.com/file/p22599858/dice-l4-fiasco-ia32-sizes.patch
dice-l4-fiasco-ia32-sizes.patch 
-- 
View this message in context: http://www.nabble.com/Patch-for-DICE-that-fix-issue-with-AMD64-host-tp22599858p22599858.html
Sent from the L4 mailing list archive at Nabble.com.





More information about the l4-hackers mailing list