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


C++ SymbolRef类代码示例

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


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

示例1: DynamicTypeInfo

DynamicTypeInfo ProgramState::getDynamicTypeInfo(const MemRegion *Reg) const {
  Reg = Reg->StripCasts();

  // Look up the dynamic type in the GDM.
  const DynamicTypeInfo *GDMType = get<DynamicTypeMap>(Reg);
  if (GDMType)
    return *GDMType;

  // Otherwise, fall back to what we know about the region.
  if (const TypedRegion *TR = dyn_cast<TypedRegion>(Reg))
    return DynamicTypeInfo(TR->getLocationType(), /*CanBeSubclass=*/false);

  if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(Reg)) {
    SymbolRef Sym = SR->getSymbol();
    return DynamicTypeInfo(Sym->getType());
  }

  return DynamicTypeInfo();
}
开发者ID:agheorghiu,项目名称:root,代码行数:19,代码来源:ProgramState.cpp

示例2: resolveRelocation

static std::error_code resolveRelocation(const Dumper::Context &Ctx,
                                         const coff_section *Section,
                                         uint64_t Offset,
                                         const coff_section *&ResolvedSection,
                                         uint64_t &ResolvedAddress) {
  SymbolRef Symbol;
  if (std::error_code EC =
          Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData))
    return EC;

  ErrorOr<uint64_t> ResolvedAddressOrErr = Symbol.getAddress();
  if (std::error_code EC = ResolvedAddressOrErr.getError())
    return EC;
  ResolvedAddress = *ResolvedAddressOrErr;

  ErrorOr<section_iterator> SI = Symbol.getSection();
  ResolvedSection = Ctx.COFF.getCOFFSection(**SI);
  return std::error_code();
}
开发者ID:adiaaida,项目名称:llvm,代码行数:19,代码来源:Win64EHDumper.cpp

示例3: symbol_address

error_or<int64_t> symbol_address(const ELFObjectFile<T> &obj, const SymbolRef &sym) {
    auto sym_elf = obj.getSymbol(sym.getRawDataRefImpl());
    if (is_rel(obj) && !is_abs_symbol(*sym_elf)) { // abs symbols does not affected by relocations
        return success(int64_t(0));
    } else {
        auto addr = prim::symbol_address(sym);
        if (!addr) return addr;
        auto base = base_address(obj);
        return success(prim::relative_address(base, *addr));
    }
}
开发者ID:rvantonder,项目名称:bap,代码行数:11,代码来源:llvm_elf_loader.hpp

示例4: getSymbol

void DyldELFObject<target_endianness, is64Bits>::updateSymbolAddress(
                                                       const SymbolRef &SymRef,
                                                       uint64_t Addr) {

  Elf_Sym *sym = const_cast<Elf_Sym*>(
                                 ELFObjectFile<target_endianness, is64Bits>::
                                   getSymbol(SymRef.getRawDataRefImpl()));

  // This assumes the address passed in matches the target address bitness
  // The template-based type cast handles everything else.
  sym->st_value = static_cast<addr_type>(Addr);
}
开发者ID:JeeLiu,项目名称:myDocument,代码行数:12,代码来源:RuntimeDyldELF.cpp

示例5: checkNull

ConditionTruthVal ConstraintManager::checkNull(ProgramStateRef State,
                                               SymbolRef Sym) {
  QualType Ty = Sym->getType();
  DefinedSVal V = Loc::isLocType(Ty) ? getLocFromSymbol(State, Sym)
                                     : nonloc::SymbolVal(Sym);
  const ProgramStatePair &P = assumeDual(State, V);
  if (P.first && !P.second)
    return ConditionTruthVal(false);
  if (!P.first && P.second)
    return ConditionTruthVal(true);
  return ConditionTruthVal();
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:12,代码来源:ConstraintManager.cpp

示例6: formatSymbol

static std::string formatSymbol(const Dumper::Context &Ctx,
                                const coff_section *Section, uint64_t Offset,
                                uint32_t Displacement) {
  std::string Buffer;
  raw_string_ostream OS(Buffer);

  SymbolRef Symbol;
  if (!Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData)) {
    if (ErrorOr<StringRef> Name = Symbol.getName()) {
      OS << *Name;
      if (Displacement > 0)
        OS << format(" +0x%X (0x%" PRIX64 ")", Displacement, Offset);
      else
        OS << format(" (0x%" PRIX64 ")", Offset);
      return OS.str();
    }
  }

  OS << format(" (0x%" PRIX64 ")", Offset);
  return OS.str();
}
开发者ID:IanLee1521,项目名称:ares,代码行数:21,代码来源:Win64EHDumper.cpp

