summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2014-05-14 21:18:50 +0000
committerKevin Enderby <enderby@apple.com>2014-05-14 21:18:50 +0000
commit14963a696b8c4dc89409889288e85f531bd59534 (patch)
treead667409d3bd4d20e9c5779e7818c4c0d11bbeda /lib
parent6b543713a25c20c028cc0bbca0dd8b052c61e000 (diff)
Teach llvm-nm to know about fat archives (aka MachOUniversal files
containing archives). First step as other tools will be updated next. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208812 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Object/MachOUniversal.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Object/MachOUniversal.cpp b/lib/Object/MachOUniversal.cpp
index 3f3731f22d8..5085efde5ec 100644
--- a/lib/Object/MachOUniversal.cpp
+++ b/lib/Object/MachOUniversal.cpp
@@ -14,6 +14,7 @@
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/Archive.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -90,6 +91,25 @@ error_code MachOUniversalBinary::ObjectForArch::getAsObjectFile(
return object_error::parse_failed;
}
+error_code MachOUniversalBinary::ObjectForArch::getAsArchive(
+ std::unique_ptr<Archive> &Result) const {
+ if (Parent) {
+ StringRef ParentData = Parent->getData();
+ StringRef ObjectData = ParentData.substr(Header.offset, Header.size);
+ std::string ObjectName =
+ Parent->getFileName().str() + ":" +
+ Triple::getArchTypeName(MachOObjectFile::getArch(Header.cputype));
+ MemoryBuffer *ObjBuffer = MemoryBuffer::getMemBuffer(
+ ObjectData, ObjectName, false);
+ ErrorOr<Archive *> Obj = Archive::create(ObjBuffer);
+ if (error_code EC = Obj.getError())
+ return EC;
+ Result.reset(Obj.get());
+ return object_error::success;
+ }
+ return object_error::parse_failed;
+}
+
void MachOUniversalBinary::anchor() { }
ErrorOr<MachOUniversalBinary *>