diff -u'rF^function' tools/llvm-ld/Optimize.cpp tools/llvm-ld/Optimize.cpp
--- tools/llvm-ld/Optimize.cpp	2006-06-16 20:23:48.000000000 +0200
+++ tools/llvm-ld/Optimize.cpp	2006-08-18 16:36:39.000000000 +0200
@@ -21,8 +21,16 @@
 #include "llvm/Target/TargetData.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/Scalar.h"
+#include "llvm/Support/PassNameParser.h"
+#include "llvm/Support/PluginLoader.h"
 using namespace llvm;
 
+// Pass Name Options (cf. opt)
+
+static cl::list<const PassInfo*, bool,
+                FilteredPassNameParser<PassInfo::Optimization> >
+OptimizationList(cl::desc("Optimizations available:"));
+
 // Optimization Options
 
 enum OptimizationLevels {
@@ -72,9 +80,10 @@
   cl::aliasopt(DisableInternalize),
   cl::desc("Alias for -disable-internalize"));
 
-static cl::list<std::string> LoadableModules("load",
+//disambiguate with -load option from llvm/Support/PluginLoader.h
+/*static cl::list<std::string> LoadableModules("load",
   cl::value_desc("path"),
-  cl::desc("Load an optimization module and run it"));
+  cl::desc("Load an optimization module and run it"));*/
 
 // A utility function that adds a pass to the pass manager but will also add
 // a verifier pass after if we're supposed to verify.
@@ -168,7 +177,8 @@
     addPass(Passes, createGlobalDCEPass());
   }
 
-  std::vector<std::string> plugins = LoadableModules;
+  // Get rid of low-level library loading: inaccessible memory for vtable?
+  /*  std::vector<std::string> plugins = LoadableModules;
   for (std::vector<std::string>::iterator I = plugins.begin(),
       E = plugins.end(); I != E; ++I) {
     sys::DynamicLibrary dll(I->c_str());
@@ -180,6 +190,29 @@
         "' is missing the RunOptimizations symbol";
     }
     (*OF)(Passes,OptLevel);
+    }*/
+
+  // Create a new optimization pass for each one specified on the command line
+  std::auto_ptr<TargetMachine> target;
+  for (unsigned i = 0; i < OptimizationList.size(); ++i) {
+    const PassInfo *Opt = OptimizationList[i];
+    
+    if (Opt->getNormalCtor())
+      Passes.add(Opt->getNormalCtor()());
+    else if (Opt->getTargetCtor()) {
+#if 0
+      if (target.get() == NULL)
+	target.reset(allocateSparcTargetMachine()); // FIXME: target option
+#endif
+      assert(target.get() && "Could not allocate target machine!");
+      Passes.add(Opt->getTargetCtor()(*target.get()));
+    } else
+      std::cerr << "llvm-ld" << ": cannot create pass: " << Opt->getPassName()
+		<< "\n";
+
+    // what's this?
+    //      if (PrintEachXForm)
+    //        Passes.add(new PrintModulePass(&std::cerr));
   }
 
   // Make sure everything is still good.