示例7: errorToErrorCode

std::error_code SymbolizableObjectFile::addSymbol(const SymbolRef &Symbol,
                                                  uint64_t SymbolSize,
                                                  DataExtractor *OpdExtractor,
                                                  uint64_t OpdAddress) {
  ErrorOr<SymbolRef::Type> SymbolTypeOrErr = Symbol.getType();
  if (auto EC = SymbolTypeOrErr.getError())
    return EC;
  SymbolRef::Type SymbolType = *SymbolTypeOrErr;
  if (SymbolType != SymbolRef::ST_Function && SymbolType != SymbolRef::ST_Data)
    return std::error_code();
  ErrorOr<uint64_t> SymbolAddressOrErr = Symbol.getAddress();
  if (auto EC = SymbolAddressOrErr.getError())
    return EC;
  uint64_t SymbolAddress = *SymbolAddressOrErr;
  if (OpdExtractor) {
    // For big-endian PowerPC64 ELF, symbols in the .opd section refer to
    // function descriptors. The first word of the descriptor is a pointer to
    // the function's code.
    // For the purposes of symbolization, pretend the symbol's address is that
    // of the function's code, not the descriptor.
    uint64_t OpdOffset = SymbolAddress - OpdAddress;
    uint32_t OpdOffset32 = OpdOffset;
    if (OpdOffset == OpdOffset32 && 
        OpdExtractor->isValidOffsetForAddress(OpdOffset32))
      SymbolAddress = OpdExtractor->getAddress(&OpdOffset32);
  }
  Expected<StringRef> SymbolNameOrErr = Symbol.getName();
  if (!SymbolNameOrErr)
    return errorToErrorCode(SymbolNameOrErr.takeError());
  StringRef SymbolName = *SymbolNameOrErr;
  // Mach-O symbol table names have leading underscore, skip it.
  if (Module->isMachO() && SymbolName.size() > 0 && SymbolName[0] == '_')
    SymbolName = SymbolName.drop_front();
  // FIXME: If a function has alias, there are two entries in symbol table
  // with same address size. Make sure we choose the correct one.
  auto &M = SymbolType == SymbolRef::ST_Function ? Functions : Objects;
  SymbolDesc SD = { SymbolAddress, SymbolSize };
  M.insert(std::make_pair(SD, SymbolName));
  return std::error_code();
}
开发者ID:AnachroNia,项目名称:llvm,代码行数:40,代码来源:SymbolizableObjectFile.cpp

示例8: symbol

    explicit symbol(const SymbolRef& sym) {
        StringRef name;
        if(error_code err = sym.getName(name))
            llvm_binary_fail(err);
        this->name_ = name.str();

        if (error_code err = sym.getType(this->kind_))
            llvm_binary_fail(err);

        if (error_code err = sym.getAddress(this->addr_))
            llvm_binary_fail(err);

        if (error_code err = sym.getSize(this->size_))
            llvm_binary_fail(err);

        uint32_t flags;
        if (error_code err = sym.getFlags(flags))
            llvm_binary_fail(err);

        if (flags & SymbolRef::SF_Undefined) {
            uint64_t addr;
            if (error_code err = sym.getValue(addr))
                llvm_binary_fail(err);
            // This will not work for x86-64, since they usually zero
            // the value. BFD library uses index correspondence
            // between plt entry and relocation, to name the plt
            // entry. We can't afford this.
            if (addr) {
                addr_ = addr;
                size_ = 8;
            }
        }
    }
开发者ID:hurryon,项目名称:bap,代码行数:33,代码来源:llvm_binary.hpp

示例9: symbol_entry

