llvm.org GIT mirror llvm / 4d78302
[LLVM-C] Add Accessor for Mach-O Universal Binary Slices Summary: Allow for retrieving an object file corresponding to an architecture-specific slice in a Mach-O universal binary file. Reviewers: whitequark, deadalnix Reviewed By: whitequark Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60378 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361705 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 3 months ago
2 changed file(s) with 31 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
101101 */
102102 LLVMBinaryType LLVMBinaryGetType(LLVMBinaryRef BR);
103103
104 /*
105 * For a Mach-O universal binary file, retrieves the object file corresponding
106 * to the given architecture if it is present as a slice.
107 *
108 * If NULL is returned, the \p ErrorMessage parameter is populated with the
109 * error's description. It is then the caller's responsibility to free this
110 * message by calling \c LLVMDisposeMessage.
111 *
112 * It is the responsiblity of the caller to free the returned object file by
113 * calling \c LLVMDisposeBinary.
114 */
115 LLVMBinaryRef LLVMMachOUniversalBinaryCopyObjectForArch(LLVMBinaryRef BR,
116 const char *Arch,
117 size_t ArchLen,
118 char **ErrorMessage);
119
104120 /**
105121 * Retrieve a copy of the section iterator for this object file.
106122 *
1414 #include "llvm/ADT/SmallVector.h"
1515 #include "llvm/IR/LLVMContext.h"
1616 #include "llvm/Object/ObjectFile.h"
17 #include "llvm/Object/MachOUniversal.h"
1718
1819 using namespace llvm;
1920 using namespace object;
130131 return BinaryTypeMapper::mapBinaryTypeToLLVMBinaryType(unwrap(BR)->getType());
131132 }
132133
134 LLVMBinaryRef LLVMMachOUniversalBinaryCopyObjectForArch(LLVMBinaryRef BR,
135 const char *Arch,
136 size_t ArchLen,
137 char **ErrorMessage) {
138 auto universal = cast(unwrap(BR));
139 Expected> ObjOrErr(
140 universal->getObjectForArch({Arch, ArchLen}));
141 if (!ObjOrErr) {
142 *ErrorMessage = strdup(toString(ObjOrErr.takeError()).c_str());
143 return nullptr;
144 }
145 return wrap(ObjOrErr.get().release());
146 }
147
133148 LLVMSectionIteratorRef LLVMObjectFileCopySectionIterator(LLVMBinaryRef BR) {
134149 auto OF = cast(unwrap(BR));
135150 auto sections = OF->sections();