arch,kern: Use CRTP to build open flags tables, not macros.

Change-Id: I433c064c66254c6e082fd6e37b4364576c2fbc3a
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45903
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/arch/arm/SConscript b/src/arch/arm/SConscript
index 2a4f5cd..9da8ff9 100644
--- a/src/arch/arm/SConscript
+++ b/src/arch/arm/SConscript
@@ -73,11 +73,9 @@
     Source('interrupts.cc')
     Source('isa.cc')
     Source('isa_device.cc')
-    Source('linux/linux.cc')
     Source('linux/process.cc')
     Source('linux/se_workload.cc')
     Source('linux/fs_workload.cc')
-    Source('freebsd/freebsd.cc')
     Source('freebsd/fs_workload.cc')
     Source('freebsd/se_workload.cc')
     Source('fs_workload.cc')
diff --git a/src/arch/arm/freebsd/freebsd.cc b/src/arch/arm/freebsd/freebsd.cc
deleted file mode 100644
index a67e347..0000000
--- a/src/arch/arm/freebsd/freebsd.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
- * All rights reserved.
- *
- * This software was developed by the University of Cambridge Computer
- * Laboratory as part of the CTSRD Project, with support from the UK Higher
- * Education Innovation Fund (HEIF).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "arch/arm/freebsd/freebsd.hh"
-
-#include <fcntl.h>
-
-namespace gem5
-{
-
-// open(2) flags translation table
-const std::map<int, int> ArmFreebsd32::openFlagTable = {
-  { ArmFreebsd32::TGT_O_RDONLY,     O_RDONLY },
-  { ArmFreebsd32::TGT_O_WRONLY,     O_WRONLY },
-  { ArmFreebsd32::TGT_O_RDWR,       O_RDWR },
-  { ArmFreebsd32::TGT_O_CREAT,      O_CREAT },
-  { ArmFreebsd32::TGT_O_EXCL,       O_EXCL },
-  { ArmFreebsd32::TGT_O_NOCTTY,     O_NOCTTY },
-  { ArmFreebsd32::TGT_O_TRUNC,      O_TRUNC },
-  { ArmFreebsd32::TGT_O_APPEND,     O_APPEND },
-  { ArmFreebsd32::TGT_O_NONBLOCK,   O_NONBLOCK },
-  { ArmFreebsd32::TGT_O_SYNC,       O_SYNC },
-  { ArmFreebsd32::TGT_FASYNC,       FASYNC },
-#ifdef O_DIRECT
-  { ArmFreebsd32::TGT_O_DIRECT,     O_DIRECT },
-#endif
-  { ArmFreebsd32::TGT_O_DIRECTORY,  O_DIRECTORY },
-  { ArmFreebsd32::TGT_O_NOFOLLOW,   O_NOFOLLOW },
-};
-
-// open(2) flags translation table
-const std::map<int, int> ArmFreebsd64::openFlagTable = {
-  { ArmFreebsd64::TGT_O_RDONLY,     O_RDONLY },
-  { ArmFreebsd64::TGT_O_WRONLY,     O_WRONLY },
-  { ArmFreebsd64::TGT_O_RDWR,       O_RDWR },
-  { ArmFreebsd64::TGT_O_CREAT,      O_CREAT },
-  { ArmFreebsd64::TGT_O_EXCL,       O_EXCL },
-  { ArmFreebsd64::TGT_O_NOCTTY,     O_NOCTTY },
-  { ArmFreebsd64::TGT_O_TRUNC,      O_TRUNC },
-  { ArmFreebsd64::TGT_O_APPEND,     O_APPEND },
-  { ArmFreebsd64::TGT_O_NONBLOCK,   O_NONBLOCK },
-  { ArmFreebsd64::TGT_O_SYNC,       O_SYNC },
-  { ArmFreebsd64::TGT_FASYNC,       FASYNC },
-#ifdef O_DIRECT
-  { ArmFreebsd64::TGT_O_DIRECT,     O_DIRECT },
-#endif
-  { ArmFreebsd64::TGT_O_DIRECTORY,  O_DIRECTORY },
-  { ArmFreebsd64::TGT_O_NOFOLLOW,   O_NOFOLLOW },
-};
-
-} // namespace gem5
diff --git a/src/arch/arm/freebsd/freebsd.hh b/src/arch/arm/freebsd/freebsd.hh
index cc2ffb8..42e6b9f 100644
--- a/src/arch/arm/freebsd/freebsd.hh
+++ b/src/arch/arm/freebsd/freebsd.hh
@@ -36,6 +36,7 @@
 #include <map>
 
 #include "kern/freebsd/freebsd.hh"
+#include "kern/linux/flag_tables.hh"
 #include "sim/byteswap.hh"
 
 namespace gem5
@@ -47,13 +48,9 @@
     static const ByteOrder byteOrder = ByteOrder::little;
 };
 
-class ArmFreebsd32 : public ArmFreebsd
+class ArmFreebsd32 : public ArmFreebsd, public OpenFlagTable<ArmFreebsd32>
 {
   public:
-    /// This table maps the target open() flags to the corresponding
-    /// host open() flags.
-    static const std::map<int, int> openFlagTable;
-
     //@{
     /// Basic ARM FreeBSD types
     typedef uint32_t size_t;
@@ -64,28 +61,28 @@
 
     //@{
     /// open(2) flag values.
-    static const int TGT_O_RDONLY    = 0x00000000; //!< O_RDONLY
-    static const int TGT_O_WRONLY    = 0x00000001; //!< O_WRONLY
-    static const int TGT_O_RDWR      = 0x00000002; //!< O_RDWR
-    static const int TGT_O_CREAT     = 0x00000200; //!< O_CREAT
-    static const int TGT_O_EXCL      = 0x00000800; //!< O_EXCL
-    static const int TGT_O_NOCTTY    = 0x00008000; //!< O_NOCTTY
-    static const int TGT_O_TRUNC     = 0x00000400; //!< O_TRUNC
-    static const int TGT_O_APPEND    = 0x00000008; //!< O_APPEND
-    static const int TGT_O_NONBLOCK  = 0x00000004; //!< O_NONBLOCK
-    static const int TGT_O_SYNC      = 0x00000080; //!< O_SYNC
-    static const int TGT_FASYNC      = 0x00000040; //!< FASYNC
-    static const int TGT_O_DIRECT    = 0x00010000; //!< O_DIRECT
-    static const int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY
-    static const int TGT_O_NOFOLLOW  = 0x00000100; //!< O_NOFOLLOW
-    static const int TGT_O_CLOEXEC   = 0x00100000; //!< O_CLOEXEC
+    static constexpr int TGT_O_RDONLY    = 0x00000000; //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY    = 0x00000001; //!< O_WRONLY
+    static constexpr int TGT_O_RDWR      = 0x00000002; //!< O_RDWR
+    static constexpr int TGT_O_CREAT     = 0x00000200; //!< O_CREAT
+    static constexpr int TGT_O_EXCL      = 0x00000800; //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY    = 0x00008000; //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC     = 0x00000400; //!< O_TRUNC
+    static constexpr int TGT_O_APPEND    = 0x00000008; //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK  = 0x00000004; //!< O_NONBLOCK
+    static constexpr int TGT_O_SYNC      = 0x00000080; //!< O_SYNC
+    static constexpr int TGT_FASYNC      = 0x00000040; //!< FASYNC
+    static constexpr int TGT_O_DIRECT    = 0x00010000; //!< O_DIRECT
+    static constexpr int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY
+    static constexpr int TGT_O_NOFOLLOW  = 0x00000100; //!< O_NOFOLLOW
+    static constexpr int TGT_O_CLOEXEC   = 0x00100000; //!< O_CLOEXEC
     //@}
 
     /// For mmap().
-    static const unsigned TGT_MAP_SHARED    = 0x0001;
-    static const unsigned TGT_MAP_PRIVATE   = 0x0002;
-    static const unsigned TGT_MAP_ANONYMOUS = 0x1000;
-    static const unsigned TGT_MAP_FIXED     = 0x0010;
+    static constexpr unsigned TGT_MAP_SHARED    = 0x0001;
+    static constexpr unsigned TGT_MAP_PRIVATE   = 0x0002;
+    static constexpr unsigned TGT_MAP_ANONYMOUS = 0x1000;
+    static constexpr unsigned TGT_MAP_FIXED     = 0x0010;
 
     /// Limit struct for getrlimit/setrlimit.
     struct rlimit
@@ -207,14 +204,10 @@
     };
 };
 
