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


C++ ObjectFile类代码示例

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


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

示例1:

addr_t
DynamicLoaderPOSIXDYLD::ComputeLoadOffset()
{
    addr_t virt_entry;

    if (m_load_offset != LLDB_INVALID_ADDRESS)
        return m_load_offset;

    if ((virt_entry = GetEntryPoint()) == LLDB_INVALID_ADDRESS)
        return LLDB_INVALID_ADDRESS;

    ModuleSP module = m_process->GetTarget().GetExecutableModule();
    if (!module)
        return LLDB_INVALID_ADDRESS;

    ObjectFile *exe = module->GetObjectFile();
    if (!exe)
        return LLDB_INVALID_ADDRESS;

    Address file_entry = exe->GetEntryPointAddress();

    if (!file_entry.IsValid())
        return LLDB_INVALID_ADDRESS;
            
    m_load_offset = virt_entry - file_entry.GetFileAddress();
    return m_load_offset;
}
开发者ID:cemeyer,项目名称:freebsd-base-graphics,代码行数:27,代码来源:DynamicLoaderPOSIXDYLD.cpp

示例2: if

bool
SymbolContext::GetAddressRange (uint32_t scope, AddressRange &range) const
{
    if ((scope & eSymbolContextLineEntry) && line_entry.IsValid())
    {
        range = line_entry.range;
        return true;
    }
    else if ((scope & eSymbolContextFunction) && function != NULL)
    {
        range = function->GetAddressRange();
        return true;
    }
    else if ((scope & eSymbolContextSymbol) && symbol != NULL && symbol->GetAddressRangePtr())
    {
        range = *symbol->GetAddressRangePtr();

        if (range.GetByteSize() == 0)
        {
            if (module_sp)
            {
                ObjectFile *objfile = module_sp->GetObjectFile();
                if (objfile)
                {
                    Symtab *symtab = objfile->GetSymtab();
                    if (symtab)
                        range.SetByteSize(symtab->CalculateSymbolSize (symbol));
                }
            }
        }
        return true;
    }
    range.Clear();
    return false;
}
开发者ID:ice799,项目名称:lldb,代码行数:35,代码来源:SymbolContext.cpp

示例3: findSymbolAddress

// Find the load address of a symbol
static lldb::addr_t findSymbolAddress( Process *proc, ConstString findName )
{
    assert( proc != nullptr );

    ModuleSP module = proc->GetTarget().GetExecutableModule();
    assert( module.get() != nullptr );

    ObjectFile *exe = module->GetObjectFile();
    assert( exe != nullptr );

    lldb_private::Symtab *symtab = exe->GetSymtab( );
    assert( symtab != nullptr );

    for ( size_t i = 0; i < symtab->GetNumSymbols( ); i++ )
    {
        const Symbol* sym = symtab->SymbolAtIndex( i );
        assert( sym != nullptr );
        const ConstString &symName = sym->GetName( );

        if ( ConstString::Compare( findName, symName ) == 0 )
        {
            Address addr = sym->GetAddress();
            return addr.GetLoadAddress( & proc->GetTarget() );
        }
    }
    return LLDB_INVALID_ADDRESS;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:28,代码来源:DynamicLoaderHexagonDYLD.cpp

示例4: ObjectFile

Builder::Builder( vector<string> &objFilePath,string lib,string output )
{
	libDirPath_ = lib;
	outputPath_ = output;
	entryFunc_ = "mini_crt_entry";
	myEntryFuncObj_ =  lib + "/entry.o";
	objFilePath.push_back(myEntryFuncObj_);
	for( unsigned int i = 0;i < objFilePath.size();++i )
	{
		//这些变量在后面都会以指针形式被保存下来,所以不能用局部变亮
		ObjectFile *pObj = new ObjectFile( objFilePath[i] );
		if( !pObj->IsValid() )
		{
			cout << objFilePath[i] << " is invalid. * Ignore *" << endl;
			continue;
		}
		ElfHeader *pEh = new ElfHeader;
		pEh->GetHeader( *pObj );
		Section *pSec = new Section();
		if( !pSec->GetSection(*pEh) )
		{
			cout << "error while getting section:" << objFilePath[i] << endl;
			exit(0);
		}
		if( !pSec->GetSymbol() )
		{
			cout << "error while getting symbols:" << objFilePath[i] << endl;
			exit(0);
		}

		rawSection_.push_back(pSec);
	}
}
开发者ID:gfblueprint,项目名称:MiniLinker,代码行数:33,代码来源:builderClass.cpp

示例5: SymbolVendor

//----------------------------------------------------------------------
// FindPlugin
//
// Platforms can register a callback to use when creating symbol
// vendors to allow for complex debug information file setups, and to
// also allow for finding separate debug information files.
//----------------------------------------------------------------------
SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp,
                                       lldb_private::Stream *feedback_strm) {
  std::unique_ptr<SymbolVendor> instance_ap;
  SymbolVendorCreateInstance create_callback;

  for (size_t idx = 0;
       (create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(
            idx)) != nullptr;
       ++idx) {
    instance_ap.reset(create_callback(module_sp, feedback_strm));

    if (instance_ap.get()) {
      return instance_ap.release();
    }
  }
  // The default implementation just tries to create debug information using the
  // file representation for the module.
  instance_ap.reset(new SymbolVendor(module_sp));
  if (instance_ap.get()) {
    ObjectFile *objfile = module_sp->GetObjectFile();
    if (objfile)
      instance_ap->AddSymbolFileRepresentation(objfile->shared_from_this());
  }
  return instance_ap.release();
}
开发者ID:linux-on-ibm-z,项目名称:swift-lldb,代码行数:32,代码来源:SymbolVendor.cpp

