[llvm] r340675 - This patch adds support to LLVM for writing HermitCore (https://hermitcore.org) ELF binaries.
Eric Christopher via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 24 18:08:19 PDT 2018
Author: echristo
Date: Fri Aug 24 18:08:18 2018
New Revision: 340675
URL: http://llvm.org/viewvc/llvm-project?rev=340675&view=rev
Log:
This patch adds support to LLVM for writing HermitCore (https://hermitcore.org) ELF binaries.
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!
Modified:
llvm/trunk/include/llvm/ADT/Triple.h
llvm/trunk/include/llvm/MC/MCELFObjectWriter.h
llvm/trunk/lib/Support/Triple.cpp
llvm/trunk/unittests/ADT/TripleTest.cpp
Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=340675&r1=340674&r2=340675&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Fri Aug 24 18:08:18 2018
@@ -182,7 +182,8 @@ public:
Mesa3D,
Contiki,
AMDPAL, // AMD PAL Runtime
- LastOSType = AMDPAL
+ HermitCore, // HermitCore Unikernel/Multikernel
+ LastOSType = HermitCore
};
enum EnvironmentType {
UnknownEnvironment,
Modified: llvm/trunk/include/llvm/MC/MCELFObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCELFObjectWriter.h?rev=340675&r1=340674&r2=340675&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCELFObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/MCELFObjectWriter.h Fri Aug 24 18:08:18 2018
@@ -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;
Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=340675&r1=340674&r2=340675&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Fri Aug 24 18:08:18 2018
@@ -209,6 +209,7 @@ StringRef Triple::getOSTypeName(OSType K
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
.StartsWith("mesa3d", Triple::Mesa3D)
.StartsWith("contiki", Triple::Contiki)
.StartsWith("amdpal", Triple::AMDPAL)
+ .StartsWith("hermit", Triple::HermitCore)
.Default(Triple::UnknownOS);
}
Modified: llvm/trunk/unittests/ADT/TripleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TripleTest.cpp?rev=340675&r1=340674&r2=340675&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/TripleTest.cpp (original)
+++ llvm/trunk/unittests/ADT/TripleTest.cpp Fri Aug 24 18:08:18 2018
@@ -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());
More information about the llvm-commits
mailing list