[LLVMdev] How to use the llvm::Linker?

xiaoyaollvm xiaoyaollvm at 126.com
Fri Mar 29 01:22:20 PDT 2013


Hi,All
this one pass that will use the Linker
namespace {
  // Hello2 - The second implementation with getAnalysisUsage implemented.
  llvm::StringRef programNametest("");
  struct Hello2 : public ModulePass {
    static char ID; // Pass identification, replacement for typeid
    Hello2() : ModulePass(ID) {}

    virtual bool runOnModule(llvm::Module &M){
      llvm::Linker *linkertest = new llvm::Linker(programNametest,&M);
      llvm::errs() << linkertest->getModule();
      ++HelloCounter;
      errs() << "Hello: ";
      return false;
    }

    // We don't modify the program, so we preserve all analyses
    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
      AU.setPreservesAll();
    }
  };
}

char Hello2::ID = 0;
static RegisterPass<Hello2>
Y1("hello2", "Hello World Pass (with getAnalysisUsage implemented)");

But ,when i run the  pass with opt, there will be a Error:
./bin/opt: symbol lookup error: ./lib/Hello.so: undefined symbol: _ZN4llvm6Linker11LinkModulesEPNS_6ModuleES2_jPSs
by the c++filt, the function name is :
llvm::Linker::LinkModules(llvm::Module*, llvm::Module*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)
So I think, may I should  Modify the cmake, I want to know how to modify the files of  cmake, so that i can complier the pass with Linker.
Thank.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130329/59891356/attachment.html>


More information about the llvm-dev mailing list