-class ArmFreebsd64 : public ArmFreebsd
+class ArmFreebsd64 : public ArmFreebsd, public OpenFlagTable<ArmFreebsd64>
 {
   public:
 
-    /// This table maps the target open() flags to the corresponding
-    /// host open() flags.
-    static const std::map<int, int> openFlagTable;
-
     //@{
     /// Basic ARM FreeBSD types
     typedef uint64_t size_t;
@@ -225,28 +218,28 @@
 
     //@{
     /// open(2) flag values.
-    static const int TGT_O_RDONLY    = 0x00000000; //!< O_RDONLY
-    static const int TGT_O_WRONLY    = 0x00000001; //!< O_WRONLY
-    static const int TGT_O_RDWR      = 0x00000002; //!< O_RDWR
-    static const int TGT_O_CREAT     = 0x00000200; //!< O_CREAT
-    static const int TGT_O_EXCL      = 0x00000800; //!< O_EXCL
-    static const int TGT_O_NOCTTY    = 0x00008000; //!< O_NOCTTY
-    static const int TGT_O_TRUNC     = 0x00000400; //!< O_TRUNC
-    static const int TGT_O_APPEND    = 0x00000008; //!< O_APPEND
-    static const int TGT_O_NONBLOCK  = 0x00000004; //!< O_NONBLOCK
-    static const int TGT_O_SYNC      = 0x00000080; //!< O_SYNC
-    static const int TGT_FASYNC      = 0x00000040; //!< FASYNC
-    static const int TGT_O_DIRECT    = 0x00010000; //!< O_DIRECT
-    static const int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY
-    static const int TGT_O_NOFOLLOW  = 0x00000100; //!< O_NOFOLLOW
-    static const int TGT_O_CLOEXEC   = 0x00100000; //!< O_CLOEXEC
+    static constexpr int TGT_O_RDONLY    = 0x00000000; //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY    = 0x00000001; //!< O_WRONLY
+    static constexpr int TGT_O_RDWR      = 0x00000002; //!< O_RDWR
+    static constexpr int TGT_O_CREAT     = 0x00000200; //!< O_CREAT
+    static constexpr int TGT_O_EXCL      = 0x00000800; //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY    = 0x00008000; //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC     = 0x00000400; //!< O_TRUNC
+    static constexpr int TGT_O_APPEND    = 0x00000008; //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK  = 0x00000004; //!< O_NONBLOCK
+    static constexpr int TGT_O_SYNC      = 0x00000080; //!< O_SYNC
+    static constexpr int TGT_FASYNC      = 0x00000040; //!< FASYNC
+    static constexpr int TGT_O_DIRECT    = 0x00010000; //!< O_DIRECT
+    static constexpr int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY
+    static constexpr int TGT_O_NOFOLLOW  = 0x00000100; //!< O_NOFOLLOW
+    static constexpr int TGT_O_CLOEXEC   = 0x00100000; //!< O_CLOEXEC
     //@}
 
     /// For mmap().
-    static const unsigned TGT_MAP_SHARED    = 0x0001;
-    static const unsigned TGT_MAP_PRIVATE   = 0x0002;
-    static const unsigned TGT_MAP_ANONYMOUS = 0x1000;
-    static const unsigned TGT_MAP_FIXED     = 0x0010;
+    static constexpr unsigned TGT_MAP_SHARED    = 0x0001;
+    static constexpr unsigned TGT_MAP_PRIVATE   = 0x0002;
+    static constexpr unsigned TGT_MAP_ANONYMOUS = 0x1000;
+    static constexpr unsigned TGT_MAP_FIXED     = 0x0010;
 
     //@{
     /// For getrusage().
diff --git a/src/arch/arm/linux/linux.cc b/src/arch/arm/linux/linux.cc
deleted file mode 100644
index 1357441..0000000
--- a/src/arch/arm/linux/linux.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2011 ARM Limited
- * All rights reserved
- *
- * The license below extends only to copyright in the software and shall
- * not be construed as granting a license to any other intellectual
- * property including but not limited to intellectual property relating
- * to a hardware implementation of the functionality of the software
- * licensed hereunder.  You may use the software subject to the license
- * terms below provided that you ensure that this notice is replicated
- * unmodified and in its entirety in all distributions of the software,
- * modified or unmodified, in source code or in binary form.
- *
- * Copyright (c) 2003-2005 The Regents of The University of Michigan
- * Copyright (c) 2007-2008 The Florida State University
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "arch/arm/linux/linux.hh"
-
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#define TARGET ArmLinux32
-#include "kern/linux/flag_tables.hh"
-
-#undef TARGET
-#define TARGET ArmLinux64
-#include "kern/linux/flag_tables.hh"
diff --git a/src/arch/arm/linux/linux.hh b/src/arch/arm/linux/linux.hh
index e795165..66c2f9e 100644
--- a/src/arch/arm/linux/linux.hh
+++ b/src/arch/arm/linux/linux.hh
@@ -46,6 +46,7 @@
 
 #include "arch/arm/utility.hh"
 #include "base/compiler.hh"
+#include "kern/linux/flag_tables.hh"
 #include "kern/linux/linux.hh"
 
 namespace gem5
@@ -72,7 +73,7 @@
     }
 };
 
-class ArmLinux32 : public ArmLinux
+class ArmLinux32 : public ArmLinux, public OpenFlagTable<ArmLinux32>
 {
   public:
 
@@ -111,10 +112,6 @@
     static const int TGT_SIGSYS         = 0x00001f;
     static const int TGT_SIGUNUSED      = 0x00001f;
 
-    /// This table maps the target open() flags to the corresponding
-    /// host open() flags.
-    static const std::map<int, int> openFlagTable;
-
     //@{
     /// Basic ARM Linux types
     typedef uint32_t size_t;
@@ -125,42 +122,42 @@
 
     //@{
     /// open(2) flag values.
-    static const int TGT_O_RDONLY    = 000000000; //!< O_RDONLY
-    static const int TGT_O_WRONLY    = 000000001; //!< O_WRONLY
-    static const int TGT_O_RDWR      = 000000002; //!< O_RDWR
-    static const int TGT_O_CREAT     = 000000100; //!< O_CREAT
-    static const int TGT_O_EXCL      = 000000200; //!< O_EXCL
-    static const int TGT_O_NOCTTY    = 000000400; //!< O_NOCTTY
-    static const int TGT_O_TRUNC     = 000001000; //!< O_TRUNC
-    static const int TGT_O_APPEND    = 000002000; //!< O_APPEND
-    static const int TGT_O_NONBLOCK  = 000004000; //!< O_NONBLOCK
-    static const int TGT_O_DSYNC     = 000010000; //!< O_DSYNC
-    static const int TGT_FASYNC      = 000020000; //!< FASYNC
-    static const int TGT_O_DIRECT    = 000200000; //!< O_DIRECT
-    static const int TGT_O_LARGEFILE = 000400000; //!< O_LARGEFILE
-    static const int TGT_O_DIRECTORY = 000040000; //!< O_DIRECTORY
-    static const int TGT_O_NOFOLLOW  = 000100000; //!< O_NOFOLLOW
-    static const int TGT_O_NOATIME   = 001000000; //!< O_NOATIME
-    static const int TGT_O_CLOEXEC   = 002000000; //!< O_NOATIME
-    static const int TGT_O_SYNC      = 004010000; //!< O_SYNC
-    static const int TGT_O_PATH      = 010000000; //!< O_PATH
+    static constexpr int TGT_O_RDONLY    = 000000000; //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY    = 000000001; //!< O_WRONLY
+    static constexpr int TGT_O_RDWR      = 000000002; //!< O_RDWR
+    static constexpr int TGT_O_CREAT     = 000000100; //!< O_CREAT
+    static constexpr int TGT_O_EXCL      = 000000200; //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY    = 000000400; //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC     = 000001000; //!< O_TRUNC
+    static constexpr int TGT_O_APPEND    = 000002000; //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK  = 000004000; //!< O_NONBLOCK
+    static constexpr int TGT_O_DSYNC     = 000010000; //!< O_DSYNC
+    static constexpr int TGT_FASYNC      = 000020000; //!< FASYNC
+    static constexpr int TGT_O_DIRECT    = 000200000; //!< O_DIRECT
+    static constexpr int TGT_O_LARGEFILE = 000400000; //!< O_LARGEFILE
+    static constexpr int TGT_O_DIRECTORY = 000040000; //!< O_DIRECTORY
+    static constexpr int TGT_O_NOFOLLOW  = 000100000; //!< O_NOFOLLOW
+    static constexpr int TGT_O_NOATIME   = 001000000; //!< O_NOATIME
+    static constexpr int TGT_O_CLOEXEC   = 002000000; //!< O_NOATIME
+    static constexpr int TGT_O_SYNC      = 004010000; //!< O_SYNC
+    static constexpr int TGT_O_PATH      = 010000000; //!< O_PATH
     //@}
 
-    static const unsigned TGT_MAP_SHARED        = 0x00001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
-    static const unsigned TGT_MAP_ANON          = 0x00020;
-    static const unsigned TGT_MAP_DENYWRITE     = 0x00800;
-    static const unsigned TGT_MAP_EXECUTABLE    = 0x01000;
-    static const unsigned TGT_MAP_FILE          = 0x00000;
-    static const unsigned TGT_MAP_GROWSDOWN     = 0x00100;
-    static const unsigned TGT_MAP_HUGETLB       = 0x40000;
-    static const unsigned TGT_MAP_LOCKED        = 0x02000;
-    static const unsigned TGT_MAP_NONBLOCK      = 0x10000;
-    static const unsigned TGT_MAP_NORESERVE     = 0x04000;
-    static const unsigned TGT_MAP_POPULATE      = 0x08000;
-    static const unsigned TGT_MAP_STACK         = 0x20000;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x00020;
-    static const unsigned TGT_MAP_FIXED         = 0x00010;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x00001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x00002;
+    static constexpr unsigned TGT_MAP_ANON          = 0x00020;
+    static constexpr unsigned TGT_MAP_DENYWRITE     = 0x00800;
+    static constexpr unsigned TGT_MAP_EXECUTABLE    = 0x01000;
+    static constexpr unsigned TGT_MAP_FILE          = 0x00000;
+    static constexpr unsigned TGT_MAP_GROWSDOWN     = 0x00100;
+    static constexpr unsigned TGT_MAP_HUGETLB       = 0x40000;
+    static constexpr unsigned TGT_MAP_LOCKED        = 0x02000;
+    static constexpr unsigned TGT_MAP_NONBLOCK      = 0x10000;
+    static constexpr unsigned TGT_MAP_NORESERVE     = 0x04000;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x08000;
+    static constexpr unsigned TGT_MAP_STACK         = 0x20000;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x00020;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x00010;
 
     /// For table().
     static const int TBL_SYSINFO = 12;
@@ -297,7 +294,7 @@
     }
 };
 
