本文整理汇总了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();
}
示例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();
}
示例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));
}
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
}
}
示例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 ;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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 = {§ion->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;
}
示例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);
}
示例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;
}