void symbol_entry(const ELFObjectFile<T> &obj, const SymbolRef &sym, ogre_doc &s) {
    auto sym_elf = obj.getSymbol(sym.getRawDataRefImpl());
    if (is_abs_symbol(*sym_elf)) {
        return;
    }
    auto name = prim::symbol_name(sym);
    auto addr = symbol_address(obj, sym);
    auto off = symbol_file_offset(obj, sym);
    if (name && addr && off) {
        s.entry("symbol-entry") << *name << *addr << sym_elf->st_size << *off;
        if (sym_elf->getType() == ELF::STT_FUNC)
            s.entry("code-entry") << *name << *off << sym_elf->st_size ;
    }
}
开发者ID:rvantonder,项目名称:bap,代码行数:14,代码来源:llvm_elf_loader.hpp

示例10: elfsym

bool
ElfConfig::ReadSymbolTable(const MemoryBuffer&  in,
                           const ElfSection&    symtab_sect,
                           ElfSymtab&           symtab,
                           Object&              object,
                           const StringTable&   strtab,
                           Section*             sections[],
                           DiagnosticsEngine&   diags) const
{
    ElfSize symsize = symtab_sect.getEntSize();
    if (symsize == 0)
    {
        diags.Report(SourceLocation(), diag::err_symbol_entity_size_zero);
        return false;
    }

    unsigned long size = symtab_sect.getSize().getUInt();

    // Symbol table always starts with null entry
    symtab.push_back(SymbolRef(0));

    ElfSymbolIndex index = 1;
    for (unsigned long pos=symsize; pos<size; pos += symsize, ++index)
    {
        std::auto_ptr<ElfSymbol> elfsym(
            new ElfSymbol(*this, in, symtab_sect, index, sections, diags));
        if (diags.hasErrorOccurred())
            return false;

        SymbolRef sym = elfsym->CreateSymbol(object, strtab);
        symtab.push_back(sym);

        if (sym)
            sym->AddAssocData(elfsym);  // Associate symbol data with symbol
    }
    return true;
}
开发者ID:8l,项目名称:yasm-nextgen,代码行数:37,代码来源:ElfConfig.cpp

示例11: isLive

bool SymbolReaper::isLive(SymbolRef sym) {
  if (TheLiving.count(sym)) {
    markDependentsLive(sym);
    return true;
  }
  
  bool KnownLive;
  
  switch (sym->getKind()) {
  case SymExpr::RegionValueKind:
    // FIXME: We should be able to use isLiveRegion here (this behavior
    // predates isLiveRegion), but doing so causes test failures. Investigate.
    KnownLive = true;
    break;
  case SymExpr::ConjuredKind:
    KnownLive = false;
    break;
  case SymExpr::DerivedKind:
    KnownLive = isLive(cast<SymbolDerived>(sym)->getParentSymbol());
    break;
  case SymExpr::ExtentKind:
    KnownLive = isLiveRegion(cast<SymbolExtent>(sym)->getRegion());
    break;
  case SymExpr::MetadataKind:
    KnownLive = MetadataInUse.count(sym) &&
                isLiveRegion(cast<SymbolMetadata>(sym)->getRegion());
    if (KnownLive)
      MetadataInUse.erase(sym);
    break;
  case SymExpr::SymIntKind:
    KnownLive = isLive(cast<SymIntExpr>(sym)->getLHS());
    break;
  case SymExpr::IntSymKind:
    KnownLive = isLive(cast<IntSymExpr>(sym)->getRHS());
    break;
  case SymExpr::SymSymKind:
    KnownLive = isLive(cast<SymSymExpr>(sym)->getLHS()) &&
                isLive(cast<SymSymExpr>(sym)->getRHS());
    break;
  case SymExpr::CastSymbolKind:
    KnownLive = isLive(cast<SymbolCast>(sym)->getOperand());
    break;
  }

  if (KnownLive)
    markLive(sym);

  return KnownLive;
}
开发者ID:DawidvC,项目名称:clang-glambda,代码行数:49,代码来源:SymbolManager.cpp

示例12: getOffset