-class ArmLinux64 : public ArmLinux
+class ArmLinux64 : public ArmLinux, public OpenFlagTable<ArmLinux64>
 {
   public:
 
@@ -336,10 +333,6 @@
     static const int TGT_SIGSYS         = 0x00001f;
     static const int TGT_SIGUNUSED      = 0x00001f;
 
-    /// This table maps the target open() flags to the corresponding
-    /// host open() flags.
-    static const std::map<int, int> openFlagTable;
-
     //@{
     /// Basic ARM Linux types
     typedef uint64_t size_t;
@@ -350,45 +343,42 @@
 
     //@{
     /// open(2) flag values.
-    static const int TGT_O_RDONLY    = 000000000; //!< O_RDONLY
-    static const int TGT_O_WRONLY    = 000000001; //!< O_WRONLY
-    static const int TGT_O_RDWR      = 000000002; //!< O_RDWR
-    static const int TGT_O_CREAT     = 000000100; //!< O_CREAT
-    static const int TGT_O_EXCL      = 000000200; //!< O_EXCL
-    static const int TGT_O_NOCTTY    = 000000400; //!< O_NOCTTY
-    static const int TGT_O_TRUNC     = 000001000; //!< O_TRUNC
-    static const int TGT_O_APPEND    = 000002000; //!< O_APPEND
-    static const int TGT_O_NONBLOCK  = 000004000; //!< O_NONBLOCK
-    static const int TGT_O_DSYNC     = 000010000; //!< O_DSYNC
-    static const int TGT_FASYNC      = 000020000; //!< FASYNC
-    static const int TGT_O_DIRECT    = 000200000; //!< O_DIRECT
-    static const int TGT_O_LARGEFILE = 000400000; //!< O_LARGEFILE
-    static const int TGT_O_DIRECTORY = 000040000; //!< O_DIRECTORY
-    static const int TGT_O_NOFOLLOW  = 000100000; //!< O_NOFOLLOW
-    static const int TGT_O_NOATIME   = 001000000; //!< O_NOATIME
-    static const int TGT_O_CLOEXEC   = 002000000; //!< O_NOATIME
-    static const int TGT_O_SYNC      = 004010000; //!< O_SYNC
-    static const int TGT_O_PATH      = 010000000; //!< O_PATH
+    static constexpr int TGT_O_RDONLY    = 000000000; //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY    = 000000001; //!< O_WRONLY
+    static constexpr int TGT_O_RDWR      = 000000002; //!< O_RDWR
+    static constexpr int TGT_O_CREAT     = 000000100; //!< O_CREAT
+    static constexpr int TGT_O_EXCL      = 000000200; //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY    = 000000400; //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC     = 000001000; //!< O_TRUNC
+    static constexpr int TGT_O_APPEND    = 000002000; //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK  = 000004000; //!< O_NONBLOCK
+    static constexpr int TGT_O_DSYNC     = 000010000; //!< O_DSYNC
+    static constexpr int TGT_FASYNC      = 000020000; //!< FASYNC
+    static constexpr int TGT_O_DIRECT    = 000200000; //!< O_DIRECT
+    static constexpr int TGT_O_LARGEFILE = 000400000; //!< O_LARGEFILE
+    static constexpr int TGT_O_DIRECTORY = 000040000; //!< O_DIRECTORY
+    static constexpr int TGT_O_NOFOLLOW  = 000100000; //!< O_NOFOLLOW
+    static constexpr int TGT_O_NOATIME   = 001000000; //!< O_NOATIME
+    static constexpr int TGT_O_CLOEXEC   = 002000000; //!< O_NOATIME
+    static constexpr int TGT_O_SYNC      = 004010000; //!< O_SYNC
+    static constexpr int TGT_O_PATH      = 010000000; //!< O_PATH
     //@}
 
-    /// For mmap().
-    static const std::map<int, int> mmapFlagTable;
-
-    static const unsigned TGT_MAP_SHARED        = 0x00001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
-    static const unsigned TGT_MAP_ANON          = 0x00020;
-    static const unsigned TGT_MAP_DENYWRITE     = 0x00800;
-    static const unsigned TGT_MAP_EXECUTABLE    = 0x01000;
-    static const unsigned TGT_MAP_FILE          = 0x00000;
-    static const unsigned TGT_MAP_GROWSDOWN     = 0x00100;
-    static const unsigned TGT_MAP_HUGETLB       = 0x40000;
-    static const unsigned TGT_MAP_LOCKED        = 0x02000;
-    static const unsigned TGT_MAP_NONBLOCK      = 0x10000;
-    static const unsigned TGT_MAP_NORESERVE     = 0x04000;
-    static const unsigned TGT_MAP_POPULATE      = 0x08000;
-    static const unsigned TGT_MAP_STACK         = 0x20000;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x00020;
-    static const unsigned TGT_MAP_FIXED         = 0x00010;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x00001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x00002;
+    static constexpr unsigned TGT_MAP_ANON          = 0x00020;
+    static constexpr unsigned TGT_MAP_DENYWRITE     = 0x00800;
+    static constexpr unsigned TGT_MAP_EXECUTABLE    = 0x01000;
+    static constexpr unsigned TGT_MAP_FILE          = 0x00000;
+    static constexpr unsigned TGT_MAP_GROWSDOWN     = 0x00100;
+    static constexpr unsigned TGT_MAP_HUGETLB       = 0x40000;
+    static constexpr unsigned TGT_MAP_LOCKED        = 0x02000;
+    static constexpr unsigned TGT_MAP_NONBLOCK      = 0x10000;
+    static constexpr unsigned TGT_MAP_NORESERVE     = 0x04000;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x08000;
+    static constexpr unsigned TGT_MAP_STACK         = 0x20000;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x00020;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x00010;
 
     //@{
     /// For getrusage().
diff --git a/src/arch/mips/SConscript b/src/arch/mips/SConscript
index 2859a05..e9b0643 100644
--- a/src/arch/mips/SConscript
+++ b/src/arch/mips/SConscript
@@ -36,7 +36,6 @@
     Source('idle_event.cc')
     Source('interrupts.cc')
     Source('isa.cc')
-    Source('linux/linux.cc')
     Source('linux/se_workload.cc')
     Source('pagetable.cc')
     Source('process.cc')
diff --git a/src/arch/mips/linux/linux.cc b/src/arch/mips/linux/linux.cc
deleted file mode 100644
index 8b3c45c..0000000
--- a/src/arch/mips/linux/linux.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2006 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "arch/mips/linux/linux.hh"
-
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#define TARGET MipsLinux
-#include "kern/linux/flag_tables.hh"
diff --git a/src/arch/mips/linux/linux.hh b/src/arch/mips/linux/linux.hh
index 86d49a3..2dab558 100644
--- a/src/arch/mips/linux/linux.hh
+++ b/src/arch/mips/linux/linux.hh
@@ -31,12 +31,13 @@
 
 #include <map>
 
+#include "kern/linux/flag_tables.hh"
 #include "kern/linux/linux.hh"
 
 namespace gem5
 {
 
-class MipsLinux : public Linux
+class MipsLinux : public Linux, public OpenFlagTable<MipsLinux>
 {
   public:
 
@@ -77,48 +78,44 @@
     static const int TGT_SIGXCPU        = 0x00001e;
     static const int TGT_SIGXFSZ        = 0x00001f;
 
-    /// This table maps the target open() flags to the corresponding
-    /// host open() flags.
-    static const std::map<int, int> openFlagTable;
-
     //@{
     /// open(2) flag values.
-    static const int TGT_O_RDONLY       = 0x00000000;   //!< O_RDONLY
-    static const int TGT_O_WRONLY       = 0x00000001;   //!< O_WRONLY
-    static const int TGT_O_RDWR         = 0x00000002;   //!< O_RDWR
-    static const int TGT_O_CREAT        = 0x00000100;   //!< O_CREAT
-    static const int TGT_O_EXCL         = 0x00000400;   //!< O_EXCL
-    static const int TGT_O_NOCTTY       = 0x00000800;   //!< O_NOCTTY
-    static const int TGT_O_TRUNC        = 0x00000200;   //!< O_TRUNC
-    static const int TGT_O_APPEND       = 0x00000008;   //!< O_APPEND
-    static const int TGT_O_NONBLOCK     = 0x00000080;   //!< O_NONBLOCK
-    static const int TGT_O_DSYNC        = 0x00000010;   //!< O_DSYNC
-    static const int TGT_FASYNC         = 0x00001000;   //!< O_FASYNC
-    static const int TGT_O_DIRECT       = 0x00008000;   //!< O_DIRECT
-    static const int TGT_O_LARGEFILE    = 0x00002000;   //!< O_LARGEFILE
-    static const int TGT_O_DIRECTORY    = 0x00010000;   //!< O_DIRECTORY
-    static const int TGT_O_NOFOLLOW     = 0x00020000;   //!< O_NOFOLLOW
-    static const int TGT_O_NOATIME      = 0x00040000;   //!< O_NOATIME
-    static const int TGT_O_CLOEXEC      = 0x00080000;   //!< O_CLOEXEC
-    static const int TGT_O_SYNC         = 0x00004010;   //!< O_SYNC
-    static const int TGT_O_PATH         = 0x00200000;   //!< O_PATH
+    static constexpr int TGT_O_RDONLY       = 0x00000000;   //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY       = 0x00000001;   //!< O_WRONLY
+    static constexpr int TGT_O_RDWR         = 0x00000002;   //!< O_RDWR
+    static constexpr int TGT_O_CREAT        = 0x00000100;   //!< O_CREAT
+    static constexpr int TGT_O_EXCL         = 0x00000400;   //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY       = 0x00000800;   //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC        = 0x00000200;   //!< O_TRUNC
+    static constexpr int TGT_O_APPEND       = 0x00000008;   //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK     = 0x00000080;   //!< O_NONBLOCK
+    static constexpr int TGT_O_DSYNC        = 0x00000010;   //!< O_DSYNC
+    static constexpr int TGT_FASYNC         = 0x00001000;   //!< O_FASYNC
+    static constexpr int TGT_O_DIRECT       = 0x00008000;   //!< O_DIRECT
+    static constexpr int TGT_O_LARGEFILE    = 0x00002000;   //!< O_LARGEFILE
+    static constexpr int TGT_O_DIRECTORY    = 0x00010000;   //!< O_DIRECTORY
+    static constexpr int TGT_O_NOFOLLOW     = 0x00020000;   //!< O_NOFOLLOW
+    static constexpr int TGT_O_NOATIME      = 0x00040000;   //!< O_NOATIME
+    static constexpr int TGT_O_CLOEXEC      = 0x00080000;   //!< O_CLOEXEC
+    static constexpr int TGT_O_SYNC         = 0x00004010;   //!< O_SYNC
+    static constexpr int TGT_O_PATH         = 0x00200000;   //!< O_PATH
     //@}
 
-    static const unsigned TGT_MAP_SHARED        = 0x00001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
-    static const unsigned TGT_MAP_ANON          = 0x00800;
-    static const unsigned TGT_MAP_DENYWRITE     = 0x02000;
-    static const unsigned TGT_MAP_EXECUTABLE    = 0x04000;
-    static const unsigned TGT_MAP_FILE          = 0x00000;
-    static const unsigned TGT_MAP_GROWSDOWN     = 0x01000;
-    static const unsigned TGT_MAP_HUGETLB       = 0x80000;
-    static const unsigned TGT_MAP_LOCKED        = 0x08000;
-    static const unsigned TGT_MAP_NONBLOCK      = 0x20000;
-    static const unsigned TGT_MAP_NORESERVE     = 0x00400;
-    static const unsigned TGT_MAP_POPULATE      = 0x10000;
-    static const unsigned TGT_MAP_STACK         = 0x40000;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x00800;
-    static const unsigned TGT_MAP_FIXED         = 0x00010;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x00001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x00002;
+    static constexpr unsigned TGT_MAP_ANON          = 0x00800;
+    static constexpr unsigned TGT_MAP_DENYWRITE     = 0x02000;
+    static constexpr unsigned TGT_MAP_EXECUTABLE    = 0x04000;
+    static constexpr unsigned TGT_MAP_FILE          = 0x00000;
+    static constexpr unsigned TGT_MAP_GROWSDOWN     = 0x01000;
+    static constexpr unsigned TGT_MAP_HUGETLB       = 0x80000;
+    static constexpr unsigned TGT_MAP_LOCKED        = 0x08000;
+    static constexpr unsigned TGT_MAP_NONBLOCK      = 0x20000;
+    static constexpr unsigned TGT_MAP_NORESERVE     = 0x00400;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x10000;
+    static constexpr unsigned TGT_MAP_STACK         = 0x40000;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x00800;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x00010;
 
     //@{
     /// For getsysinfo().
diff --git a/src/arch/power/SConscript b/src/arch/power/SConscript
index 74b2c81..72979f5 100644
--- a/src/arch/power/SConscript
+++ b/src/arch/power/SConscript
@@ -42,7 +42,6 @@
     Source('insts/floating.cc')
     Source('insts/condition.cc')
     Source('insts/static_inst.cc')
-    Source('linux/linux.cc')
     Source('linux/se_workload.cc')
     Source('isa.cc')
     Source('pagetable.cc')
diff --git a/src/arch/power/linux/linux.cc b/src/arch/power/linux/linux.cc
deleted file mode 100644
index 7d170ec..0000000
--- a/src/arch/power/linux/linux.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2003-2005 The Regents of The University of Michigan
- * Copyright (c) 2009 The University of Edinburgh
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "arch/power/linux/linux.hh"
-
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#define TARGET PowerLinux
-#include "kern/linux/flag_tables.hh"
diff --git a/src/arch/power/linux/linux.hh b/src/arch/power/linux/linux.hh
index effdf15..02a45ef 100644
--- a/src/arch/power/linux/linux.hh
+++ b/src/arch/power/linux/linux.hh
@@ -35,6 +35,7 @@
 #include "arch/power/isa.hh"
 #include "arch/power/regs/int.hh"
 #include "cpu/thread_context.hh"
+#include "kern/linux/flag_tables.hh"
 #include "kern/linux/linux.hh"
 
 namespace gem5
@@ -44,7 +45,7 @@
  * This works for a 2.6.15 kernel.
  */
 
-class PowerLinux : public Linux
+class PowerLinux : public Linux, public OpenFlagTable<PowerLinux>
 {
   public:
 
@@ -144,48 +145,44 @@
     static const int TGT_SIGSYS         = 0x00001f;
     static const int TGT_SIGUNUSED      = 0x00001f;
 
-    /// This table maps the target open() flags to the corresponding
-    /// host open() flags.
-    static const std::map<int, int> openFlagTable;
-
     //@{
     /// open(2) flag values.
-    static const int TGT_O_RDONLY    = 000000000; //!< O_RDONLY
-    static const int TGT_O_WRONLY    = 000000001; //!< O_WRONLY
-    static const int TGT_O_RDWR      = 000000002; //!< O_RDWR
-    static const int TGT_O_CREAT     = 000000100; //!< O_CREAT
-    static const int TGT_O_EXCL      = 000000200; //!< O_EXCL
-    static const int TGT_O_NOCTTY    = 000000400; //!< O_NOCTTY
-    static const int TGT_O_TRUNC     = 000001000; //!< O_TRUNC
-    static const int TGT_O_APPEND    = 000002000; //!< O_APPEND
-    static const int TGT_O_NONBLOCK  = 000004000; //!< O_NONBLOCK
-    static const int TGT_O_DSYNC     = 000010000; //!< O_DSYNC
-    static const int TGT_FASYNC      = 000020000; //!< FASYNC
-    static const int TGT_O_DIRECT    = 000400000; //!< O_DIRECT
-    static const int TGT_O_LARGEFILE = 000200000; //!< O_LARGEFILE
-    static const int TGT_O_DIRECTORY = 000040000; //!< O_DIRECTORY
-    static const int TGT_O_NOFOLLOW  = 000100000; //!< O_NOFOLLOW
-    static const int TGT_O_NOATIME   = 001000000; //!< O_NOATIME
-    static const int TGT_O_CLOEXEC   = 002000000; //!< O_CLOEXEC
-    static const int TGT_O_SYNC      = 004010000; //!< O_SYNC
-    static const int TGT_O_PATH      = 010000000; //!< O_PATH
+    static constexpr int TGT_O_RDONLY    = 000000000; //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY    = 000000001; //!< O_WRONLY
+    static constexpr int TGT_O_RDWR      = 000000002; //!< O_RDWR
+    static constexpr int TGT_O_CREAT     = 000000100; //!< O_CREAT
+    static constexpr int TGT_O_EXCL      = 000000200; //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY    = 000000400; //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC     = 000001000; //!< O_TRUNC
+    static constexpr int TGT_O_APPEND    = 000002000; //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK  = 000004000; //!< O_NONBLOCK
+    static constexpr int TGT_O_DSYNC     = 000010000; //!< O_DSYNC
+    static constexpr int TGT_FASYNC      = 000020000; //!< FASYNC
+    static constexpr int TGT_O_DIRECT    = 000400000; //!< O_DIRECT
+    static constexpr int TGT_O_LARGEFILE = 000200000; //!< O_LARGEFILE
+    static constexpr int TGT_O_DIRECTORY = 000040000; //!< O_DIRECTORY
+    static constexpr int TGT_O_NOFOLLOW  = 000100000; //!< O_NOFOLLOW
+    static constexpr int TGT_O_NOATIME   = 001000000; //!< O_NOATIME
+    static constexpr int TGT_O_CLOEXEC   = 002000000; //!< O_CLOEXEC
+    static constexpr int TGT_O_SYNC      = 004010000; //!< O_SYNC
+    static constexpr int TGT_O_PATH      = 010000000; //!< O_PATH
     //@}
 
-    static const unsigned TGT_MAP_SHARED        = 0x00001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
-    static const unsigned TGT_MAP_ANON          = 0x00020;
-    static const unsigned TGT_MAP_DENYWRITE     = 0x00800;
-    static const unsigned TGT_MAP_EXECUTABLE    = 0x01000;
-    static const unsigned TGT_MAP_FILE          = 0x00000;
-    static const unsigned TGT_MAP_GROWSDOWN     = 0x00100;
-    static const unsigned TGT_MAP_HUGETLB       = 0x40000;
-    static const unsigned TGT_MAP_LOCKED        = 0x00080;
-    static const unsigned TGT_MAP_NONBLOCK      = 0x10000;
-    static const unsigned TGT_MAP_NORESERVE     = 0x00040;
-    static const unsigned TGT_MAP_POPULATE      = 0x08000;
-    static const unsigned TGT_MAP_STACK         = 0x20000;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x00020;
-    static const unsigned TGT_MAP_FIXED         = 0x00010;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x00001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x00002;
+    static constexpr unsigned TGT_MAP_ANON          = 0x00020;
+    static constexpr unsigned TGT_MAP_DENYWRITE     = 0x00800;
+    static constexpr unsigned TGT_MAP_EXECUTABLE    = 0x01000;
+    static constexpr unsigned TGT_MAP_FILE          = 0x00000;
+    static constexpr unsigned TGT_MAP_GROWSDOWN     = 0x00100;
+    static constexpr unsigned TGT_MAP_HUGETLB       = 0x40000;
+    static constexpr unsigned TGT_MAP_LOCKED        = 0x00080;
+    static constexpr unsigned TGT_MAP_NONBLOCK      = 0x10000;
+    static constexpr unsigned TGT_MAP_NORESERVE     = 0x00040;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x08000;
+    static constexpr unsigned TGT_MAP_STACK         = 0x20000;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x00020;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x00010;
 
     //@{
     /// ioctl() command codes.
diff --git a/src/arch/riscv/SConscript b/src/arch/riscv/SConscript
index 291499c..33844ea 100644
--- a/src/arch/riscv/SConscript
+++ b/src/arch/riscv/SConscript
@@ -58,7 +58,6 @@
     Source('tlb.cc')
 
     Source('linux/se_workload.cc')
-    Source('linux/linux.cc')
     Source('linux/fs_workload.cc')
 
     Source('bare_metal/fs_workload.cc')
diff --git a/src/arch/riscv/linux/linux.cc b/src/arch/riscv/linux/linux.cc
deleted file mode 100644
index 512e392..0000000
--- a/src/arch/riscv/linux/linux.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2006 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "arch/riscv/linux/linux.hh"
-
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#define TARGET RiscvLinux64
-#include "kern/linux/flag_tables.hh"
-
-#undef TARGET
-#define TARGET RiscvLinux32
-#include "kern/linux/flag_tables.hh"
diff --git a/src/arch/riscv/linux/linux.hh b/src/arch/riscv/linux/linux.hh
index 30d6dcc..9c99d1b 100644
--- a/src/arch/riscv/linux/linux.hh
+++ b/src/arch/riscv/linux/linux.hh
@@ -32,6 +32,7 @@
 #include <map>
 
 #include "arch/riscv/utility.hh"
+#include "kern/linux/flag_tables.hh"
 #include "kern/linux/linux.hh"
 
 namespace gem5
@@ -43,7 +44,7 @@
     static const ByteOrder byteOrder = ByteOrder::little;
 };
 
-class RiscvLinux64 : public RiscvLinux
+class RiscvLinux64 : public RiscvLinux, public OpenFlagTable<RiscvLinux64>
 {
   public:
     static const int TGT_SIGHUP         =  1;
@@ -82,44 +83,40 @@
     static const int TGT_SIGUSR1        = 30;
     static const int TGT_SIGUSR2        = 31;
 
-    /// This table maps the target open() flags to the corresponding
-    /// host open() flags.
-    static const std::map<int, int> openFlagTable;
-
     //@{
     /// open(2) flag values.
-    static const int TGT_O_RDONLY       = 0x000000; //!< O_RDONLY
-    static const int TGT_O_WRONLY       = 0x000001; //!< O_WRONLY
-    static const int TGT_O_RDWR         = 0x000002; //!< O_RDWR
-    static const int TGT_O_CREAT        = 0x000040; //!< O_CREAT
-    static const int TGT_O_EXCL         = 0x000080; //!< O_EXCL
-    static const int TGT_O_NOCTTY       = 0x000100; //!< O_NOCTTY
-    static const int TGT_O_TRUNC        = 0x000200; //!< O_TRUNC
-    static const int TGT_O_APPEND       = 0x000400; //!< O_APPEND
-    static const int TGT_O_NONBLOCK     = 0x000800; //!< O_NONBLOCK
-    static const int TGT_O_SYNC         = 0x001000; //!< O_SYNC
-    static const int TGT_FSYNC          = 0x001000; //!< FSYNC
-    static const int TGT_FASYNC         = 0x008000; //!< FASYNC
+    static constexpr int TGT_O_RDONLY       = 0x000000; //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY       = 0x000001; //!< O_WRONLY
+    static constexpr int TGT_O_RDWR         = 0x000002; //!< O_RDWR
+    static constexpr int TGT_O_CREAT        = 0x000040; //!< O_CREAT
+    static constexpr int TGT_O_EXCL         = 0x000080; //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY       = 0x000100; //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC        = 0x000200; //!< O_TRUNC
+    static constexpr int TGT_O_APPEND       = 0x000400; //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK     = 0x000800; //!< O_NONBLOCK
+    static constexpr int TGT_O_SYNC         = 0x001000; //!< O_SYNC
+    static constexpr int TGT_FSYNC          = 0x001000; //!< FSYNC
+    static constexpr int TGT_FASYNC         = 0x008000; //!< FASYNC
     // The following are not present in riscv64-unknown-elf <fcntl.h>
-    static const int TGT_O_DSYNC        = 0x010000; //!< O_DSYNC
-    static const int TGT_O_CLOEXEC      = 0x040000; //!< O_CLOEXEC
-    static const int TGT_O_NOINHERIT    = 0x040000; //!< O_NOINHERIT
-    static const int TGT_O_DIRECT       = 0x080000; //!< O_DIRECT
-    static const int TGT_O_NOFOLLOW     = 0x100000; //!< O_NOFOLLOW
-    static const int TGT_O_DIRECTORY    = 0x200000; //!< O_DIRECTORY
+    static constexpr int TGT_O_DSYNC        = 0x010000; //!< O_DSYNC
+    static constexpr int TGT_O_CLOEXEC      = 0x040000; //!< O_CLOEXEC
+    static constexpr int TGT_O_NOINHERIT    = 0x040000; //!< O_NOINHERIT
+    static constexpr int TGT_O_DIRECT       = 0x080000; //!< O_DIRECT
+    static constexpr int TGT_O_NOFOLLOW     = 0x100000; //!< O_NOFOLLOW
+    static constexpr int TGT_O_DIRECTORY    = 0x200000; //!< O_DIRECTORY
     // The following are not defined by riscv64-unknown-elf
-    static const int TGT_O_LARGEFILE    = 0x020000; //!< O_LARGEFILE
-    static const int TGT_O_NOATIME      = 0x800000; //!< O_NOATIME
-    static const int TGT_O_PATH         = 0x400000; //!< O_PATH
+    static constexpr int TGT_O_LARGEFILE    = 0x020000; //!< O_LARGEFILE
+    static constexpr int TGT_O_NOATIME      = 0x800000; //!< O_NOATIME
+    static constexpr int TGT_O_PATH         = 0x400000; //!< O_PATH
     //@}
 
     // Only defined in riscv-unknown-elf for proxy kernel and not linux kernel
-    static const unsigned TGT_MAP_SHARED        = 0x0001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x0002;
-    static const unsigned TGT_MAP_FIXED         = 0x0010;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x0020;
-    static const unsigned TGT_MAP_POPULATE      = 0x1000;
-    static const unsigned TGT_MREMAP_FIXED      = 0x0020;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x0001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x0002;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x0010;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x0020;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x1000;
+    static constexpr unsigned TGT_MREMAP_FIXED      = 0x0020;
 
     typedef int64_t time_t;
     typedef uint64_t dev_t;
@@ -212,7 +209,7 @@
     }
 };
 
-class RiscvLinux32 : public RiscvLinux
+class RiscvLinux32 : public RiscvLinux, public OpenFlagTable<RiscvLinux32>
 {
   public:
     static const int TGT_SIGHUP         =  1;
@@ -251,46 +248,42 @@
     static const int TGT_SIGUSR1        = 30;
     static const int TGT_SIGUSR2        = 31;
 
-    /// This table maps the target open() flags to the corresponding
-    /// host open() flags.
-    static const std::map<int, int> openFlagTable;
-
     //@{
     /// open(2) flag values.
     // The following values match newlib 3.0.0.
     // Note that glibc has different values.
-    static const int TGT_O_RDONLY       = 0x000000; //!< O_RDONLY
-    static const int TGT_O_WRONLY       = 0x000001; //!< O_WRONLY
-    static const int TGT_O_RDWR         = 0x000002; //!< O_RDWR
-    static const int TGT_O_CREAT        = 0x000200; //!< O_CREAT
-    static const int TGT_O_EXCL         = 0x000800; //!< O_EXCL
-    static const int TGT_O_NOCTTY       = 0x008000; //!< O_NOCTTY
-    static const int TGT_O_TRUNC        = 0x000400; //!< O_TRUNC
-    static const int TGT_O_APPEND       = 0x000008; //!< O_APPEND
-    static const int TGT_O_NONBLOCK     = 0x004000; //!< O_NONBLOCK
-    static const int TGT_O_SYNC         = 0x002000; //!< O_SYNC
-    static const int TGT_FSYNC          = 0x002000; //!< FSYNC
-    static const int TGT_FASYNC         = 0x000040; //!< FASYNC
+    static constexpr int TGT_O_RDONLY       = 0x000000; //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY       = 0x000001; //!< O_WRONLY
+    static constexpr int TGT_O_RDWR         = 0x000002; //!< O_RDWR
+    static constexpr int TGT_O_CREAT        = 0x000200; //!< O_CREAT
+    static constexpr int TGT_O_EXCL         = 0x000800; //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY       = 0x008000; //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC        = 0x000400; //!< O_TRUNC
+    static constexpr int TGT_O_APPEND       = 0x000008; //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK     = 0x004000; //!< O_NONBLOCK
+    static constexpr int TGT_O_SYNC         = 0x002000; //!< O_SYNC
+    static constexpr int TGT_FSYNC          = 0x002000; //!< FSYNC
+    static constexpr int TGT_FASYNC         = 0x000040; //!< FASYNC
     // The following are not present in riscv32-unknown-elf <fcntl.h>
-    static const int TGT_O_DSYNC        = 0x010000; //!< O_DSYNC
-    static const int TGT_O_CLOEXEC      = 0x040000; //!< O_CLOEXEC
-    static const int TGT_O_NOINHERIT    = 0x040000; //!< O_NOINHERIT
-    static const int TGT_O_DIRECT       = 0x080000; //!< O_DIRECT
-    static const int TGT_O_NOFOLLOW     = 0x100000; //!< O_NOFOLLOW
-    static const int TGT_O_DIRECTORY    = 0x200000; //!< O_DIRECTORY
+    static constexpr int TGT_O_DSYNC        = 0x010000; //!< O_DSYNC
+    static constexpr int TGT_O_CLOEXEC      = 0x040000; //!< O_CLOEXEC
+    static constexpr int TGT_O_NOINHERIT    = 0x040000; //!< O_NOINHERIT
+    static constexpr int TGT_O_DIRECT       = 0x080000; //!< O_DIRECT
+    static constexpr int TGT_O_NOFOLLOW     = 0x100000; //!< O_NOFOLLOW
+    static constexpr int TGT_O_DIRECTORY    = 0x200000; //!< O_DIRECTORY
     // The following are not defined by riscv32-unknown-elf
-    static const int TGT_O_LARGEFILE    = 0x020000; //!< O_LARGEFILE
-    static const int TGT_O_NOATIME      = 0x800000; //!< O_NOATIME
-    static const int TGT_O_PATH         = 0x400000; //!< O_PATH
+    static constexpr int TGT_O_LARGEFILE    = 0x020000; //!< O_LARGEFILE
+    static constexpr int TGT_O_NOATIME      = 0x800000; //!< O_NOATIME
+    static constexpr int TGT_O_PATH         = 0x400000; //!< O_PATH
     //@}
 
     // Only defined in riscv-unknown-elf for proxy kernel and not linux kernel
-    static const unsigned TGT_MAP_SHARED        = 0x0001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x0002;
-    static const unsigned TGT_MAP_FIXED         = 0x0010;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x0020;
-    static const unsigned TGT_MAP_POPULATE      = 0x1000;
-    static const unsigned TGT_MREMAP_FIXED      = 0x0020;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x0001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x0002;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x0010;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x0020;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x1000;
+    static constexpr unsigned TGT_MREMAP_FIXED      = 0x0020;
 
     // Newlib 3.0.0 defaults to 64-bits for time_t.
     // Currently time_t in glibc for riscv32 is 32-bits, but will be changed.
diff --git a/src/arch/sparc/SConscript b/src/arch/sparc/SConscript
index 0098781..d17caa9 100644
--- a/src/arch/sparc/SConscript
+++ b/src/arch/sparc/SConscript
@@ -34,7 +34,6 @@
     Source('faults.cc')
     Source('fs_workload.cc')
     Source('isa.cc')
-    Source('linux/linux.cc')
     Source('linux/se_workload.cc')
     Source('linux/syscalls.cc')
     Source('nativetrace.cc')
@@ -42,7 +41,6 @@
     Source('process.cc')
     Source('remote_gdb.cc')
     Source('se_workload.cc')
-    Source('solaris/solaris.cc')
     Source('tlb.cc')
     Source('ua2005.cc')
 
diff --git a/src/arch/sparc/linux/linux.cc b/src/arch/sparc/linux/linux.cc
deleted file mode 100644
index d67d9ee..0000000
--- a/src/arch/sparc/linux/linux.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2003-2005 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "arch/sparc/linux/linux.hh"
-
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#define TARGET SparcLinux
-#include "kern/linux/flag_tables.hh"
diff --git a/src/arch/sparc/linux/linux.hh b/src/arch/sparc/linux/linux.hh
index 3a70985..0912de2 100644
--- a/src/arch/sparc/linux/linux.hh
+++ b/src/arch/sparc/linux/linux.hh
@@ -35,12 +35,13 @@
 #include "arch/sparc/regs/int.hh"
 #include "arch/sparc/regs/misc.hh"
 #include "cpu/thread_context.hh"
+#include "kern/linux/flag_tables.hh"
 #include "kern/linux/linux.hh"
 
 namespace gem5
 {
 
-class SparcLinux : public Linux
+class SparcLinux : public Linux, public OpenFlagTable<SparcLinux>
 {
   public:
 
@@ -129,45 +130,43 @@
     static const int TGT_SIGUSR1        = 0x00001e;
     static const int TGT_SIGUSR2        = 0x00001f;
 
-    static const std::map<int, int> openFlagTable;
+    static constexpr int TGT_O_RDONLY    = 0x00000000;  //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY    = 0x00000001;  //!< O_WRONLY
+    static constexpr int TGT_O_RDWR      = 0x00000002;  //!< O_RDWR
+    static constexpr int TGT_O_NONBLOCK  = 0x00004000;  //!< O_NONBLOCK
+    static constexpr int TGT_O_APPEND    = 0x00000008;  //!< O_APPEND
+    static constexpr int TGT_FASYNC      = 0x00000040;  //!< FASYNC
+    static constexpr int TGT_O_CREAT     = 0x00000200;  //!< O_CREAT
+    static constexpr int TGT_O_TRUNC     = 0x00000400;  //!< O_TRUNC
+    static constexpr int TGT_O_EXCL      = 0x00000800;  //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY    = 0x00008000;  //!< O_NOCTTY
+    static constexpr int TGT_O_DSYNC     = 0x00002000;  //!< O_DSYNC
+    static constexpr int TGT_O_LARGEFILE = 0x00040000;  //!< O_LARGEFILE
+    static constexpr int TGT_O_DIRECT    = 0x00100000;  //!< O_DIRECT
+    static constexpr int TGT_O_NOATIME   = 0x00200000;  //!< O_NOATIME
+    static constexpr int TGT_O_CLOEXEC   = 0x00400000;  //!< O_CLOEXEC
+    static constexpr int TGT_O_SYNC      = 0x00802000;  //!< O_SYNC
+    static constexpr int TGT_O_PATH      = 0x01000000;  //!< O_PATH
 
-    static const int TGT_O_RDONLY       = 0x00000000;   //!< O_RDONLY
-    static const int TGT_O_WRONLY       = 0x00000001;   //!< O_WRONLY
-    static const int TGT_O_RDWR         = 0x00000002;   //!< O_RDWR
-    static const int TGT_O_NONBLOCK     = 0x00004000;   //!< O_NONBLOCK
-    static const int TGT_O_APPEND       = 0x00000008;   //!< O_APPEND
-    static const int TGT_FASYNC         = 0x00000040;   //!< FASYNC
-    static const int TGT_O_CREAT        = 0x00000200;   //!< O_CREAT
-    static const int TGT_O_TRUNC        = 0x00000400;   //!< O_TRUNC
-    static const int TGT_O_EXCL         = 0x00000800;   //!< O_EXCL
-    static const int TGT_O_NOCTTY       = 0x00008000;   //!< O_NOCTTY
-    static const int TGT_O_DSYNC        = 0x00002000;   //!< O_DSYNC
-    static const int TGT_O_LARGEFILE    = 0x00040000;   //!< O_LARGEFILE
-    static const int TGT_O_DIRECT       = 0x00100000;   //!< O_DIRECT
-    static const int TGT_O_NOATIME      = 0x00200000;   //!< O_NOATIME
-    static const int TGT_O_CLOEXEC      = 0x00400000;   //!< O_CLOEXEC
-    static const int TGT_O_SYNC         = 0x00802000;   //!< O_SYNC
-    static const int TGT_O_PATH         = 0x01000000;   //!< O_PATH
+    static constexpr int TGT_O_DIRECTORY = 000200000;   //!< O_DIRECTORY
+    static constexpr int TGT_O_NOFOLLOW  = 000400000;   //!< O_NOFOLLOW
 
-    static const int TGT_O_DIRECTORY    = 000200000;   //!< O_DIRECTORY
-    static const int TGT_O_NOFOLLOW     = 000400000;   //!< O_NOFOLLOW
-
-    static const unsigned TGT_MAP_SHARED        = 0x00001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
-    static const unsigned TGT_MAP_ANON          = 0x00020;
-    static const unsigned TGT_MAP_DENYWRITE     = 0x00800;
-    static const unsigned TGT_MAP_EXECUTABLE    = 0x01000;
-    static const unsigned TGT_MAP_FILE          = 0x00000;
-    static const unsigned TGT_MAP_GROWSDOWN     = 0x00200;
-    static const unsigned TGT_MAP_HUGETLB       = 0x40000;
-    static const unsigned TGT_MAP_LOCKED        = 0x00100;
-    static const unsigned TGT_MAP_NONBLOCK      = 0x10000;
-    static const unsigned TGT_MAP_NORESERVE     = 0x00040;
-    static const unsigned TGT_MAP_POPULATE      = 0x08000;
-    static const unsigned TGT_MAP_STACK         = 0x20000;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x00020;
-    static const unsigned TGT_MAP_FIXED         = 0x00010;
-    static const unsigned TGT_MAP_INHERIT       = 0x00080;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x00001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x00002;
+    static constexpr unsigned TGT_MAP_ANON          = 0x00020;
+    static constexpr unsigned TGT_MAP_DENYWRITE     = 0x00800;
+    static constexpr unsigned TGT_MAP_EXECUTABLE    = 0x01000;
+    static constexpr unsigned TGT_MAP_FILE          = 0x00000;
+    static constexpr unsigned TGT_MAP_GROWSDOWN     = 0x00200;
+    static constexpr unsigned TGT_MAP_HUGETLB       = 0x40000;
+    static constexpr unsigned TGT_MAP_LOCKED        = 0x00100;
+    static constexpr unsigned TGT_MAP_NONBLOCK      = 0x10000;
+    static constexpr unsigned TGT_MAP_NORESERVE     = 0x00040;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x08000;
+    static constexpr unsigned TGT_MAP_STACK         = 0x20000;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x00020;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x00010;
+    static constexpr unsigned TGT_MAP_INHERIT       = 0x00080;
 
     struct tgt_sysinfo
     {
diff --git a/src/arch/sparc/solaris/solaris.cc b/src/arch/sparc/solaris/solaris.cc
deleted file mode 100644
index d05fb49..0000000
--- a/src/arch/sparc/solaris/solaris.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2003-2005 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "arch/sparc/solaris/solaris.hh"
-
-#include <fcntl.h>
-#include <sys/mman.h>
-
-namespace gem5
-{
-
-// open(2) flags translation table
-const std::map<int, int> SparcSolaris::openFlagTable = {
-#ifdef _MSC_VER
-  { SparcSolaris::TGT_O_RDONLY, _O_RDONLY },
-  { SparcSolaris::TGT_O_WRONLY, _O_WRONLY },
-  { SparcSolaris::TGT_O_RDWR,   _O_RDWR },
-  { SparcSolaris::TGT_O_APPEND, _O_APPEND },
-  { SparcSolaris::TGT_O_CREAT,  _O_CREAT },
-  { SparcSolaris::TGT_O_TRUNC,  _O_TRUNC },
-  { SparcSolaris::TGT_O_EXCL,   _O_EXCL },
-#ifdef _O_NONBLOCK
-  { SparcSolaris::TGT_O_NONBLOCK,       _O_NONBLOCK },
-  { SparcSolaris::TGT_O_NDELAY  ,       _O_NONBLOCK },
-#endif
-#ifdef _O_NOCTTY
-  { SparcSolaris::TGT_O_NOCTTY, _O_NOCTTY },
-#endif
-#ifdef _O_SYNC
-  { SparcSolaris::TGT_O_SYNC,   _O_SYNC },
-  { SparcSolaris::TGT_O_DSYNC,  _O_SYNC },
-  { SparcSolaris::TGT_O_RSYNC,  _O_SYNC },
-#endif
-#else /* !_MSC_VER */
-  { SparcSolaris::TGT_O_RDONLY, O_RDONLY },
-  { SparcSolaris::TGT_O_WRONLY, O_WRONLY },
-  { SparcSolaris::TGT_O_RDWR,   O_RDWR },
-  { SparcSolaris::TGT_O_APPEND, O_APPEND },
-  { SparcSolaris::TGT_O_CREAT,  O_CREAT },
-  { SparcSolaris::TGT_O_TRUNC,  O_TRUNC },
-  { SparcSolaris::TGT_O_EXCL,   O_EXCL },
-  { SparcSolaris::TGT_O_NONBLOCK,       O_NONBLOCK },
-  { SparcSolaris::TGT_O_NDELAY  ,       O_NONBLOCK },
-  { SparcSolaris::TGT_O_NOCTTY, O_NOCTTY },
-#ifdef O_SYNC
-  { SparcSolaris::TGT_O_SYNC,   O_SYNC },
-  { SparcSolaris::TGT_O_DSYNC,  O_SYNC },
-  { SparcSolaris::TGT_O_RSYNC,  O_SYNC },
-#endif
-#endif /* _MSC_VER */
-};
-
-// mmap(2) flags translation table
-const std::map<int, int> SparcSolaris::mmapFlagTable = {
-  { TGT_MAP_SHARED, MAP_SHARED },
-  { TGT_MAP_PRIVATE, MAP_PRIVATE },
-  { TGT_MAP_ANON, MAP_ANON },
-  { TGT_MAP_DENYWRITE, MAP_DENYWRITE },
-  { TGT_MAP_EXECUTABLE, MAP_EXECUTABLE },
-  { TGT_MAP_FILE, MAP_FILE },
-  { TGT_MAP_GROWSDOWN, MAP_GROWSDOWN },
-  { TGT_MAP_HUGETLB, MAP_HUGETLB },
-  { TGT_MAP_LOCKED, MAP_LOCKED },
-  { TGT_MAP_NONBLOCK, MAP_NONBLOCK },
-  { TGT_MAP_NORESERVE, MAP_NORESERVE },
-  { TGT_MAP_POPULATE, MAP_POPULATE },
-  { TGT_MAP_STACK, MAP_STACK },
-  { TGT_MAP_ANONYMOUS, MAP_ANONYMOUS },
-  { TGT_MAP_FIXED, MAP_FIXED },
-};
-
-} // namespace gem5
diff --git a/src/arch/sparc/solaris/solaris.hh b/src/arch/sparc/solaris/solaris.hh
index a90d6eb..7e8b4d6 100644
--- a/src/arch/sparc/solaris/solaris.hh
+++ b/src/arch/sparc/solaris/solaris.hh
@@ -31,55 +31,50 @@
 
 #include <map>
 
+#include "kern/linux/flag_tables.hh"
 #include "kern/solaris/solaris.hh"
 #include "sim/byteswap.hh"
 
 namespace gem5
 {
 
-class SparcSolaris : public Solaris
+class SparcSolaris : public Solaris, public OpenFlagTable<SparcSolaris>
 {
   public:
+    static constexpr ByteOrder byteOrder = ByteOrder::big;
 
-    static const ByteOrder byteOrder = ByteOrder::big;
+    static constexpr int TGT_O_RDONLY       = 0x00000000;   //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY       = 0x00000001;   //!< O_WRONLY
+    static constexpr int TGT_O_RDWR         = 0x00000002;   //!< O_RDWR
+    static constexpr int TGT_O_NDELAY       = 0x00000004;   //!< O_NONBLOCK
+    static constexpr int TGT_O_APPEND       = 0x00000008;   //!< O_APPEND
+    static constexpr int TGT_O_SYNC         = 0x00000010;   //!< O_SYNC
+    static constexpr int TGT_O_DSYNC        = 0x00000040;   //!< O_SYNC
+    static constexpr int TGT_O_RSYNC        = 0x00008000;   //!< O_SYNC
+    static constexpr int TGT_O_NONBLOCK     = 0x00000080;   //!< O_NONBLOCK
+    static constexpr int TGT_O_PRIV         = 0x00001000;   //??
+    static constexpr int TGT_O_LARGEFILE    = 0x00002000;   //??
+    static constexpr int TGT_O_CREAT        = 0x00000100;   //!< O_CREAT
+    static constexpr int TGT_O_TRUNC        = 0x00000200;   //!< O_TRUNC
+    static constexpr int TGT_O_EXCL         = 0x00000400;   //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY       = 0x00000800;   //!< O_NOCTTY
+    static constexpr int TGT_O_XATTR        = 0x00004000;   //??
 
-    static const std::map<int, int> openFlagTable;
-
-    static const int TGT_O_RDONLY       = 0x00000000;   //!< O_RDONLY
-    static const int TGT_O_WRONLY       = 0x00000001;   //!< O_WRONLY
-    static const int TGT_O_RDWR         = 0x00000002;   //!< O_RDWR
-    static const int TGT_O_NDELAY       = 0x00000004;   //!< O_NONBLOCK
-    static const int TGT_O_APPEND       = 0x00000008;   //!< O_APPEND
-    static const int TGT_O_SYNC         = 0x00000010;   //!< O_SYNC
-    static const int TGT_O_DSYNC        = 0x00000040;   //!< O_SYNC
-    static const int TGT_O_RSYNC        = 0x00008000;   //!< O_SYNC
-    static const int TGT_O_NONBLOCK     = 0x00000080;   //!< O_NONBLOCK
-    static const int TGT_O_PRIV         = 0x00001000;   //??
-    static const int TGT_O_LARGEFILE    = 0x00002000;   //??
-    static const int TGT_O_CREAT        = 0x00000100;   //!< O_CREAT
-    static const int TGT_O_TRUNC        = 0x00000200;   //!< O_TRUNC
-    static const int TGT_O_EXCL         = 0x00000400;   //!< O_EXCL
-    static const int TGT_O_NOCTTY       = 0x00000800;   //!< O_NOCTTY
-    static const int TGT_O_XATTR        = 0x00004000;   //??
-
-    /// For mmap().
-    static const std::map<int, int> mmapFlagTable;
-
-    static const unsigned TGT_MAP_SHARED        = 0x00001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
-    static const unsigned TGT_MAP_ANON          = 0x00020;
-    static const unsigned TGT_MAP_DENYWRITE     = 0x00800;
-    static const unsigned TGT_MAP_EXECUTABLE    = 0x01000;
-    static const unsigned TGT_MAP_FILE          = 0x00000;
-    static const unsigned TGT_MAP_GROWSDOWN     = 0x00100;
-    static const unsigned TGT_MAP_HUGETLB       = 0x40000;
-    static const unsigned TGT_MAP_LOCKED        = 0x02000;
-    static const unsigned TGT_MAP_NONBLOCK      = 0x10000;
-    static const unsigned TGT_MAP_NORESERVE     = 0x04000;
-    static const unsigned TGT_MAP_POPULATE      = 0x08000;
-    static const unsigned TGT_MAP_STACK         = 0x20000;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x00020;
-    static const unsigned TGT_MAP_FIXED         = 0x00010;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x00001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x00002;
+    static constexpr unsigned TGT_MAP_ANON          = 0x00020;
+    static constexpr unsigned TGT_MAP_DENYWRITE     = 0x00800;
+    static constexpr unsigned TGT_MAP_EXECUTABLE    = 0x01000;
+    static constexpr unsigned TGT_MAP_FILE          = 0x00000;
+    static constexpr unsigned TGT_MAP_GROWSDOWN     = 0x00100;
+    static constexpr unsigned TGT_MAP_HUGETLB       = 0x40000;
+    static constexpr unsigned TGT_MAP_LOCKED        = 0x02000;
+    static constexpr unsigned TGT_MAP_NONBLOCK      = 0x10000;
+    static constexpr unsigned TGT_MAP_NORESERVE     = 0x04000;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x08000;
+    static constexpr unsigned TGT_MAP_STACK         = 0x20000;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x00020;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x00010;
 };
 
 } // namespace gem5
diff --git a/src/arch/x86/linux/SConscript b/src/arch/x86/linux/SConscript
index 08b0792..d27d6be 100644
--- a/src/arch/x86/linux/SConscript
+++ b/src/arch/x86/linux/SConscript
@@ -44,7 +44,6 @@
     Return()
 
 Source('fs_workload.cc')
-Source('linux.cc')
 Source('se_workload.cc')
 Source('syscalls.cc')
 Source('syscall_tbl32.cc')
diff --git a/src/arch/x86/linux/linux.cc b/src/arch/x86/linux/linux.cc
deleted file mode 100644
index b298dcc..0000000
--- a/src/arch/x86/linux/linux.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2007 The Hewlett-Packard Development Company
- * All rights reserved.
- *
- * The license below extends only to copyright in the software and shall
- * not be construed as granting a license to any other intellectual
- * property including but not limited to intellectual property relating
- * to a hardware implementation of the functionality of the software
- * licensed hereunder.  You may use the software subject to the license
- * terms below provided that you ensure that this notice is replicated
- * unmodified and in its entirety in all distributions of the software,
- * modified or unmodified, in source code or in binary form.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "arch/x86/linux/linux.hh"
-
-#include <fcntl.h>
-#include <sys/mman.h>
-
-// true for both X86Linux32 and X86Linux64
-#define TARGET_HAS_MAP_32BIT
-
-#define TARGET X86Linux32
-#include "kern/linux/flag_tables.hh"
-
-#undef TARGET
-#define TARGET X86Linux64
-#include "kern/linux/flag_tables.hh"
diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh
index 29422a3..957d348 100644
--- a/src/arch/x86/linux/linux.hh
+++ b/src/arch/x86/linux/linux.hh
@@ -42,6 +42,7 @@
 
 #include "arch/x86/utility.hh"
 #include "base/compiler.hh"
+#include "kern/linux/flag_tables.hh"
 #include "kern/linux/linux.hh"
 #include "sim/guest_abi.hh"
 #include "sim/syscall_return.hh"
@@ -95,7 +96,7 @@
 
 } // namespace guest_abi
 
-class X86Linux64 : public X86Linux
+class X86Linux64 : public X86Linux, public OpenFlagTable<X86Linux64>
 {
   public:
 
@@ -176,27 +177,25 @@
     static const int TGT_SIGSYS         = 0x00001f;
     static const int TGT_SIGUNUSED      = 0x00001f;
 
-    static const std::map<int, int> openFlagTable;
-
-    static const int TGT_O_RDONLY       = 000000000;     //!< O_RDONLY
-    static const int TGT_O_WRONLY       = 000000001;     //!< O_WRONLY
-    static const int TGT_O_RDWR         = 000000002;     //!< O_RDWR
-    static const int TGT_O_CREAT        = 000000100;     //!< O_CREAT
-    static const int TGT_O_EXCL         = 000000200;     //!< O_EXCL
-    static const int TGT_O_NOCTTY       = 000000400;     //!< O_NOCTTY
-    static const int TGT_O_TRUNC        = 000001000;     //!< O_TRUNC
-    static const int TGT_O_APPEND       = 000002000;     //!< O_APPEND
-    static const int TGT_O_NONBLOCK     = 000004000;     //!< O_NONBLOCK
-    static const int TGT_O_DSYNC        = 000010000;
-    static const int TGT_FASYNC         = 000020000;
-    static const int TGT_O_DIRECT       = 000040000;     //!< O_DIRECTIO
-    static const int TGT_O_LARGEFILE    = 000100000;
-    static const int TGT_O_DIRECTORY    = 000200000;
-    static const int TGT_O_NOFOLLOW     = 000400000;
-    static const int TGT_O_NOATIME      = 001000000;
-    static const int TGT_O_CLOEXEC      = 002000000;
-    static const int TGT_O_SYNC         = 004010000;     //!< O_SYNC
-    static const int TGT_O_PATH         = 010000000;
+    static constexpr int TGT_O_RDONLY       = 000000000;     //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY       = 000000001;     //!< O_WRONLY
+    static constexpr int TGT_O_RDWR         = 000000002;     //!< O_RDWR
+    static constexpr int TGT_O_CREAT        = 000000100;     //!< O_CREAT
+    static constexpr int TGT_O_EXCL         = 000000200;     //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY       = 000000400;     //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC        = 000001000;     //!< O_TRUNC
+    static constexpr int TGT_O_APPEND       = 000002000;     //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK     = 000004000;     //!< O_NONBLOCK
+    static constexpr int TGT_O_DSYNC        = 000010000;
+    static constexpr int TGT_FASYNC         = 000020000;
+    static constexpr int TGT_O_DIRECT       = 000040000;     //!< O_DIRECTIO
+    static constexpr int TGT_O_LARGEFILE    = 000100000;
+    static constexpr int TGT_O_DIRECTORY    = 000200000;
+    static constexpr int TGT_O_NOFOLLOW     = 000400000;
+    static constexpr int TGT_O_NOATIME      = 001000000;
+    static constexpr int TGT_O_CLOEXEC      = 002000000;
+    static constexpr int TGT_O_SYNC         = 004010000;     //!< O_SYNC
+    static constexpr int TGT_O_PATH         = 010000000;
 
     //@{
     /// Basic X86_64 Linux types
@@ -206,22 +205,22 @@
     typedef int64_t clock_t;
     //@}
 
-    static const unsigned TGT_MAP_SHARED        = 0x00001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
-    static const unsigned TGT_MAP_32BIT         = 0x00040;
-    static const unsigned TGT_MAP_ANON          = 0x00020;
-    static const unsigned TGT_MAP_DENYWRITE     = 0x00800;
-    static const unsigned TGT_MAP_EXECUTABLE    = 0x01000;
-    static const unsigned TGT_MAP_FILE          = 0x00000;
-    static const unsigned TGT_MAP_GROWSDOWN     = 0x00100;
-    static const unsigned TGT_MAP_HUGETLB       = 0x40000;
-    static const unsigned TGT_MAP_LOCKED        = 0x02000;
-    static const unsigned TGT_MAP_NONBLOCK      = 0x10000;
-    static const unsigned TGT_MAP_NORESERVE     = 0x04000;
-    static const unsigned TGT_MAP_POPULATE      = 0x08000;
-    static const unsigned TGT_MAP_STACK         = 0x20000;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x00020;
-    static const unsigned TGT_MAP_FIXED         = 0x00010;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x00001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x00002;
+    static constexpr unsigned TGT_MAP_32BIT         = 0x00040;
+    static constexpr unsigned TGT_MAP_ANON          = 0x00020;
+    static constexpr unsigned TGT_MAP_DENYWRITE     = 0x00800;
+    static constexpr unsigned TGT_MAP_EXECUTABLE    = 0x01000;
+    static constexpr unsigned TGT_MAP_FILE          = 0x00000;
+    static constexpr unsigned TGT_MAP_GROWSDOWN     = 0x00100;
+    static constexpr unsigned TGT_MAP_HUGETLB       = 0x40000;
+    static constexpr unsigned TGT_MAP_LOCKED        = 0x02000;
+    static constexpr unsigned TGT_MAP_NONBLOCK      = 0x10000;
+    static constexpr unsigned TGT_MAP_NORESERVE     = 0x04000;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x08000;
+    static constexpr unsigned TGT_MAP_STACK         = 0x20000;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x00020;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x00010;
 
     struct tgt_iovec
     {
@@ -247,7 +246,7 @@
 
 };
 
-class X86Linux32 : public X86Linux
+class X86Linux32 : public X86Linux, public OpenFlagTable<X86Linux32>
 {
   public:
     struct GEM5_PACKED tgt_stat64
@@ -308,27 +307,25 @@
     static const int TGT_SIGSYS         = 0x00001f;
     static const int TGT_SIGUNUSED      = 0x00001f;
 
-    static const std::map<int, int> openFlagTable;
-
-    static const int TGT_O_RDONLY       = 000000000;     //!< O_RDONLY
-    static const int TGT_O_WRONLY       = 000000001;     //!< O_WRONLY
-    static const int TGT_O_RDWR         = 000000002;     //!< O_RDWR
-    static const int TGT_O_CREAT        = 000000100;     //!< O_CREAT
-    static const int TGT_O_EXCL         = 000000200;     //!< O_EXCL
-    static const int TGT_O_NOCTTY       = 000000400;     //!< O_NOCTTY
-    static const int TGT_O_TRUNC        = 000001000;     //!< O_TRUNC
-    static const int TGT_O_APPEND       = 000002000;     //!< O_APPEND
-    static const int TGT_O_NONBLOCK     = 000004000;     //!< O_NONBLOCK
-    static const int TGT_O_DSYNC        = 000010000;     //!< O_DSYNC
-    static const int TGT_FASYNC         = 000020000;
-    static const int TGT_O_DIRECT       = 000040000;     //!< O_DIRECTIO
-    static const int TGT_O_LARGEFILE    = 000100000;
-    static const int TGT_O_DIRECTORY    = 000200000;
-    static const int TGT_O_NOFOLLOW     = 000400000;
-    static const int TGT_O_NOATIME      = 001000000;
-    static const int TGT_O_CLOEXEC      = 002000000;
-    static const int TGT_O_SYNC         = 004010000;     //!< O_SYNC
-    static const int TGT_O_PATH         = 010000000;
+    static constexpr int TGT_O_RDONLY       = 000000000;     //!< O_RDONLY
+    static constexpr int TGT_O_WRONLY       = 000000001;     //!< O_WRONLY
+    static constexpr int TGT_O_RDWR         = 000000002;     //!< O_RDWR
+    static constexpr int TGT_O_CREAT        = 000000100;     //!< O_CREAT
+    static constexpr int TGT_O_EXCL         = 000000200;     //!< O_EXCL
+    static constexpr int TGT_O_NOCTTY       = 000000400;     //!< O_NOCTTY
+    static constexpr int TGT_O_TRUNC        = 000001000;     //!< O_TRUNC
+    static constexpr int TGT_O_APPEND       = 000002000;     //!< O_APPEND
+    static constexpr int TGT_O_NONBLOCK     = 000004000;     //!< O_NONBLOCK
+    static constexpr int TGT_O_DSYNC        = 000010000;     //!< O_DSYNC
+    static constexpr int TGT_FASYNC         = 000020000;
+    static constexpr int TGT_O_DIRECT       = 000040000;     //!< O_DIRECTIO
+    static constexpr int TGT_O_LARGEFILE    = 000100000;
+    static constexpr int TGT_O_DIRECTORY    = 000200000;
+    static constexpr int TGT_O_NOFOLLOW     = 000400000;
+    static constexpr int TGT_O_NOATIME      = 001000000;
+    static constexpr int TGT_O_CLOEXEC      = 002000000;
+    static constexpr int TGT_O_SYNC         = 004010000;     //!< O_SYNC
+    static constexpr int TGT_O_PATH         = 010000000;
 
     static const std::map<int, int> mmapFlagTable;
 
@@ -340,22 +337,22 @@
     typedef int32_t clock_t;
     //@}
 
-    static const unsigned TGT_MAP_SHARED        = 0x00001;
-    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
-    static const unsigned TGT_MAP_32BIT         = 0x00040;
-    static const unsigned TGT_MAP_ANON          = 0x00020;
-    static const unsigned TGT_MAP_DENYWRITE     = 0x00800;
-    static const unsigned TGT_MAP_EXECUTABLE    = 0x01000;
-    static const unsigned TGT_MAP_FILE          = 0x00000;
-    static const unsigned TGT_MAP_GROWSDOWN     = 0x00100;
-    static const unsigned TGT_MAP_HUGETLB       = 0x40000;
-    static const unsigned TGT_MAP_LOCKED        = 0x02000;
-    static const unsigned TGT_MAP_NONBLOCK      = 0x10000;
-    static const unsigned TGT_MAP_NORESERVE     = 0x04000;
-    static const unsigned TGT_MAP_POPULATE      = 0x08000;
-    static const unsigned TGT_MAP_STACK         = 0x20000;
-    static const unsigned TGT_MAP_ANONYMOUS     = 0x00020;
-    static const unsigned TGT_MAP_FIXED         = 0x00010;
+    static constexpr unsigned TGT_MAP_SHARED        = 0x00001;
+    static constexpr unsigned TGT_MAP_PRIVATE       = 0x00002;
+    static constexpr unsigned TGT_MAP_32BIT         = 0x00040;
+    static constexpr unsigned TGT_MAP_ANON          = 0x00020;
+    static constexpr unsigned TGT_MAP_DENYWRITE     = 0x00800;
+    static constexpr unsigned TGT_MAP_EXECUTABLE    = 0x01000;
+    static constexpr unsigned TGT_MAP_FILE          = 0x00000;
+    static constexpr unsigned TGT_MAP_GROWSDOWN     = 0x00100;
+    static constexpr unsigned TGT_MAP_HUGETLB       = 0x40000;
+    static constexpr unsigned TGT_MAP_LOCKED        = 0x02000;
+    static constexpr unsigned TGT_MAP_NONBLOCK      = 0x10000;
+    static constexpr unsigned TGT_MAP_NORESERVE     = 0x04000;
+    static constexpr unsigned TGT_MAP_POPULATE      = 0x08000;
+    static constexpr unsigned TGT_MAP_STACK         = 0x20000;
+    static constexpr unsigned TGT_MAP_ANONYMOUS     = 0x00020;
+    static constexpr unsigned TGT_MAP_FIXED         = 0x00010;
 
     struct tgt_sysinfo
     {
diff --git a/src/kern/linux/flag_tables.hh b/src/kern/linux/flag_tables.hh
index d2bf55f..e8b7e07 100644
--- a/src/kern/linux/flag_tables.hh
+++ b/src/kern/linux/flag_tables.hh
@@ -40,73 +40,78 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <fcntl.h>
+#include <sys/mman.h>
+
 /*
  * @file flag_tables.hh
  *
  * This file contains definitions of flag translation tables for the
  * open() system call.  Since the tables are nearly identical
  * across target platforms (other than the values of the target flags),
- * we use a single copy of the tables but include it separately for
- * each target platform.  The TARGET macro must be #defined before including
- * to indicate the class for which the table is being defined.
- *
- * See src/arch/<*>/linux/linux.cc.
+ * we use a template to build the tables which is inherited by each target
+ * platform.
  */
 
 namespace gem5
 {
 
-// open(2) flags translation table
-const std::map<int, int> TARGET::openFlagTable = {
+template <typename Target>
+class OpenFlagTable
+{
+  public:
+    // open(2) flags translation table
+    static inline const std::map<int, int> openFlagTable = {
 #ifdef _MSC_VER
-  { TARGET::TGT_O_RDONLY,     _O_RDONLY },
-  { TARGET::TGT_O_WRONLY,     _O_WRONLY },
-  { TARGET::TGT_O_RDWR,       _O_RDWR },
-  { TARGET::TGT_O_CREAT,      _O_CREAT },
-  { TARGET::TGT_O_EXCL,       _O_EXCL },
-  { TARGET::TGT_O_TRUNC,      _O_TRUNC },
-  { TARGET::TGT_O_APPEND,     _O_APPEND },
+      { Target::TGT_O_RDONLY,     _O_RDONLY },
+      { Target::TGT_O_WRONLY,     _O_WRONLY },
+      { Target::TGT_O_RDWR,       _O_RDWR },
+      { Target::TGT_O_CREAT,      _O_CREAT },
+      { Target::TGT_O_EXCL,       _O_EXCL },
+      { Target::TGT_O_TRUNC,      _O_TRUNC },
+      { Target::TGT_O_APPEND,     _O_APPEND },
 #else /* !_MSC_VER */
-  { TARGET::TGT_O_RDONLY,     O_RDONLY },
-  { TARGET::TGT_O_WRONLY,     O_WRONLY },
-  { TARGET::TGT_O_RDWR,       O_RDWR },
-  { TARGET::TGT_O_CREAT,      O_CREAT },
-  { TARGET::TGT_O_EXCL,       O_EXCL },
-  { TARGET::TGT_O_TRUNC,      O_TRUNC },
-  { TARGET::TGT_O_APPEND,     O_APPEND },
-  { TARGET::TGT_O_NOCTTY,     O_NOCTTY },
-  { TARGET::TGT_O_NONBLOCK,   O_NONBLOCK },
+      { Target::TGT_O_RDONLY,     O_RDONLY },
+      { Target::TGT_O_WRONLY,     O_WRONLY },
+      { Target::TGT_O_RDWR,       O_RDWR },
+      { Target::TGT_O_CREAT,      O_CREAT },
+      { Target::TGT_O_EXCL,       O_EXCL },
+      { Target::TGT_O_TRUNC,      O_TRUNC },
+      { Target::TGT_O_APPEND,     O_APPEND },
+      { Target::TGT_O_NOCTTY,     O_NOCTTY },
+      { Target::TGT_O_NONBLOCK,   O_NONBLOCK },
 #ifdef O_DSYNC
-  { TARGET::TGT_O_DSYNC,      O_DSYNC },
+      { Target::TGT_O_DSYNC,      O_DSYNC },
 #endif
 #ifdef O_ASYNC
-  { TARGET::TGT_FASYNC,       O_ASYNC },
+      { Target::TGT_FASYNC,       O_ASYNC },
 #endif
 #ifdef O_DIRECT
-  { TARGET::TGT_O_DIRECT,     O_DIRECT },
+      { Target::TGT_O_DIRECT,     O_DIRECT },
 #endif
 #ifdef O_LARGEFILE
-  { TARGET::TGT_O_LARGEFILE,  O_LARGEFILE },
+      { Target::TGT_O_LARGEFILE,  O_LARGEFILE },
 #endif
 #ifdef O_DIRECTORY
-  { TARGET::TGT_O_DIRECTORY,  O_DIRECTORY },
+      { Target::TGT_O_DIRECTORY,  O_DIRECTORY },
 #endif
 #ifdef O_NOFOLLOW
-  { TARGET::TGT_O_NOFOLLOW,   O_NOFOLLOW },
+      { Target::TGT_O_NOFOLLOW,   O_NOFOLLOW },
 #endif
 #ifdef O_NOATIME
-  { TARGET::TGT_O_NOATIME,    O_NOATIME },
+      { Target::TGT_O_NOATIME,    O_NOATIME },
 #endif
 #ifdef O_CLOEXEC
-  { TARGET::TGT_O_CLOEXEC,    O_CLOEXEC },
+      { Target::TGT_O_CLOEXEC,    O_CLOEXEC },
 #endif
 #ifdef O_SYNC
-  { TARGET::TGT_O_SYNC,       O_SYNC },
+      { Target::TGT_O_SYNC,       O_SYNC },
 #endif
 #ifdef O_PATH
-  { TARGET::TGT_O_PATH,       O_PATH },
+      { Target::TGT_O_PATH,       O_PATH },
 #endif
 #endif /* _MSC_VER */
+    };
 };
 
 } // namespace gem5