This patch adds support to LLVM for writing HermitCore (https://hermitcore.org) ELF...
authorEric Christopher <echristo@gmail.com>
Sat, 25 Aug 2018 01:08:18 +0000 (01:08 +0000)
committerEric Christopher <echristo@gmail.com>
Sat, 25 Aug 2018 01:08:18 +0000 (01:08 +0000)
HermitCore is a POSIX-compatible kernel for running a single application in an isolated environment to get maximum performance and predictable runtime behavior. It can either be used bare-metal on hardware or a VM (Unikernel) or side by side to an existing Linux system (Multikernel).
Due to the latter feature, HermitCore binaries are marked with ELFOSABI_STANDALONE to let the Linux ELF loader distinguish them from regular Unix/Linux binaries and load them using the HermitCore "proxy" tool.

Patch by Colin Finck!

llvm-svn: 340675

llvm/include/llvm/ADT/Triple.h
llvm/include/llvm/MC/MCELFObjectWriter.h
llvm/lib/Support/Triple.cpp
llvm/unittests/ADT/TripleTest.cpp

index c95b16d..76fe6d3 100644 (file)
@@ -182,7 +182,8 @@ public:
     Mesa3D,
     Contiki,
     AMDPAL,     // AMD PAL Runtime
-    LastOSType = AMDPAL
+    HermitCore, // HermitCore Unikernel/Multikernel
+    LastOSType = HermitCore
   };
   enum EnvironmentType {
     UnknownEnvironment,
index bff58fe..58cb3ae 100644 (file)
@@ -73,6 +73,8 @@ public:
     switch (OSType) {
       case Triple::CloudABI:
         return ELF::ELFOSABI_CLOUDABI;
+      case Triple::HermitCore:
+        return ELF::ELFOSABI_STANDALONE;
       case Triple::PS4:
       case Triple::FreeBSD:
         return ELF::ELFOSABI_FREEBSD;
index c48be2d..d1017fb 100644 (file)
@@ -209,6 +209,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
   case Mesa3D: return "mesa3d";
   case Contiki: return "contiki";
   case AMDPAL: return "amdpal";
+  case HermitCore: return "hermit";
   }
 
   llvm_unreachable("Invalid OSType");
@@ -502,6 +503,7 @@ static Triple::OSType parseOS(StringRef OSName) {
     .StartsWith("mesa3d", Triple::Mesa3D)
     .StartsWith("contiki", Triple::Contiki)
     .StartsWith("amdpal", Triple::AMDPAL)
+    .StartsWith("hermit", Triple::HermitCore)
     .Default(Triple::UnknownOS);
 }
 
index fcc71d5..7da8cff 100644 (file)
@@ -235,6 +235,12 @@ TEST(TripleTest, ParsedIDs) {
   EXPECT_EQ(Triple::Fuchsia, T.getOS());
   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
 
+  T = Triple("x86_64-unknown-hermit");
+  EXPECT_EQ(Triple::x86_64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::HermitCore, T.getOS());
+  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
   T = Triple("wasm32-unknown-unknown");
   EXPECT_EQ(Triple::wasm32, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());