Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 474748 | Differences between
and this patch

Collapse All | Expand All

(-)a/ld/InputFiles.cpp (+8 lines)
Lines 58-64 Link Here
58
#include "macho_relocatable_file.h"
58
#include "macho_relocatable_file.h"
59
#include "macho_dylib_file.h"
59
#include "macho_dylib_file.h"
60
#include "archive_file.h"
60
#include "archive_file.h"
61
#ifdef LTO
61
#include "lto_file.h"
62
#include "lto_file.h"
63
#endif
62
#include "opaque_section_file.h"
64
#include "opaque_section_file.h"
63
#include "Snapshot.h"
65
#include "Snapshot.h"
64
66
Lines 181-189 const char* InputFiles::fileArch(const uint8_t* p, unsigned len) Link Here
181
	if ( result != NULL  )
183
	if ( result != NULL  )
182
		 return result;
184
		 return result;
183
		 
185
		 
186
#ifdef LTO
184
	result = lto::archName(p, len);
187
	result = lto::archName(p, len);
185
	if ( result != NULL  )
188
	if ( result != NULL  )
186
		 return result;
189
		 return result;
190
#endif
187
	
191
	
188
	if ( strncmp((const char*)p, "!<arch>\n", 8) == 0 )
192
	if ( strncmp((const char*)p, "!<arch>\n", 8) == 0 )
189
		return "archive";
193
		return "archive";
Lines 282-287 ld::File* InputFiles::makeFile(const Options::FileInfo& info, bool indirectDylib Link Here
282
		return objResult;
286
		return objResult;
283
	}
287
	}
284
288
289
#ifdef LTO
285
	// see if it is an llvm object file
290
	// see if it is an llvm object file
286
	objResult = lto::parse(p, len, info.path, info.modTime, info.ordinal, _options.architecture(), _options.subArchitecture(), _options.logAllFiles());
291
	objResult = lto::parse(p, len, info.path, info.modTime, info.ordinal, _options.architecture(), _options.subArchitecture(), _options.logAllFiles());
287
	if ( objResult != NULL ) {
292
	if ( objResult != NULL ) {
Lines 289-294 ld::File* InputFiles::makeFile(const Options::FileInfo& info, bool indirectDylib Link Here
289
		OSAtomicIncrement32(&_totalObjectLoaded);
294
		OSAtomicIncrement32(&_totalObjectLoaded);
290
		return objResult;
295
		return objResult;
291
	}
296
	}
297
#endif
292
	
298
	
293
	// see if it is a dynamic library
299
	// see if it is a dynamic library
294
	ld::dylib::File* dylibResult = mach_o::dylib::parse(p, len, info.path, info.modTime, _options, info.ordinal, info.options.fBundleLoader, indirectDylib);
300
	ld::dylib::File* dylibResult = mach_o::dylib::parse(p, len, info.path, info.modTime, _options, info.ordinal, info.options.fBundleLoader, indirectDylib);
Lines 312-317 ld::File* InputFiles::makeFile(const Options::FileInfo& info, bool indirectDylib Link Here
312
		return archiveResult;
318
		return archiveResult;
313
	}
319
	}
314
	
320
	
321
#ifdef LTO
315
	// does not seem to be any valid linker input file, check LTO misconfiguration problems
322
	// does not seem to be any valid linker input file, check LTO misconfiguration problems
