本文整理汇总了C++中SymbolRef::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolRef::getValue方法的具体用法?C++ SymbolRef::getValue怎么用?C++ SymbolRef::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolRef
的用法示例。
在下文中一共展示了SymbolRef::getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
}
示例2: getSymbolSectionID
std::vector<std::pair<SymbolRef, uint64_t>>
llvm::object::computeSymbolSizes(const ObjectFile &O) {
std::vector<std::pair<SymbolRef, uint64_t>> Ret;
if (const auto *E = dyn_cast<ELFObjectFileBase>(&O)) {
auto Syms = E->symbols();
if (Syms.begin() == Syms.end())
Syms = E->getDynamicSymbolIterators();
for (ELFSymbolRef Sym : Syms)
Ret.push_back({Sym, Sym.getSize()});
return Ret;
}
// Collect sorted symbol addresses. Include dummy addresses for the end
// of each section.
std::vector<SymEntry> Addresses;
unsigned SymNum = 0;
for (symbol_iterator I = O.symbol_begin(), E = O.symbol_end(); I != E; ++I) {
SymbolRef Sym = *I;
uint64_t Value = Sym.getValue();
Addresses.push_back({I, Value, SymNum, getSymbolSectionID(O, Sym)});
++SymNum;
}
for (SectionRef Sec : O.sections()) {
uint64_t Address = Sec.getAddress();
uint64_t Size = Sec.getSize();
Addresses.push_back(
{O.symbol_end(), Address + Size, 0, getSectionID(O, Sec)});
}
array_pod_sort(Addresses.begin(), Addresses.end(), compareAddress);
// Compute the size as the gap to the next symbol
for (unsigned I = 0, N = Addresses.size() - 1; I < N; ++I) {
auto &P = Addresses[I];
if (P.I == O.symbol_end())
continue;
// If multiple symbol have the same address, give both the same size.
unsigned NextI = I + 1;
while (NextI < N && Addresses[NextI].Address == P.Address)
++NextI;
uint64_t Size = Addresses[NextI].Address - P.Address;
P.Address = Size;
}
// Assign the sorted symbols in the original order.
Ret.resize(SymNum);
for (SymEntry &P : Addresses) {
if (P.I == O.symbol_end())
continue;
Ret[P.Number] = {*P.I, P.Address};
}
return Ret;
}
示例3: getSymbolOffset
uint64_t RuntimeDyldCOFF::getSymbolOffset(const SymbolRef &Sym) {
// The value in a relocatable COFF object is the offset.
return Sym.getValue();
}