static std::error_code getOffset(const SymbolRef &Sym, uint64_t &Result) {
  uint64_t Address;
  if (std::error_code EC = Sym.getAddress(Address))
    return EC;

  if (Address == UnknownAddressOrSize) {
    Result = UnknownAddressOrSize;
    return object_error::success;
  }

  const ObjectFile *Obj = Sym.getObject();
  section_iterator SecI(Obj->section_begin());
  if (std::error_code EC = Sym.getSection(SecI))
    return EC;

  if (SecI == Obj->section_end()) {
    Result = UnknownAddressOrSize;
    return object_error::success;
  }

  uint64_t SectionAddress = SecI->getAddress();
  Result = Address - SectionAddress;
  return object_error::success;
}
开发者ID:Pwootage,项目名称:llvm,代码行数:24,代码来源:RuntimeDyld.cpp

示例13: Section

Section*
XdfObject::AppendSection(llvm::StringRef name,
                         SourceLocation source,
                         Diagnostic& diags)
{
    bool code = (name == ".text");
    Section* section = new Section(name, code, false, source);
    m_object.AppendSection(std::auto_ptr<Section>(section));

    // Define a label for the start of the section
    Location start = {&section->bytecodes_front(), 0};
    SymbolRef sym = m_object.getSymbol(name);
    if (!sym->isDefined())
    {
        sym->DefineLabel(start);
        sym->setDefSource(source);
    }
    section->setSymbol(sym);

    // Add XDF data to the section
    section->AddAssocData(std::auto_ptr<XdfSection>(new XdfSection(sym)));

    return section;
}
开发者ID:PeterJohnson,项目名称:yasm-nextgen,代码行数:24,代码来源:XdfObject.cpp

示例14: assumeSymNE

ProgramStateRef
SimpleConstraintManager::assumeAuxForSymbol(ProgramStateRef State,
                                            SymbolRef Sym, bool Assumption) {
  BasicValueFactory &BVF = getBasicVals();
  QualType T = Sym->getType();

  // None of the constraint solvers currently support non-integer types.
  if (!T->isIntegralOrEnumerationType())
    return State;

  const llvm::APSInt &zero = BVF.getValue(0, T);
  if (Assumption)
    return assumeSymNE(State, Sym, zero, zero);
  else
    return assumeSymEQ(State, Sym, zero, zero);
}
开发者ID:cms-externals,项目名称:clang,代码行数:16,代码来源:SimpleConstraintManager.cpp

示例15: isLive

bool SymbolReaper::isLive(SymbolRef sym) {
  if (TheLiving.count(sym)) {
    markDependentsLive(sym);
    return true;
  }
  
  bool KnownLive;
  
  switch (sym->getKind()) {
  case SymExpr::RegionValueKind:
    KnownLive = isLiveRegion(cast<SymbolRegionValue>(sym)->getRegion());
    break;
  case SymExpr::ConjuredKind:
    KnownLive = false;
    break;
  case SymExpr::DerivedKind:
    KnownLive = isLive(cast<SymbolDerived>(sym)->getParentSymbol());
    break;
  case SymExpr::ExtentKind:
    KnownLive = isLiveRegion(cast<SymbolExtent>(sym)->getRegion());
    break;
  case SymExpr::MetadataKind:
    KnownLive = MetadataInUse.count(sym) &&
                isLiveRegion(cast<SymbolMetadata>(sym)->getRegion());
    if (KnownLive)
      MetadataInUse.erase(sym);
    break;
  case SymExpr::SymIntKind:
    KnownLive = isLive(cast<SymIntExpr>(sym)->getLHS());
    break;
  case SymExpr::IntSymKind:
    KnownLive = isLive(cast<IntSymExpr>(sym)->getRHS());
    break;
  case SymExpr::SymSymKind:
    KnownLive = isLive(cast<SymSymExpr>(sym)->getLHS()) &&
                isLive(cast<SymSymExpr>(sym)->getRHS());
    break;
  case SymExpr::CastSymbolKind:
    KnownLive = isLive(cast<SymbolCast>(sym)->getOperand());
    break;
  }

  if (KnownLive)
    markLive(sym);

  return KnownLive;
}
开发者ID:4ntoine,项目名称:clang,代码行数:47,代码来源:SymbolManager.cpp


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