Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Add support for writing HermitCore (https://hermitcore.org) ELF binaries #122

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/llvm/ADT/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ class Triple {
Mesa3D,
Contiki,
AMDPAL, // AMD PAL Runtime
LastOSType = AMDPAL
HermitCore, // HermitCore Unikernel/Multikernel
LastOSType = HermitCore
};
enum EnvironmentType {
UnknownEnvironment,
Expand Down
2 changes: 2 additions & 0 deletions include/llvm/MC/MCELFObjectWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class MCELFObjectTargetWriter : public MCObjectTargetWriter {
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;
Expand Down
2 changes: 2 additions & 0 deletions lib/Support/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions unittests/ADT/TripleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down