示例6: SymbolVendor

//----------------------------------------------------------------------
// FindPlugin
//
// Platforms can register a callback to use when creating symbol
// vendors to allow for complex debug information file setups, and to
// also allow for finding separate debug information files.
//----------------------------------------------------------------------
SymbolVendor*
SymbolVendor::FindPlugin (Module* module)
{
    std::auto_ptr<SymbolVendor> instance_ap;
    //----------------------------------------------------------------------
    // We currently only have one debug symbol parser...
    //----------------------------------------------------------------------
    SymbolVendorCreateInstance create_callback;
    for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(idx)) != NULL; ++idx)
    {
        instance_ap.reset(create_callback(module));

        if (instance_ap.get())
        {
            // TODO: make sure this symbol vendor is what we want. We
            // currently are just returning the first one we find, but
            // we may want to call this function only when we have our
            // main executable module and then give all symbol vendor
            // plug-ins a chance to compete for who wins.
            return instance_ap.release();
        }
    }
    // The default implementation just tries to create debug information using the
    // file representation for the module.
    instance_ap.reset(new SymbolVendor(module));
    if (instance_ap.get())
    {
        ObjectFile *objfile = module->GetObjectFile();
        if (objfile)
            instance_ap->AddSymbolFileRepresentation(objfile->GetSP());
    }
    return instance_ap.release();
}
开发者ID:fbsd,项目名称:old_lldb,代码行数:40,代码来源:SymbolVendor.cpp

示例7: module_sp

SBSection
SBModule::FindSection (const char *sect_name)
{
    SBSection sb_section;
    
    ModuleSP module_sp (GetSP ());
    if (sect_name && module_sp)
    {
        ObjectFile *objfile = module_sp->GetObjectFile();
        if (objfile)
        {
            SectionList *section_list = objfile->GetSectionList();
            if (section_list)
            {
                ConstString const_sect_name(sect_name);
                SectionSP section_sp (section_list->FindSectionByName(const_sect_name));
                if (section_sp)
                {
                    sb_section.SetSP (section_sp);
                }
            }
        }
    }
    return sb_section;
}
开发者ID:carlokok,项目名称:lldb,代码行数:25,代码来源:SBModule.cpp

示例8: locker

void
Module::Dump(Stream *s)
{
    Mutex::Locker locker (m_mutex);
    //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
    s->Indent();
    s->Printf("Module %s/%s%s%s%s\n",
              m_file.GetDirectory().AsCString(),
              m_file.GetFilename().AsCString(),
              m_object_name ? "(" : "",
              m_object_name ? m_object_name.GetCString() : "",
              m_object_name ? ")" : "");

    s->IndentMore();
    ObjectFile *objfile = GetObjectFile ();

    if (objfile)
        objfile->Dump(s);

    SymbolVendor *symbols = GetSymbolVendor ();

    if (symbols)
        symbols->Dump(s);

    s->IndentLess();
}
开发者ID:eightcien,项目名称:lldb,代码行数:26,代码来源:Module.cpp

示例9: scoped_timer

size_t
Module::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, SymbolContextList &sc_list)
{
    // No need to protect this call using m_mutex all other method calls are
    // already thread safe.


    Timer scoped_timer(__PRETTY_FUNCTION__,
                       "Module::FindSymbolsWithNameAndType (name = %s, type = %i)",
                       name.AsCString(),
                       symbol_type);
    const size_t initial_size = sc_list.GetSize();
    ObjectFile *objfile = GetObjectFile ();
    if (objfile)
    {
        Symtab *symtab = objfile->GetSymtab();
        if (symtab)
        {
            std::vector<uint32_t> symbol_indexes;
            symtab->FindAllSymbolsWithNameAndType (name, symbol_type, symbol_indexes);
            SymbolIndicesToSymbolContextList (symtab, symbol_indexes, sc_list);
        }
    }
    return sc_list.GetSize() - initial_size;
}
开发者ID:eightcien,项目名称:lldb,代码行数:25,代码来源:Module.cpp

示例10:

