当前位置: 首页>>代码示例>>C++>>正文


C++ Symtab::emit方法代码示例

本文整理汇总了C++中Symtab::emit方法的典型用法代码示例。如果您正苦于以下问题:C++ Symtab::emit方法的具体用法?C++ Symtab::emit怎么用?C++ Symtab::emit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symtab的用法示例。


在下文中一共展示了Symtab::emit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: inst_printf


//.........这里部分代码省略.........
      // bool loadable: heck yeah...
        
      Region *newSec = NULL;
      symObj->findRegion(newSec, ".dyninstInst");
      if (newSec) {
         // We're re-instrumenting - will fail for now
         fprintf(stderr, "ERROR:  unable to open/reinstrument previously instrumented binary %s!\n", newFileName.c_str());
         return false;
      }

      symObj->addRegion(lowWaterMark_,
                        newSectionPtr,
                        highWaterMark_ - lowWaterMark_,
                        ".dyninstInst",
                        Region::RT_TEXTDATA,
                        true);
	  fprintf(stderr,"Write lowWater : %lx, highWater : %lx\n",lowWaterMark_,highWaterMark_);
      
      symObj->findRegion(newSec, ".dyninstInst");
      assert(newSec);

      
      if (mobj == getAOut()) {
         // Add dynamic symbol relocations
         for (unsigned i=0; i < dependentRelocations.size(); i++) {
            Address to = dependentRelocations[i]->getAddress();
            Symbol *referring = dependentRelocations[i]->getReferring();
            /*
              if (!symObj->isStaticBinary() && !symObj->hasReldyn() && !symObj->hasReladyn()) {
              Address addr = referring->getOffset();
              bool result = writeDataSpace((void *) to, getAddressWidth(), &addr);
              assert(result);
              continue;
              }
            */
               
            // Create the relocationEntry
            relocationEntry localRel(to, referring->getMangledName(), referring,
                                     relocationEntry::getGlobalRelType(getAddressWidth(), referring));
	    
            /*
              if( mobj->isSharedLib() ) {
              localRel.setRelAddr(to - mobj->imageOffset());
              }
            */
            
            symObj->addExternalSymbolReference(referring, newSec, localRel);
            
            /*
              newSymbol = new Symbol(referring->getName(), 
              Symbol::ST_FUNCTION, 
              Symbol::SL_GLOBAL,
              Symbol::SV_DEFAULT, 
              (Address)0, 
              symObj->getDefaultModule(),
              NULL, 
              8,
              true, 
              false);
              symObj->addSymbol(newSymbol, referring);
              if (!symObj->hasReldyn() && symObj->hasReladyn()) {
              newSec->addRelocationEntry(to, newSymbol, relocationEntry::dynrel, Region::RT_RELA);
              } else {
              newSec->addRelocationEntry(to, newSymbol, relocationEntry::dynrel);
              }
            */
         }
      }
      
      pdvector<Symbol *> newSyms;
      buildDyninstSymbols(newSyms, newSec, symObj->getOrCreateModule("dyninstInst",
                                                                     lowWaterMark_));
      for (unsigned i = 0; i < newSyms.size(); i++) {
         symObj->addSymbol(newSyms[i]);
      }
      
      // Okay, now...
      // Hand textSection and newSection to DynSymtab.
        
      // First, textSection.
        
      // From the SymtabAPI documentation: we have the following methods we want to use.
      // Symtab::addSection(Offset vaddr, void *data, unsigned int dataSize, std::string name, 
      //                    unsigned long flags, bool loadable)
      // Symtab::updateCode(void *buffer, unsigned size)
      // Symtab::emit(std::string filename)
        
      // First, text
      assert(symObj);
      
      
      // And now we generate the new binary
      //if (!symObj->emit(newFileName.c_str())) {
      if (!symObj->emit(newFileName.c_str())) {
         SymtabError lastError = Symtab::getLastSymtabError();
         showErrorCallback(109, Symtab::printError(lastError));
         return false;
      }
   return true;
}
开发者ID:sirmc,项目名称:XnRmor,代码行数:101,代码来源:binaryEdit.C


注:本文中的Symtab::emit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。