1 //===------ MachOLinkGraphTests.cpp - Unit tests for MachO LinkGraphs -----===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "JITLinkTestUtils.h"
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/ExecutionEngine/JITLink/JITLink.h"
13 #include "llvm/ExecutionEngine/JITLink/MachO.h"
14 #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
16 #include "llvm/Testing/Support/Error.h"
17 #include "gtest/gtest.h"
20 using namespace llvm::jitlink
;
22 TEST(MachOLinkGraphTest
, GetStandardSections
) {
23 // Check that LinkGraph construction works as expected.
24 LinkGraph
G("foo", std::make_shared
<orc::SymbolStringPool
>(),
25 Triple("arm64-apple-darwin"), SubtargetFeatures(),
26 getGenericEdgeKindName
);
28 auto &Data
= getMachODefaultRWDataSection(G
);
29 EXPECT_TRUE(Data
.empty());
30 EXPECT_EQ(Data
.getName(), orc::MachODataDataSectionName
);
31 EXPECT_EQ(Data
.getMemProt(), orc::MemProt::Read
| orc::MemProt::Write
);
33 auto &Text
= getMachODefaultTextSection(G
);
34 EXPECT_TRUE(Text
.empty());
35 EXPECT_EQ(Text
.getName(), orc::MachOTextTextSectionName
);
36 EXPECT_EQ(Text
.getMemProt(), orc::MemProt::Read
| orc::MemProt::Exec
);