316
	if ( lto::archName((uint8_t*)p, len) != NULL ) {
323
	if ( lto::archName((uint8_t*)p, len) != NULL ) {
317
		if ( lto::libLTOisLoaded() ) {
324
		if ( lto::libLTOisLoaded() ) {
Lines 339-344 ld::File* InputFiles::makeFile(const Options::FileInfo& info, bool indirectDylib Link Here
339
			throwf("could not process llvm bitcode object file, because %s could not be loaded", libLTO);
346
			throwf("could not process llvm bitcode object file, because %s could not be loaded", libLTO);
340
		}
347
		}
341
	}
348
	}
349
#endif
342
350
343
	// error handling
351
	// error handling
344
	if ( ((fat_header*)p)->magic == OSSwapBigToHostInt32(FAT_MAGIC) ) {
352
	if ( ((fat_header*)p)->magic == OSSwapBigToHostInt32(FAT_MAGIC) ) {
(-)a/ld/Options.cpp (+6 lines)
Lines 42-51 Link Here
42
#include "MachOFileAbstraction.hpp"
42
#include "MachOFileAbstraction.hpp"
43
#include "Snapshot.h"
43
#include "Snapshot.h"
44
44
45
46
#define ALL_SUPPORTED_ARCHS "x86_64 i386"
47
#ifdef LTO
45
// upward dependency on lto::version()
48
// upward dependency on lto::version()
46
namespace lto {
49
namespace lto {
47
	extern const char* version();
50
	extern const char* version();
48
}
51
}
52
#endif
49
53
50
// magic to place command line in crash reports
54
// magic to place command line in crash reports
51
const int crashreporterBufferSize = 2000;
55
const int crashreporterBufferSize = 2000;
Lines 2894-2903 void Options::buildSearchPaths(int argc, const char* argv[]) Link Here
2894
			fprintf(stderr, "configured to support archs: %s\n", ALL_SUPPORTED_ARCHS);
2898
			fprintf(stderr, "configured to support archs: %s\n", ALL_SUPPORTED_ARCHS);
2895
			 // if only -v specified, exit cleanly
2899
			 // if only -v specified, exit cleanly
2896
			 if ( argc == 2 ) {
2900
			 if ( argc == 2 ) {
2901
#ifdef LTO
2897
				const char* ltoVers = lto::version();
2902
				const char* ltoVers = lto::version();
2898
				if ( ltoVers != NULL )
2903
				if ( ltoVers != NULL )
2899
					fprintf(stderr, "LTO support using: %s\n", ltoVers);
2904
					fprintf(stderr, "LTO support using: %s\n", ltoVers);
2900
				exit(0);
2905
				exit(0);
2906
#endif
2901
			}
2907
			}
2902
		}
2908
		}
2903
		else if ( strcmp(argv[i], "-syslibroot") == 0 ) {
2909
		else if ( strcmp(argv[i], "-syslibroot") == 0 ) {
(-)a/ld/Resolver.cpp (+6 lines)
Lines 56-62 Link Here
56
#include "InputFiles.h"
56
#include "InputFiles.h"
57
#include "SymbolTable.h"
57
#include "SymbolTable.h"
58
#include "Resolver.h"
58
#include "Resolver.h"
59
#ifdef LTO
59
#include "parsers/lto_file.h"
60
#include "parsers/lto_file.h"
61
#endif
60
62
61
63
62
namespace ld {
64
namespace ld {
Lines 1321-1326 void Resolver::removeCoalescedAwayAtoms() Link Here
1321
1323
1322
void Resolver::linkTimeOptimize()
1324
void Resolver::linkTimeOptimize()
1323
{
1325
{
1326
#ifdef LTO
1324
	// only do work here if some llvm obj files where loaded
1327
	// only do work here if some llvm obj files where loaded
1325
	if ( ! _haveLLVMObjs )
1328
	if ( ! _haveLLVMObjs )
1326
		return;
1329
		return;
Lines 1407-1412 void Resolver::linkTimeOptimize() Link Here
1407
		// check new code does not override some dylib
1410
		// check new code does not override some dylib
1408
		this->checkDylibSymbolCollisions();
1411
		this->checkDylibSymbolCollisions();
1409
	}
1412
	}
1413
#else
1414
  return;
1415
#endif
1410
}
1416
}
1411
1417
1412
1418
(-)a/ld/ld.cpp (+2 lines)
Lines 83-89 extern "C" double log2 ( double ); Link Here
83
#include "parsers/archive_file.h"
83
#include "parsers/archive_file.h"
84
#include "parsers/macho_relocatable_file.h"
84
#include "parsers/macho_relocatable_file.h"
85
#include "parsers/macho_dylib_file.h"
85
#include "parsers/macho_dylib_file.h"
86
#ifdef LTO
86
#include "parsers/lto_file.h"
87
#include "parsers/lto_file.h"
88
#endif
87
#include "parsers/opaque_section_file.h"
89
#include "parsers/opaque_section_file.h"
88
90
89
91
(-)a/ld/parsers/archive_file.cpp (-1 / +13 lines)
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
	}
(-)a/other/ObjectDump.cpp (+4 lines)
Lines 33-39 Link Here
33
33
34
#include "MachOFileAbstraction.hpp"
34
#include "MachOFileAbstraction.hpp"
35
#include "parsers/macho_relocatable_file.h"
35
#include "parsers/macho_relocatable_file.h"
36
#ifdef LTO
36
#include "parsers/lto_file.h"
37
#include "parsers/lto_file.h"
38
#endif
37
39
38
static bool			sDumpContent= true;
40
static bool			sDumpContent= true;
39
static bool			sDumpStabs	= false;
41
static bool			sDumpStabs	= false;
Lines 1132-1141 static ld::relocatable::File* createReader(const char* path) Link Here
1132
	if ( objResult != NULL )
1134
	if ( objResult != NULL )
1133
		return objResult;
1135
		return objResult;
1134
1136
1137
#ifdef LTO
1135
	// see if it is an llvm object file
1138
	// see if it is an llvm object file
1136
	objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, ld::File::Ordinal::NullOrdinal(), sPreferredArch, sPreferredSubArch, false);
1139
	objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, ld::File::Ordinal::NullOrdinal(), sPreferredArch, sPreferredSubArch, false);
1137
	if ( objResult != NULL ) 
1140
	if ( objResult != NULL ) 
1138
		return objResult;
1141
		return objResult;
1142
#endif
1139
1143
1140
	throwf("not a mach-o object file: %s", path);
1144
	throwf("not a mach-o object file: %s", path);
1141
#else
1145
#else

Return to bug 474748