File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,22 @@ LLVMMemoryBufferRef LLVMBinaryCopyMemoryBuffer(LLVMBinaryRef BR);
102
102
*/
103
103
LLVMBinaryType LLVMBinaryGetType (LLVMBinaryRef BR);
104
104
105
+ /*
106
+ * For a Mach-O universal binary file, retrieves the object file corresponding
107
+ * to the given architecture if it is present as a slice.
108
+ *
109
+ * If NULL is returned, the \p ErrorMessage parameter is populated with the
110
+ * error's description. It is then the caller's responsibility to free this
111
+ * message by calling \c LLVMDisposeMessage.
112
+ *
113
+ * It is the responsiblity of the caller to free the returned object file by
114
+ * calling \c LLVMDisposeBinary.
115
+ */
116
+ LLVMBinaryRef LLVMMachOUniversalBinaryCopyObjectForArch (LLVMBinaryRef BR,
117
+ const char *Arch,
118
+ size_t ArchLen,
119
+ char **ErrorMessage);
120
+
105
121
/* *
106
122
* Retrieve a copy of the section iterator for this object file.
107
123
*
Original file line number Diff line number Diff line change 15
15
#include " llvm/ADT/SmallVector.h"
16
16
#include " llvm/IR/LLVMContext.h"
17
17
#include " llvm/Object/ObjectFile.h"
18
+ #include " llvm/Object/MachOUniversal.h"
18
19
19
20
using namespace llvm ;
20
21
using namespace object ;
@@ -131,6 +132,20 @@ LLVMBinaryType LLVMBinaryGetType(LLVMBinaryRef BR) {
131
132
return BinaryTypeMapper::mapBinaryTypeToLLVMBinaryType (unwrap (BR)->getType ());
132
133
}
133
134
135
+ LLVMBinaryRef LLVMMachOUniversalBinaryCopyObjectForArch (LLVMBinaryRef BR,
136
+ const char *Arch,
137
+ size_t ArchLen,
138
+ char **ErrorMessage) {
139
+ auto universal = cast<MachOUniversalBinary>(unwrap (BR));
140
+ Expected<std::unique_ptr<ObjectFile>> ObjOrErr (
141
+ universal->getObjectForArch ({Arch, ArchLen}));
142
+ if (!ObjOrErr) {
143
+ *ErrorMessage = strdup (toString (ObjOrErr.takeError ()).c_str ());
144
+ return nullptr ;
145
+ }
146
+ return wrap (ObjOrErr.get ().release ());
147
+ }
148
+
134
149
LLVMSectionIteratorRef LLVMObjectFileCopySectionIterator (LLVMBinaryRef BR) {
135
150
auto OF = cast<ObjectFile>(unwrap (BR));
136
151
auto sections = OF->sections ();
You can’t perform that action at this time.
0 commit comments