summaryrefslogtreecommitdiffstats
path: root/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
diff options
context:
space:
mode:
authorJoey Gouly <joey.gouly@gmail.com>2014-01-14 22:32:38 +0000
committerJoey Gouly <joey.gouly@gmail.com>2014-01-14 22:32:38 +0000
commit010b37691ddeb161f824bc3013e72deb090fc29a (patch)
tree6b2fd0066c2b45471c1ab98def2b6c0e50fedc52 /lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
parent39c17a8f3006f4e4733d28d6e830623a223744a8 (diff)
downloadbcm5719-llvm-010b37691ddeb161f824bc3013e72deb090fc29a.tar.gz
bcm5719-llvm-010b37691ddeb161f824bc3013e72deb090fc29a.zip
[MachO] Begin support for reading fat binaries.
llvm-svn: 199259
Diffstat (limited to 'lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp')
-rw-r--r--lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp b/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
index 0e2c0838693..b4c7c9e955d 100644
--- a/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
+++ b/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
@@ -32,22 +32,20 @@ using namespace lld::mach_o::normalized;
// Parses binary mach-o file at specified path and returns
// ownership of buffer to mb parameter and ownership of
// Normalized file to nf parameter.
-static void
-fromBinary(StringRef path, std::unique_ptr<MemoryBuffer> &mb,
- std::unique_ptr<NormalizedFile> &nf) {
-
+static void fromBinary(StringRef path, std::unique_ptr<MemoryBuffer> &mb,
+ std::unique_ptr<NormalizedFile> &nf, StringRef archStr) {
OwningPtr<MemoryBuffer> opmb;
error_code ec = MemoryBuffer::getFile(path, opmb);
EXPECT_FALSE(ec);
mb.reset(opmb.take());
- ErrorOr<std::unique_ptr<NormalizedFile>> r
- = lld::mach_o::normalized::readBinary(mb);
+ ErrorOr<std::unique_ptr<NormalizedFile>> r =
+ lld::mach_o::normalized::readBinary(
+ mb, lld::MachOLinkingContext::archFromName(archStr));
EXPECT_FALSE(!r);
nf.reset(r->release());
}
-
static Relocation
makeReloc(unsigned addr, bool rel, bool ext, RelocationInfoType type,
unsigned sym) {
@@ -159,7 +157,7 @@ TEST(BinaryWriterTest, obj_relocs_x86_64) {
std::unique_ptr<MemoryBuffer> bufferOwner;
std::unique_ptr<NormalizedFile> f2;
- fromBinary(tmpFl, bufferOwner, f2);
+ fromBinary(tmpFl, bufferOwner, f2, "x86_64");
EXPECT_EQ(lld::MachOLinkingContext::arch_x86_64, f2->arch);
EXPECT_EQ(MH_OBJECT, f2->fileType);
@@ -269,7 +267,7 @@ TEST(BinaryWriterTest, obj_relocs_x86) {
}
std::unique_ptr<MemoryBuffer> bufferOwner;
std::unique_ptr<NormalizedFile> f2;
- fromBinary(tmpFl, bufferOwner, f2);
+ fromBinary(tmpFl, bufferOwner, f2, "i386");
EXPECT_EQ(lld::MachOLinkingContext::arch_x86, f2->arch);
EXPECT_EQ(MH_OBJECT, f2->fileType);
@@ -386,7 +384,7 @@ TEST(BinaryWriterTest, obj_relocs_armv7) {
}
std::unique_ptr<MemoryBuffer> bufferOwner;
std::unique_ptr<NormalizedFile> f2;
- fromBinary(tmpFl, bufferOwner, f2);
+ fromBinary(tmpFl, bufferOwner, f2, "armv7");
EXPECT_EQ(lld::MachOLinkingContext::arch_armv7, f2->arch);
EXPECT_EQ(MH_OBJECT, f2->fileType);
@@ -541,7 +539,7 @@ TEST(BinaryWriterTest, obj_relocs_ppc) {
}
std::unique_ptr<MemoryBuffer> bufferOwner;
std::unique_ptr<NormalizedFile> f2;
- fromBinary(tmpFl, bufferOwner, f2);
+ fromBinary(tmpFl, bufferOwner, f2, "ppc");
EXPECT_EQ(lld::MachOLinkingContext::arch_ppc, f2->arch);
EXPECT_EQ(MH_OBJECT, f2->fileType);
@@ -693,7 +691,3 @@ TEST(BinaryWriterTest, obj_relocs_ppc) {
EXPECT_FALSE(ec);
}
-
-
-
-
OpenPOWER on IntegriCloud