Lines 39-45
Link Here
|
39 |
#include "Architectures.hpp" |
39 |
#include "Architectures.hpp" |
40 |
|
40 |
|
41 |
#include "macho_relocatable_file.h" |
41 |
#include "macho_relocatable_file.h" |
|
|
42 |
#ifdef LTO |
42 |
#include "lto_file.h" |
43 |
#include "lto_file.h" |
|
|
44 |
#endif |
43 |
#include "archive_file.h" |
45 |
#include "archive_file.h" |
44 |
|
46 |
|
45 |
|
47 |
|
Lines 91-98
public:
Link Here
|
91 |
private: |
93 |
private: |
92 |
static bool validMachOFile(const uint8_t* fileContent, uint64_t fileLength, |
94 |
static bool validMachOFile(const uint8_t* fileContent, uint64_t fileLength, |
93 |
const mach_o::relocatable::ParserOptions& opts); |
95 |
const mach_o::relocatable::ParserOptions& opts); |
|
|
96 |
#ifdef LTO |
94 |
static bool validLTOFile(const uint8_t* fileContent, uint64_t fileLength, |
97 |
static bool validLTOFile(const uint8_t* fileContent, uint64_t fileLength, |
95 |
const mach_o::relocatable::ParserOptions& opts); |
98 |
const mach_o::relocatable::ParserOptions& opts); |
|
|
99 |
#endif |
96 |
static cpu_type_t architecture(); |
100 |
static cpu_type_t architecture(); |
97 |
|
101 |
|
98 |
class Entry : ar_hdr |
102 |
class Entry : ar_hdr |
Lines 231-241
bool File<A>::validMachOFile(const uint8_t* fileContent, uint64_t fileLength, co
Link Here
|
231 |
return mach_o::relocatable::isObjectFile(fileContent, fileLength, opts); |
235 |
return mach_o::relocatable::isObjectFile(fileContent, fileLength, opts); |
232 |
} |
236 |
} |
233 |
|
237 |
|
|
|
238 |
#ifdef LTO |
234 |
template <typename A> |
239 |
template <typename A> |
235 |
bool File<A>::validLTOFile(const uint8_t* fileContent, uint64_t fileLength, const mach_o::relocatable::ParserOptions& opts) |
240 |
bool File<A>::validLTOFile(const uint8_t* fileContent, uint64_t fileLength, const mach_o::relocatable::ParserOptions& opts) |
236 |
{ |
241 |
{ |
237 |
return lto::isObjectFile(fileContent, fileLength, opts.architecture, opts.subType); |
242 |
return lto::isObjectFile(fileContent, fileLength, opts.architecture, opts.subType); |
238 |
} |
243 |
} |
|
|
244 |
#endif |
239 |
|
245 |
|
240 |
|
246 |
|
241 |
|
247 |
|
Lines 256-262
bool File<A>::validFile(const uint8_t* fileContent, uint64_t fileLength, const m
Link Here
|
256 |
if ( (p==start) && ((strcmp(memberName, SYMDEF_SORTED) == 0) || (strcmp(memberName, SYMDEF) == 0)) ) |
262 |
if ( (p==start) && ((strcmp(memberName, SYMDEF_SORTED) == 0) || (strcmp(memberName, SYMDEF) == 0)) ) |
257 |
continue; |
263 |
continue; |
258 |
// archive is valid if first .o file is valid |
264 |
// archive is valid if first .o file is valid |
259 |
return (validMachOFile(p->content(), p->contentSize(), opts) || validLTOFile(p->content(), p->contentSize(), opts)); |
265 |
return (validMachOFile(p->content(), p->contentSize(), opts) |
|
|
266 |
#ifdef LTO |
267 |
|| validLTOFile(p->content(), p->contentSize(), opts) |
268 |
#endif |
269 |
); |
260 |
} |
270 |
} |
261 |
// empty archive |
271 |
// empty archive |
262 |
return true; |
272 |
return true; |
Lines 377-382
typename File<A>::MemberState& File<A>::makeObjectFileForMember(const Entry* mem
Link Here
|
377 |
_instantiatedEntries[member] = state; |
387 |
_instantiatedEntries[member] = state; |
378 |
return _instantiatedEntries[member]; |
388 |
return _instantiatedEntries[member]; |
379 |
} |
389 |
} |
|
|
390 |
#ifdef LTO |
380 |
// see if member is llvm bitcode file |
391 |
// see if member is llvm bitcode file |
381 |
result = lto::parse(member->content(), member->contentSize(), |
392 |
result = lto::parse(member->content(), member->contentSize(), |
382 |
mPath, member->modificationTime(), ordinal, |
393 |
mPath, member->modificationTime(), ordinal, |
Lines 386-391
typename File<A>::MemberState& File<A>::makeObjectFileForMember(const Entry* mem
Link Here
|
386 |
_instantiatedEntries[member] = state; |
397 |
_instantiatedEntries[member] = state; |
387 |
return _instantiatedEntries[member]; |
398 |
return _instantiatedEntries[member]; |
388 |
} |
399 |
} |
|
|
400 |
#endif |
389 |
|
401 |
|
390 |
throwf("archive member '%s' with length %d is not mach-o or llvm bitcode", memberName, member->contentSize()); |
402 |
throwf("archive member '%s' with length %d is not mach-o or llvm bitcode", memberName, member->contentSize()); |
391 |
} |
403 |
} |