Jochen Wilhelmy
2011-Feb-18 16:18 UTC
[LLVMdev] Please add .o writer example to next release
Hi! Is it possible that you add an example how to write a .o with llvm? Just like examples/ModuleMaker but instead of printing to stdout writing a .o file as starting point for the new MC functionality. -Jochen
Óscar Fuentes
2011-Feb-18 16:33 UTC
[LLVMdev] Please add .o writer example to next release
Jochen Wilhelmy <j.wilhelmy at arcor.de> writes:> Is it possible that you add an example how to write a .o with llvm?+1
Nathan Jeffords
2011-Feb-18 17:18 UTC
[LLVMdev] Please add .o writer example to next release
this is function I use to emit an object file: void output_object (llvm::Module * Module, llvm::TargetMachine * Target, llvm::raw_ostream & Output) { llvm::formatted_raw_ostream fOutput (Output); FunctionPassManager Passes(Module); Passes.add(new TargetData (*Target->getTargetData())); if (Target->addPassesToEmitFile(Passes, fOutput, llvm::TargetMachine::CGFT_ObjectFile, llvm::CodeGenOpt::None)) throw std::runtime_error ("bad voodoo (Target->addPassesToEmitFile)"); Passes.doInitialization(); for (llvm::Module::iterator I = Module->begin(), E = Module->end(); I !E; ++I) if (!I->isDeclaration()) Passes.run(*I); Passes.doFinalization(); } On Fri, Feb 18, 2011 at 8:33 AM, Óscar Fuentes <ofv at wanadoo.es> wrote:> Jochen Wilhelmy <j.wilhelmy at arcor.de> writes: > > > Is it possible that you add an example how to write a .o with llvm? > > +1 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110218/8c750353/attachment.html>