//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
enum ObjCRuntimeVersions
AppleObjCRuntime::GetObjCVersion (Process *process, ModuleSP &objc_module_sp)
{
    ModuleList &images = process->GetTarget().GetImages();
    size_t num_images = images.GetSize();
    for (size_t i = 0; i < num_images; i++)
    {
        ModuleSP module_sp = images.GetModuleAtIndex(i);
        if (AppleIsModuleObjCLibrary (module_sp))
        {
            objc_module_sp = module_sp;
            ObjectFile *ofile = module_sp->GetObjectFile();
            if (!ofile)
                return eObjC_VersionUnknown;
            
            SectionList *sections = ofile->GetSectionList();
            if (!sections)
                return eObjC_VersionUnknown;    
            SectionSP v1_telltale_section_sp = sections->FindSectionByName(ConstString ("__OBJC"));
            if (v1_telltale_section_sp)
            {
                return eAppleObjC_V1;
            }
            return eAppleObjC_V2;
        }
    }
            
    return eObjC_VersionUnknown;
}
开发者ID:fbsd,项目名称:old_lldb,代码行数:32,代码来源:AppleObjCRuntime.cpp

示例11: computeSectionStubBufSize

// compute stub buffer size for the given section
unsigned RuntimeDyldImpl::computeSectionStubBufSize(const ObjectFile &Obj,
                                                    const SectionRef &Section) {
  unsigned StubSize = getMaxStubSize();
  if (StubSize == 0) {
    return 0;
  }
  // FIXME: this is an inefficient way to handle this. We should computed the
  // necessary section allocation size in loadObject by walking all the sections
  // once.
  unsigned StubBufSize = 0;
  for (section_iterator SI = Obj.section_begin(), SE = Obj.section_end();
       SI != SE; ++SI) {
    section_iterator RelSecI = SI->getRelocatedSection();
    if (!(RelSecI == Section))
      continue;

    for (const RelocationRef &Reloc : SI->relocations()) {
      (void)Reloc;
      StubBufSize += StubSize;
    }
  }

  // Get section data size and alignment
  uint64_t DataSize = Section.getSize();
  uint64_t Alignment64 = Section.getAlignment();

  // Add stubbuf size alignment
  unsigned Alignment = (unsigned)Alignment64 & 0xffffffffL;
  unsigned StubAlignment = getStubAlignment();
  unsigned EndAlignment = (DataSize | Alignment) & -(DataSize | Alignment);
  if (StubAlignment > EndAlignment)
    StubBufSize += StubAlignment - EndAlignment;
  return StubBufSize;
}
开发者ID:MessiahAndrw,项目名称:Perception,代码行数:35,代码来源:RuntimeDyld.cpp

示例12: dumpObject

static error_code dumpObject(const ObjectFile &Obj) {
  if (Obj.isCOFF())
    return coff2yaml(outs(), cast<COFFObjectFile>(Obj));
  if (Obj.isELF())
    return elf2yaml(outs(), Obj);

  return obj2yaml_error::unsupported_obj_file_format;
}
开发者ID:ADonut,项目名称:LLVM-GPGPU,代码行数:8,代码来源:obj2yaml.cpp

示例13: ERROR_MSG

// Delete an object
bool OSToken::deleteObject(OSObject* object)
{
	if (!valid) return false;

	if (objects.find(object) == objects.end())
	{
		ERROR_MSG("Cannot delete non-existent object 0x%08X", object);

		return false;
	}

	MutexLocker lock(tokenMutex);

	ObjectFile* fileObject = dynamic_cast<ObjectFile*>(object);
	if (fileObject == NULL)
	{
		ERROR_MSG("Object type not compatible with this token class 0x%08X", object);

		return false;
	}
	
	// Invalidate the object instance
	fileObject->invalidate();

	// Retrieve the filename of the object
	std::string objectFilename = fileObject->getFilename();

	// Attempt to delete the file
	if (!tokenDir->remove(objectFilename))
	{
		ERROR_MSG("Failed to delete object file %s", objectFilename.c_str());

		return false;
	}

	// Retrieve the filename of the lock
	std::string lockFilename = fileObject->getLockname();

	// Attempt to delete the lock
	if (!tokenDir->remove(lockFilename))
	{
		ERROR_MSG("Failed to delete lock file %s", lockFilename.c_str());

		return false;
	}

	objects.erase(object);

	DEBUG_MSG("Deleted object %s", objectFilename.c_str());

	gen->update();

	gen->commit();

	return true;
}
开发者ID:GarysRefererence2014,项目名称:SoftHSMv2,代码行数:57,代码来源:OSToken.cpp

示例14: module_sp

void SymbolVendor::ClearSymtab() {
  ModuleSP module_sp(GetModule());
  if (module_sp) {
    ObjectFile *objfile = module_sp->GetObjectFile();
    if (objfile) {
      // Clear symbol table from unified section list.
      objfile->ClearSymtab();
    }
  }
}
开发者ID:linux-on-ibm-z,项目名称:swift-lldb,代码行数:10,代码来源:SymbolVendor.cpp

示例15: read

std::vector<section> read(const ObjectFile& obj) {
    int size = utils::distance(obj.begin_sections(),
                               obj.end_sections());
    std::vector<section> sections;
    sections.reserve(size);
    std::transform(obj.begin_sections(),
                   obj.end_sections(),
                   std::back_inserter(sections),
                   [](const SectionRef& s) { return section(s); });
    return sections;
}
开发者ID:jamella,项目名称:bap,代码行数:11,代码来源:llvm_binary.hpp


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