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


C++ SymbolRef::getName方法代码示例

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


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

示例1: 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

示例2: OS

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)) {
    Expected<StringRef> Name = Symbol.getName();
    if (Name) {
      OS << *Name;
      if (Displacement > 0)
        OS << format(" +0x%X (0x%" PRIX64 ")", Displacement, Offset);
      else
        OS << format(" (0x%" PRIX64 ")", Offset);
      return OS.str();
    } else {
      // TODO: Actually report errors helpfully.
      consumeError(Name.takeError());
    }
  }

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

示例3: resolveSymbolName

// Given a vector of relocations for a section and an offset into this section
// the function returns the name of the symbol used for the relocation at the
// offset.
static error_code resolveSymbolName(const std::vector<RelocationRef> &Rels,
                                    uint64_t Offset, StringRef &Name) {
  SymbolRef Sym;
  if (error_code ec = resolveSymbol(Rels, Offset, Sym)) return ec;
  if (error_code ec = Sym.getName(Name)) return ec;
  return object_error::success;
}
开发者ID:32bitmicro,项目名称:llvm,代码行数:10,代码来源:COFFDump.cpp

示例4: error_code

// Given a vector of relocations for a section and an offset into this section
// the function returns the name of the symbol used for the relocation at the
// offset.
static std::error_code resolveSymbolName(const std::vector<RelocationRef> &Rels,
                                         uint64_t Offset, StringRef &Name) {
  SymbolRef Sym;
  if (std::error_code EC = resolveSymbol(Rels, Offset, Sym))
    return EC;
  if (std::error_code EC = Sym.getName(Name))
    return EC;
  return std::error_code();
}
开发者ID:Nanosim-LIG,项目名称:llvm,代码行数:12,代码来源:COFFDump.cpp

示例5: resolveSymbolName

// Given a section and an offset into this section the function returns the name
// of the symbol used for the relocation at the offset.
std::error_code COFFDumper::resolveSymbolName(const coff_section *Section,
                                              uint64_t Offset,
                                              StringRef &Name) {
  SymbolRef Symbol;
  if (std::error_code EC = resolveSymbol(Section, Offset, Symbol))
    return EC;
  if (std::error_code EC = Symbol.getName(Name))
    return EC;
  return object_error::success;
}
开发者ID:DragonToothSoftware,项目名称:llvm,代码行数:12,代码来源:COFFDumper.cpp

示例6: errorToErrorCode

// Given a vector of relocations for a section and an offset into this section
// the function returns the name of the symbol used for the relocation at the
// offset.
static std::error_code resolveSymbolName(const std::vector<RelocationRef> &Rels,
                                         uint64_t Offset, StringRef &Name) {
  SymbolRef Sym;
  if (std::error_code EC = resolveSymbol(Rels, Offset, Sym))
    return EC;
  Expected<StringRef> NameOrErr = Sym.getName();
  if (!NameOrErr)
    return errorToErrorCode(NameOrErr.takeError());
  Name = *NameOrErr;
  return std::error_code();
}
开发者ID:fcrick,项目名称:llvm,代码行数:14,代码来源:COFFDump.cpp

示例7: error_code

// Given a vector of relocations for a section and an offset into this section
// the function returns the name of the symbol used for the relocation at the
// offset.
static std::error_code resolveSymbolName(const std::vector<RelocationRef> &Rels,
                                         uint64_t Offset, StringRef &Name) {
  SymbolRef Sym;
  if (std::error_code EC = resolveSymbol(Rels, Offset, Sym))
    return EC;
  ErrorOr<StringRef> NameOrErr = Sym.getName();
  if (std::error_code EC = NameOrErr.getError())
    return EC;
  Name = *NameOrErr;
  return std::error_code();
}
开发者ID:AlexDenisov,项目名称:llvm,代码行数:14,代码来源:COFFDump.cpp

示例8: resolveSymbolName

// Given a section and an offset into this section the function returns the name
// of the symbol used for the relocation at the offset.
std::error_code COFFDumper::resolveSymbolName(const coff_section *Section,
                                              uint64_t Offset,
                                              StringRef &Name) {
  SymbolRef Symbol;
  if (std::error_code EC = resolveSymbol(Section, Offset, Symbol))
    return EC;
  ErrorOr<StringRef> NameOrErr = Symbol.getName();
  if (std::error_code EC = NameOrErr.getError())
    return EC;
  Name = *NameOrErr;
  return std::error_code();
}
开发者ID:zhiyongLee,项目名称:llvm,代码行数:14,代码来源:COFFDumper.cpp

示例9: 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);
 }
开发者ID:Matthewxie,项目名称:bap,代码行数:15,代码来源:llvm_binary_stubs.hpp

示例10: OS

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

示例11: addSymbol

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

示例12:

error_or<std::string> get_name(const SymbolRef &sym) {
    auto er_name = sym.getName();
    auto e = of_llvm_error_or(er_name);
    return map_value<std::string>(e, [](const StringRef &x){return x.str();});
}
开发者ID:ivg,项目名称:bap,代码行数:5,代码来源:llvm_binary_38_40.hpp


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