summaryrefslogtreecommitdiffstats
path: root/lld/unittests/MachOTests
diff options
context:
space:
mode:
Diffstat (limited to 'lld/unittests/MachOTests')
-rw-r--r--lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp16
-rw-r--r--lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp17
-rw-r--r--lld/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp18
3 files changed, 25 insertions, 26 deletions
diff --git a/lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp b/lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp
index 22ed3f15b3e..8c870f905a0 100644
--- a/lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp
+++ b/lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp
@@ -273,7 +273,7 @@ TEST(BinaryReaderTest, hello_obj_x86_64) {
EXPECT_EQ(text.type, S_REGULAR);
EXPECT_EQ(text.attributes,SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(text.alignment, 4U);
+ EXPECT_EQ(text.alignment.get(), 16U);
EXPECT_EQ(text.address, Hex64(0x0));
EXPECT_EQ(text.content.size(), 45UL);
EXPECT_EQ((int)(text.content[0]), 0x55);
@@ -298,7 +298,7 @@ TEST(BinaryReaderTest, hello_obj_x86_64) {
EXPECT_TRUE(cstring.sectionName.equals("__cstring"));
EXPECT_EQ(cstring.type, S_CSTRING_LITERALS);
EXPECT_EQ(cstring.attributes, SectionAttr(0));
- EXPECT_EQ(cstring.alignment, 0U);
+ EXPECT_EQ(cstring.alignment.get(), 1U);
EXPECT_EQ(cstring.address, Hex64(0x02D));
EXPECT_EQ(cstring.content.size(), 7UL);
EXPECT_EQ((int)(cstring.content[0]), 0x68);
@@ -399,7 +399,7 @@ TEST(BinaryReaderTest, hello_obj_x86) {
EXPECT_EQ(text.type, S_REGULAR);
EXPECT_EQ(text.attributes,SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(text.alignment, 4U);
+ EXPECT_EQ(text.alignment.get(), 16U);
EXPECT_EQ(text.address, Hex64(0x0));
EXPECT_EQ(text.content.size(), 48UL);
EXPECT_EQ((int)(text.content[0]), 0x55);
@@ -434,7 +434,7 @@ TEST(BinaryReaderTest, hello_obj_x86) {
EXPECT_TRUE(cstring.sectionName.equals("__cstring"));
EXPECT_EQ(cstring.type, S_CSTRING_LITERALS);
EXPECT_EQ(cstring.attributes, SectionAttr(0));
- EXPECT_EQ(cstring.alignment, 0U);
+ EXPECT_EQ(cstring.alignment.get(), 1U);
EXPECT_EQ(cstring.address, Hex64(0x030));
EXPECT_EQ(cstring.content.size(), 7UL);
EXPECT_EQ((int)(cstring.content[0]), 0x68);
@@ -532,7 +532,7 @@ TEST(BinaryReaderTest, hello_obj_armv7) {
EXPECT_EQ(text.type, S_REGULAR);
EXPECT_EQ(text.attributes,SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(text.alignment, 2U);
+ EXPECT_EQ(text.alignment.get(), 4U);
EXPECT_EQ(text.address, Hex64(0x0));
EXPECT_EQ(text.content.size(), 42UL);
EXPECT_EQ((int)(text.content[0]), 0x80);
@@ -576,7 +576,7 @@ TEST(BinaryReaderTest, hello_obj_armv7) {
EXPECT_TRUE(cstring.sectionName.equals("__cstring"));
EXPECT_EQ(cstring.type, S_CSTRING_LITERALS);
EXPECT_EQ(cstring.attributes, SectionAttr(0));
- EXPECT_EQ(cstring.alignment, 0U);
+ EXPECT_EQ(cstring.alignment.get(), 1U);
EXPECT_EQ(cstring.address, Hex64(0x02A));
EXPECT_EQ(cstring.content.size(), 7UL);
EXPECT_EQ((int)(cstring.content[0]), 0x68);
@@ -677,7 +677,7 @@ TEST(BinaryReaderTest, hello_obj_ppc) {
EXPECT_EQ(text.type, S_REGULAR);
EXPECT_EQ(text.attributes,SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(text.alignment, 2U);
+ EXPECT_EQ(text.alignment.get(), 4U);
EXPECT_EQ(text.address, Hex64(0x0));
EXPECT_EQ(text.content.size(), 68UL);
EXPECT_EQ((int)(text.content[0]), 0x7C);
@@ -720,7 +720,7 @@ TEST(BinaryReaderTest, hello_obj_ppc) {
EXPECT_TRUE(cstring.sectionName.equals("__cstring"));
EXPECT_EQ(cstring.type, S_CSTRING_LITERALS);
EXPECT_EQ(cstring.attributes, SectionAttr(0));
- EXPECT_EQ(cstring.alignment, 2U);
+ EXPECT_EQ(cstring.alignment.get(), 4U);
EXPECT_EQ(cstring.address, Hex64(0x044));
EXPECT_EQ(cstring.content.size(), 7UL);
EXPECT_EQ((int)(cstring.content[0]), 0x68);
diff --git a/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp b/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
index d79c6d62a84..528c908c90e 100644
--- a/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
+++ b/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
@@ -123,7 +123,7 @@ TEST(BinaryWriterTest, obj_relocs_x86_64) {
text.type = S_REGULAR;
text.attributes = SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS);
- text.alignment = 4;
+ text.alignment = lld::PowerOf2(4);
text.address = 0;
const uint8_t textBytes[] = {
0xe8, 0x00, 0x00, 0x00, 0x00, 0x48, 0x8b, 0x05,
@@ -179,7 +179,7 @@ TEST(BinaryWriterTest, obj_relocs_x86_64) {
EXPECT_EQ(S_REGULAR, text.type);
EXPECT_EQ(text.attributes,SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(text.alignment, 4U);
+ EXPECT_EQ(text.alignment.get(), 16U);
EXPECT_EQ(text.address, Hex64(0x0));
EXPECT_EQ(48UL, text.content.size());
const Relocation& call = text.relocations[0];
@@ -240,7 +240,7 @@ TEST(BinaryWriterTest, obj_relocs_x86) {
text.type = S_REGULAR;
text.attributes = SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS);
- text.alignment = 4;
+ text.alignment = lld::PowerOf2(4);
text.address = 0;
const uint8_t textBytes[] = {
0xe8, 0xfb, 0xff, 0xff, 0xff, 0xa1, 0x00, 0x00,
@@ -290,7 +290,7 @@ TEST(BinaryWriterTest, obj_relocs_x86) {
EXPECT_EQ(S_REGULAR, text.type);
EXPECT_EQ(text.attributes,SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(text.alignment, 4U);
+ EXPECT_EQ(text.alignment.get(), 16U);
EXPECT_EQ(text.address, Hex64(0x0));
EXPECT_EQ(22UL, text.content.size());
const Relocation& call = text.relocations[0];
@@ -350,7 +350,7 @@ TEST(BinaryWriterTest, obj_relocs_armv7) {
text.type = S_REGULAR;
text.attributes = SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS);
- text.alignment = 2;
+ text.alignment = lld::PowerOf2(2);
text.address = 0;
const uint8_t textBytes[] = {
0xff, 0xf7, 0xfe, 0xef, 0x40, 0xf2, 0x05, 0x01,
@@ -415,7 +415,7 @@ TEST(BinaryWriterTest, obj_relocs_armv7) {
EXPECT_EQ(S_REGULAR, text.type);
EXPECT_EQ(text.attributes,SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(text.alignment, 2U);
+ EXPECT_EQ(text.alignment.get(), 4U);
EXPECT_EQ(text.address, Hex64(0x0));
EXPECT_EQ(18UL, text.content.size());
const Relocation& blx = text.relocations[0];
@@ -479,7 +479,7 @@ TEST(BinaryWriterTest, obj_relocs_ppc) {
text.type = S_REGULAR;
text.attributes = SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS);
- text.alignment = 2;
+ text.alignment = lld::PowerOf2(2);
text.address = 0;
const uint8_t textBytes[] = {
0x48, 0x00, 0x00, 0x01, 0x40, 0x82, 0xff, 0xfc,
@@ -571,7 +571,7 @@ TEST(BinaryWriterTest, obj_relocs_ppc) {
EXPECT_EQ(S_REGULAR, text.type);
EXPECT_EQ(text.attributes,SectionAttr(S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(text.alignment, 2U);
+ EXPECT_EQ(text.alignment.get(), 4U);
EXPECT_EQ(text.address, Hex64(0x0));
EXPECT_EQ(44UL, text.content.size());
const Relocation& br24 = text.relocations[0];
@@ -690,4 +690,3 @@ TEST(BinaryWriterTest, obj_relocs_ppc) {
std::error_code ec = llvm::sys::fs::remove(Twine(tmpFl));
EXPECT_FALSE(ec);
}
-
diff --git a/lld/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp b/lld/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp
index 562dae60049..8e424515778 100644
--- a/lld/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp
+++ b/lld/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp
@@ -213,7 +213,7 @@ TEST(ObjectFileYAML, oneSection) {
EXPECT_EQ((uint32_t)(sect.type), (uint32_t)(llvm::MachO::S_REGULAR));
EXPECT_EQ((uint32_t)(sect.attributes),
(uint32_t)(llvm::MachO::S_ATTR_PURE_INSTRUCTIONS));
- EXPECT_EQ(sect.alignment, 1U);
+ EXPECT_EQ(sect.alignment.get(), 2U);
EXPECT_EQ((uint64_t)sect.address, 0x12345678ULL);
EXPECT_EQ(sect.content.size(), 2UL);
EXPECT_EQ((int)(sect.content[0]), 0x90);
@@ -286,7 +286,7 @@ TEST(ObjectFileYAML, hello_x86_64) {
EXPECT_EQ((uint32_t)(sect1.attributes),
(uint32_t)(llvm::MachO::S_ATTR_PURE_INSTRUCTIONS
| llvm::MachO::S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(sect1.alignment, 0U);
+ EXPECT_EQ(sect1.alignment.get(), 1U);
EXPECT_EQ((uint64_t)sect1.address, 0x0ULL);
EXPECT_EQ(sect1.content.size(), 22UL);
EXPECT_EQ((int)(sect1.content[0]), 0x55);
@@ -316,7 +316,7 @@ TEST(ObjectFileYAML, hello_x86_64) {
EXPECT_TRUE(sect2.sectionName.equals("__cstring"));
EXPECT_EQ((uint32_t)(sect2.type), (uint32_t)(llvm::MachO::S_CSTRING_LITERALS));
EXPECT_EQ((uint32_t)(sect2.attributes), 0U);
- EXPECT_EQ(sect2.alignment, 0U);
+ EXPECT_EQ(sect2.alignment.get(), 1U);
EXPECT_EQ((uint64_t)sect2.address, 0x016ULL);
EXPECT_EQ(sect2.content.size(), 7UL);
EXPECT_EQ((int)(sect2.content[0]), 0x68);
@@ -417,7 +417,7 @@ TEST(ObjectFileYAML, hello_x86) {
EXPECT_EQ((uint32_t)(sect1.attributes),
(uint32_t)(llvm::MachO::S_ATTR_PURE_INSTRUCTIONS
| llvm::MachO::S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(sect1.alignment, 0U);
+ EXPECT_EQ(sect1.alignment.get(), 1U);
EXPECT_EQ((uint64_t)sect1.address, 0x0ULL);
EXPECT_EQ(sect1.content.size(), 33UL);
EXPECT_EQ((int)(sect1.content[0]), 0x55);
@@ -454,7 +454,7 @@ TEST(ObjectFileYAML, hello_x86) {
EXPECT_TRUE(sect2.sectionName.equals("__cstring"));
EXPECT_EQ((uint32_t)(sect2.type), (uint32_t)(llvm::MachO::S_CSTRING_LITERALS));
EXPECT_EQ((uint32_t)(sect2.attributes), 0U);
- EXPECT_EQ(sect2.alignment, 0U);
+ EXPECT_EQ(sect2.alignment.get(), 1U);
EXPECT_EQ((uint64_t)sect2.address, 0x021ULL);
EXPECT_EQ(sect2.content.size(), 7UL);
EXPECT_EQ((int)(sect2.content[0]), 0x68);
@@ -545,7 +545,7 @@ TEST(ObjectFileYAML, hello_armv6) {
EXPECT_EQ((uint32_t)(sect1.attributes),
(uint32_t)(llvm::MachO::S_ATTR_PURE_INSTRUCTIONS
| llvm::MachO::S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(sect1.alignment, 2U);
+ EXPECT_EQ(sect1.alignment.get(), 4U);
EXPECT_EQ((uint64_t)sect1.address, 0x0ULL);
EXPECT_EQ(sect1.content.size(), 32UL);
EXPECT_EQ((int)(sect1.content[0]), 0x80);
@@ -582,7 +582,7 @@ TEST(ObjectFileYAML, hello_armv6) {
EXPECT_TRUE(sect2.sectionName.equals("__cstring"));
EXPECT_EQ((uint32_t)(sect2.type), (uint32_t)(llvm::MachO::S_CSTRING_LITERALS));
EXPECT_EQ((uint32_t)(sect2.attributes), 0U);
- EXPECT_EQ(sect2.alignment, 0U);
+ EXPECT_EQ(sect2.alignment.get(), 1U);
EXPECT_EQ((uint64_t)sect2.address, 0x020ULL);
EXPECT_EQ(sect2.content.size(), 7UL);
EXPECT_EQ((int)(sect2.content[0]), 0x68);
@@ -687,7 +687,7 @@ TEST(ObjectFileYAML, hello_armv7) {
EXPECT_EQ((uint32_t)(sect1.attributes),
(uint32_t)(llvm::MachO::S_ATTR_PURE_INSTRUCTIONS
| llvm::MachO::S_ATTR_SOME_INSTRUCTIONS));
- EXPECT_EQ(sect1.alignment, 1U);
+ EXPECT_EQ(sect1.alignment.get(), 2U);
EXPECT_EQ((uint64_t)sect1.address, 0x0ULL);
EXPECT_EQ(sect1.content.size(), 22UL);
EXPECT_EQ((int)(sect1.content[0]), 0x80);
@@ -740,7 +740,7 @@ TEST(ObjectFileYAML, hello_armv7) {
EXPECT_TRUE(sect2.sectionName.equals("__cstring"));
EXPECT_EQ((uint32_t)(sect2.type), (uint32_t)(llvm::MachO::S_CSTRING_LITERALS));
EXPECT_EQ((uint32_t)(sect2.attributes), 0U);
- EXPECT_EQ(sect2.alignment, 0U);
+ EXPECT_EQ(sect2.alignment.get(), 1U);
EXPECT_EQ((uint64_t)sect2.address, 0x016ULL);
EXPECT_EQ(sect2.content.size(), 7UL);
EXPECT_EQ((int)(sect2.content[0]), 0x68);
OpenPOWER on IntegriCloud