Added: trunk/patches/force_load.diff (0 => 155)
--- trunk/patches/force_load.diff (rev 0)
+++ trunk/patches/force_load.diff 2009-06-28 05:02:46 UTC (rev 155)
@@ -0,0 +1,184 @@
+--- ./misc/libtool.c.orig 2009-06-14 11:26:04.000000000 -0500
++++ ./misc/libtool.c 2009-06-14 11:39:10.000000000 -0500
+@@ -699,6 +699,7 @@
+ strcmp(argv[i], "-Y") == 0 ||
+ strcmp(argv[i], "-dylib_file") == 0 ||
+ strcmp(argv[i], "-final_output") == 0 ||
++ strcmp(argv[i], "-force_load") == 0 ||
+ strcmp(argv[i], "-headerpad") == 0 ||
+ strcmp(argv[i], "-weak_reference_mismatches") == 0 ||
+ strcmp(argv[i], "-u") == 0 ||
+--- ./man/libtool.1.orig 2009-06-14 11:39:35.000000000 -0500
++++ ./man/libtool.1 2009-06-14 11:39:43.000000000 -0500
+@@ -288,6 +288,7 @@
+ .B \-dylib_file,
+ .B \-run_init_lazily,
+ .B \-final_output,
++.B \-force_load,
+ .B \-macosx_version_min,
+ .B \-multiply_defined,
+ .B \-multiply_defined_unused,
+--- ld64/src/ArchiveReader.hpp.orig 2009-06-14 11:37:02.000000000 -0500
++++ ld64/src/ArchiveReader.hpp 2009-06-14 11:38:17.000000000 -0500
+@@ -54,7 +54,8 @@
+ public:
+ static bool validFile(const uint8_t* fileContent, uint64_t fileLength);
+ Reader(const uint8_t fileContent[], uint64_t fileLength,
+- const char* path, time_t modTime,
++ const char* path, time_t modTime,
++ const DynamicLibraryOptions& ArchiveOptions,
+ const ObjectFile::ReaderOptions& options, uint32_t ordinalBase);
+ virtual ~Reader() {}
+
+@@ -121,6 +122,7 @@
+ std::set<const class Entry*> fInstantiatedEntries;
+ std::set<const class Entry*> fPossibleEntries;
+ NameToEntryMap fHashTable;
++ bool fForceLoad;
+
+ static std::vector<class ObjectFile::Atom*> fgEmptyList;
+ };
+@@ -257,10 +259,11 @@
+ }
+
+ template <typename A>
+-Reader<A>::Reader(const uint8_t fileContent[], uint64_t fileLength, const char* path, time_t modTime,
++Reader<A>::Reader(const uint8_t fileContent[], uint64_t fileLength, const char* path, time_t modTime,
++ const DynamicLibraryOptions& archiveOptions,
+ const ObjectFile::ReaderOptions& options, uint32_t ordinalBase)
+ : fPath(NULL), fModTime(modTime), fOptions(options), fOrdinalBase(ordinalBase), fFileContent(NULL),
+- fTableOfContents(NULL), fTableOfContentCount(0), fStringPool(NULL)
++ fTableOfContents(NULL), fTableOfContentCount(0), fStringPool(NULL), fForceLoad(archiveOptions.fForceLoad)
+ {
+ fPath = strdup(path);
+ fFileContent = fileContent;
+@@ -273,7 +276,7 @@
+ if ( options.fLogAllFiles )
+ printf("%s\n", path);
+
+- if ( !options.fFullyLoadArchives ) {
++ if ( !options.fFullyLoadArchives && !fForceLoad) {
+ const Entry* const firstMember = (Entry*)&fFileContent[8];
+ if ( (strcmp(firstMember->getName(), SYMDEF_SORTED) == 0) || (strcmp(firstMember->getName(), SYMDEF) == 0) ) {
+ const uint8_t* contents = firstMember->getContent();
+@@ -324,7 +327,7 @@
+ template <typename A>
+ std::vector<class ObjectFile::Atom*>& Reader<A>::getAtoms()
+ {
+- if ( fOptions.fFullyLoadArchives ) {
++ if ( fOptions.fFullyLoadArchives || fForceLoad) {
+ // build vector of all atoms from all .o files in this archive
+ const Entry* const start = (Entry*)&fFileContent[8];
+ const Entry* const end = (Entry*)&fFileContent[fFileLength];
+@@ -332,8 +335,12 @@
+ const char* memberName = p->getName();
+ if ( (p==start) && ((strcmp(memberName, SYMDEF_SORTED) == 0) || (strcmp(memberName, SYMDEF) == 0)) )
+ continue;
+- if ( fOptions.fWhyLoad )
+- printf("-all_load forced load of %s(%s)\n", this->getPath(), memberName);
++ if ( fOptions.fWhyLoad ) {
++ if (! fForceLoad)
++ printf("-all_load forced load of %s(%s)\n", this->getPath(), memberName);
++ else
++ printf("-force_load forced load of %s(%s)\n", this->getPath(), memberName);
++ }
+ ObjectFile::Reader* r = this->makeObjectReaderForMember(p);
+ std::vector<class ObjectFile::Atom*>& atoms = r->getAtoms();
+ fAllAtoms.insert(fAllAtoms.end(), atoms.begin(), atoms.end());
+@@ -420,7 +427,7 @@
+ template <typename A>
+ std::vector<class ObjectFile::Atom*>* Reader<A>::getJustInTimeAtomsFor(const char* name)
+ {
+- if ( fOptions.fFullyLoadArchives ) {
++ if ( fOptions.fFullyLoadArchives || fForceLoad ) {
+ return NULL;
+ }
+ else {
+--- ld64/src/Options.cpp.orig 2009-06-14 11:37:02.000000000 -0500
++++ ld64/src/Options.cpp 2009-06-14 11:38:17.000000000 -0500
+@@ -1548,6 +1548,9 @@
+ // if dylib is specified again but weak, record that it should be weak
+ if ( info.options.fWeakImport )
+ fit->options.fWeakImport = true;
++ // Similarly for -force_load
++ if ( info.options.fForceLoad )
++ fit->options.fForceLoad = true;
+ return;
+ }
+ }
+@@ -1676,6 +1679,12 @@
+ else if ( strcmp(arg, "-ObjC") == 0 ) {
+ fReaderOptions.fLoadAllObjcObjectsFromArchives = true;
+ }
++ // Similar to -all_load, but for the following archive only.
++ else if ( strcmp(arg, "-force_load") == 0 ) {
++ FileInfo info = findFile(argv[++i]);
++ info.options.fForceLoad = true;
++ addLibrary(info);
++ }
+ // Library versioning.
+ else if ( (strcmp(arg, "-dylib_compatibility_version") == 0)
+ || (strcmp(arg, "-compatibility_version") == 0)) {
+--- ld64/src/ld.cpp.orig 2009-06-14 11:37:02.000000000 -0500
++++ ld64/src/ld.cpp 2009-06-14 11:38:17.000000000 -0500
+@@ -2917,7 +2917,7 @@
+ else if ( mach_o::dylib::Reader<ppc>::validFile(p, info.options.fBundleLoader) )
+ return this->addDylib(new mach_o::dylib::Reader<ppc>::Reader(p, len, info.path, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ else if ( archive::Reader<ppc>::validFile(p, len) )
+- return this->addArchive(new archive::Reader<ppc>::Reader(p, len, info.path, info.modTime, fOptions.readerOptions(), fNextInputOrdinal), info, len);
++ return this->addArchive(new archive::Reader<ppc>::Reader(p, len, info.path, info.modTime, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ break;
+ case CPU_TYPE_POWERPC64:
+ if ( mach_o::relocatable::Reader<ppc64>::validFile(p) )
+@@ -2925,7 +2925,7 @@
+ else if ( mach_o::dylib::Reader<ppc64>::validFile(p, info.options.fBundleLoader) )
+ return this->addDylib(new mach_o::dylib::Reader<ppc64>::Reader(p, len, info.path, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ else if ( archive::Reader<ppc64>::validFile(p, len) )
+- return this->addArchive(new archive::Reader<ppc64>::Reader(p, len, info.path, info.modTime, fOptions.readerOptions(), fNextInputOrdinal), info, len);
++ return this->addArchive(new archive::Reader<ppc64>::Reader(p, len, info.path, info.modTime, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ break;
+ case CPU_TYPE_I386:
+ if ( mach_o::relocatable::Reader<x86>::validFile(p) )
+@@ -2933,7 +2933,7 @@
+ else if ( mach_o::dylib::Reader<x86>::validFile(p, info.options.fBundleLoader) )
+ return this->addDylib(new mach_o::dylib::Reader<x86>::Reader(p, len, info.path, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ else if ( archive::Reader<x86>::validFile(p, len) )
+- return this->addArchive(new archive::Reader<x86>::Reader(p, len, info.path, info.modTime, fOptions.readerOptions(), fNextInputOrdinal), info, len);
++ return this->addArchive(new archive::Reader<x86>::Reader(p, len, info.path, info.modTime, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ break;
+ case CPU_TYPE_X86_64:
+ if ( mach_o::relocatable::Reader<x86_64>::validFile(p) )
+@@ -2941,14 +2941,14 @@
+ else if ( mach_o::dylib::Reader<x86_64>::validFile(p, info.options.fBundleLoader) )
+ return this->addDylib(new mach_o::dylib::Reader<x86_64>::Reader(p, len, info.path, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ else if ( archive::Reader<x86_64>::validFile(p, len) )
+- return this->addArchive(new archive::Reader<x86_64>::Reader(p, len, info.path, info.modTime, fOptions.readerOptions(), fNextInputOrdinal), info, len);
++ return this->addArchive(new archive::Reader<x86_64>::Reader(p, len, info.path, info.modTime, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ case CPU_TYPE_ARM:
+ if ( mach_o::relocatable::Reader<arm>::validFile(p) )
+ return this->addObject(new mach_o::relocatable::Reader<arm>::Reader(p, info.path, info.modTime, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ else if ( mach_o::dylib::Reader<arm>::validFile(p, info.options.fBundleLoader) )
+ return this->addDylib(new mach_o::dylib::Reader<arm>::Reader(p, len, info.path, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ else if ( archive::Reader<arm>::validFile(p, len) )
+- return this->addArchive(new archive::Reader<arm>::Reader(p, len, info.path, info.modTime, fOptions.readerOptions(), fNextInputOrdinal), info, len);
++ return this->addArchive(new archive::Reader<arm>::Reader(p, len, info.path, info.modTime, info.options, fOptions.readerOptions(), fNextInputOrdinal), info, len);
+ break;
+ break;
+ }
+--- ld64/src/Options.h.orig 2009-06-14 11:37:02.000000000 -0500
++++ ld64/src/Options.h 2009-06-14 11:38:17.000000000 -0500
+@@ -43,12 +43,13 @@
+ class DynamicLibraryOptions
+ {
+ public:
+- DynamicLibraryOptions() : fWeakImport(false), fReExport(false), fBundleLoader(false), fLazyLoad(false) {}
++ DynamicLibraryOptions() : fWeakImport(false), fReExport(false), fBundleLoader(false), fLazyLoad(false), fForceLoad(false) {}
+
+ bool fWeakImport;
+ bool fReExport;
+ bool fBundleLoader;
+ bool fLazyLoad;
++ bool fForceLoad;
+ };
+
+ //