Changes in directory llvm/tools/llvm-ld:
llvm-ld.cpp updated: 1.40 -> 1.41 --- Log message: For PR998: http://llvm.org/PR998 : Fix an infinite loop in the Linker and a few other assorted link problems. Patch contributed by Scott Michel. Thanks, Scott! --- Diffs of the changes: (+18 -12) llvm-ld.cpp | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) Index: llvm/tools/llvm-ld/llvm-ld.cpp diff -u llvm/tools/llvm-ld/llvm-ld.cpp:1.40 llvm/tools/llvm-ld/llvm-ld.cpp:1.41 --- llvm/tools/llvm-ld/llvm-ld.cpp:1.40 Sun Nov 5 13:53:08 2006 +++ llvm/tools/llvm-ld/llvm-ld.cpp Sat Nov 11 05:54:25 2006 @@ -264,7 +264,7 @@ /// Inputs: /// InputFilename - The name of the input bytecode file. /// OutputFilename - The name of the file to generate. -/// Libraries - The list of libraries with which to link. +/// LinkItems - The native libraries, files, code with which to link /// LibPaths - The list of directories in which to find libraries. /// gcc - The pathname to use for GGC. /// envp - A copy of the process's current environment. @@ -276,7 +276,7 @@ /// static int GenerateNative(const std::string &OutputFilename, const std::string &InputFilename, - const std::vector<std::string> &Libraries, + const Linker::ItemList &LinkItems, const sys::Path &gcc, char ** const envp, std::string& ErrMsg) { // Remove these environment variables from the environment of the @@ -323,10 +323,13 @@ } // Add in the libraries to link. - for (unsigned index = 0; index < Libraries.size(); index++) - if (Libraries[index] != "crtend") { - args.push_back("-l"); - args.push_back(Libraries[index].c_str()); + for (unsigned index = 0; index < LinkItems.size(); index++) + if (LinkItems[index].first != "crtend") { + if (LinkItems[index].second) { + std::string lib_name = "-l" + LinkItems[index].first; + args.push_back(lib_name.c_str()); + } else + args.push_back(LinkItems[index].first.c_str()); } args.push_back(0); @@ -433,13 +436,17 @@ try { // Initial global variable above for convenience printing of program name. progname = sys::Path(argv[0]).getBasename(); - Linker TheLinker(progname, OutputFilename, Verbose); // Parse the command line options cl::ParseCommandLineOptions(argc, argv, " llvm linker\n"); sys::PrintStackTraceOnErrorSignal(); - // Set up the library paths for the Linker + // Construct a Linker (now that Verbose is set) + Linker TheLinker(progname, OutputFilename, Verbose); + // Keep track of the native link items (vice the bytecode items) + Linker::ItemList LinkItems; + + // Add library paths to the linker TheLinker.addPaths(LibPaths); TheLinker.addSystemPaths(); @@ -463,11 +470,10 @@ } else { // Build a list of the items from our command line Linker::ItemList Items; - Linker::ItemList NativeItems; BuildLinkItems(Items, InputFilenames, Libraries); // Link all the items together - if (TheLinker.LinkInItems(Items,NativeItems) ) + if (TheLinker.LinkInItems(Items,LinkItems) ) return 1; } @@ -558,7 +564,7 @@ if (Verbose) std::cout << "Generating Native Code\n"; if (0 != GenerateNative(OutputFilename, AssemblyFile.toString(), - Libraries,gcc,envp,ErrMsg)) { + LinkItems,gcc,envp,ErrMsg)) { std::cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } @@ -592,7 +598,7 @@ } if (Verbose) std::cout << "Generating Native Code\n"; - if (0 != GenerateNative(OutputFilename, CFile.toString(), Libraries, + if (0 != GenerateNative(OutputFilename, CFile.toString(), LinkItems, gcc, envp, ErrMsg)) { std::cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits